text:
.class public Lcom/samsung/android/graphics/spr/document/debug/SprDebug;
.super Ljava/lang/Object;
.source "SprDebug.java"

# static fields
.field public static final DEBUG_HIGH:I = 0x3

.field public static final DEBUG_LOW:I = 0x1

.field public static final DEBUG_MID:I = 0x2

.field public static IsDebug:Z

.field private static mDebugLevel:Ljava/lang/Integer;

.field private static mTextOutlinePaint:Landroid/graphics/Paint;

.field private static mTextPaint:Landroid/graphics/Paint;

# direct methods
.method static constructor <clinit>()V
    .locals 9

    const/4 v3, 0x0

    const/4 v4, 0x1

    const/4 v5, 0x0

    sput-boolean v5, Lcom/samsung/android/graphics/spr/document/debug/SprDebug;->IsDebug:Z

    sput-object v3, Lcom/samsung/android/graphics/spr/document/debug/SprDebug;->mDebugLevel:Ljava/lang/Integer;

    sput-object v3, Lcom/samsung/android/graphics/spr/document/debug/SprDebug;->mTextPaint:Landroid/graphics/Paint;

    sput-object v3, Lcom/samsung/android/graphics/spr/document/debug/SprDebug;->mTextOutlinePaint:Landroid/graphics/Paint;

    const-string/jumbo v3, "eng"

    sget-object v6, Landroid/os/Build;->TYPE:Ljava/lang/String;

    invoke-virtual {v3, v6}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v3

    if-eqz v3, :cond_0

    :try_start_0
    const-string/jumbo v3, "android.os.SystemProperties"

    invoke-static {v3}, Ljava/lang/Class;->forName(Ljava/lang/String;)Ljava/lang/Class;

    move-result-object v0

    const-string/jumbo v3, "getInt"

    const/4 v6, 0x2

    new-array v6, v6, [Ljava/lang/Class;

    const-class v7, Ljava/lang/String;

    const/4 v8, 0x0

    aput-object v7, v6, v8

    sget-object v7, Ljava/lang/Integer;->TYPE:Ljava/lang/Class;

    const/4 v8, 0x1

    aput-object v7, v6, v8

    invoke-virtual {v0, v3, v6}, Ljava/lang/Class;->getMethod(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;

    move-result-object v2

    const/4 v3, 0x2

    new-array v3, v3, [Ljava/lang/Object;

    const-string/jumbo v6, "persist.sys.spr.debug"

    const/4 v7, 0x0

    aput-object v6, v3, v7

    const/4 v6, 0x0

    invoke-static {v6}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v6

    const/4 v7, 0x1

    aput-object v6, v3, v7

    invoke-virtual {v2, v0, v3}, Ljava/lang/reflect/Method;->invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v3

    check-cast v3, Ljava/lang/Integer;

    sput-object v3, Lcom/samsung/android/graphics/spr/document/debug/SprDebug;->mDebugLevel:Ljava/lang/Integer;
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    :goto_0
    sget-object v3, Lcom/samsung/android/graphics/spr/document/debug/SprDebug;->mDebugLevel:Ljava/lang/Integer;

    invoke-virtual {v3}, Ljava/lang/Integer;->intValue()I

    move-result v3

    if-lt v3, v4, :cond_1

    move v3, v4

    :goto_1
    sput-boolean v3, Lcom/samsung/android/graphics/spr/document/debug/SprDebug;->IsDebug:Z

    return-void

    :catch_0
    move-exception v1

    invoke-virtual {v1}, Ljava/lang/Exception;->printStackTrace()V

    invoke-static {v5}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v3

    sput-object v3, Lcom/samsung/android/graphics/spr/document/debug/SprDebug;->mDebugLevel:Ljava/lang/Integer;

    goto :goto_0

    :cond_0
    invoke-static {v5}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v3

    sput-object v3, Lcom/samsung/android/graphics/spr/document/debug/SprDebug;->mDebugLevel:Ljava/lang/Integer;

    goto :goto_0

    :cond_1
    move v3, v5

    goto :goto_1
.end method

.method public constructor <init>()V
    .locals 0

    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method

.method public static drawDebugInfo(Landroid/graphics/Canvas;Lcom/samsung/android/graphics/spr/document/SprDocument;III)V
    .locals 2

    sget-object v0, Lcom/samsung/android/graphics/spr/document/debug/SprDebug;->mDebugLevel:Ljava/lang/Integer;

    invoke-virtual {v0}, Ljava/lang/Integer;->intValue()I

    move-result v0

    const/4 v1, 0x2

    if-lt v0, v1, :cond_0

    new-instance v1, Ljava/lang/StringBuilder;

    invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

    invoke-virtual {p1}, Lcom/samsung/android/graphics/spr/document/SprDocument;->isNinePatch()Z

    move-result v0

    if-eqz v0, :cond_1

    const-string/jumbo v0, "N"

    :goto_0
    invoke-virtual {v1, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {p1}, Lcom/samsung/android/graphics/spr/document/SprDocument;->hashCode()I

    move-result v1

    rem-int/lit16 v1, v1, 0x2710

    invoke-static {v1}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    const/16 v1, 0x14

    invoke-static {p0, v0, v1}, Lcom/samsung/android/graphics/spr/document/debug/SprDebug;->drawText(Landroid/graphics/Canvas;Ljava/lang/String;I)V

    iget-object v0, p1, Lcom/samsung/android/graphics/spr/document/SprDocument;->mName:Ljava/lang/String;

    const/16 v1, 0x28

    invoke-static {p0, v0, v1}, Lcom/samsung/android/graphics/spr/document/debug/SprDebug;->drawText(Landroid/graphics/Canvas;Ljava/lang/String;I)V

    new-instance v0, Ljava/lang/StringBuilder;

    invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V

    invoke-virtual {v0, p4}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v0

    const-string/jumbo v1, ")"

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {v0, p2}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v0

    const-string/jumbo v1, "x"

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {v0, p3}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    const/16 v1, 0x3c

    invoke-static {p0, v0, v1}, Lcom/samsung/android/graphics/spr/document/debug/SprDebug;->drawText(Landroid/graphics/Canvas;Ljava/lang/String;I)V

    sget-object v0, Lcom/samsung/android/graphics/spr/document/debug/SprDebug;->mDebugLevel:Ljava/lang/Integer;

    invoke-virtual {v0}, Ljava/lang/Integer;->intValue()I

    move-result v0

    const/4 v1, 0x3

    if-lt v0, v1, :cond_0

    new-instance v0, Ljava/lang/StringBuilder;

    invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V

    invoke-virtual {p1}, Lcom/samsung/android/graphics/spr/document/SprDocument;->getLoadingTime()I

    move-result v1

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v0

    const-string/jumbo v1, "ms E:"

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {p1}, Lcom/samsung/android/graphics/spr/document/SprDocument;->getTotalElementCount()I

    move-result v1

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v0

    const-string/jumbo v1, " S:"

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {p1}, Lcom/samsung/android/graphics/spr/document/SprDocument;->getTotalSegmentCount()I

    move-result v1

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v0

    const-string/jumbo v1, " A:"

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {p1}, Lcom/samsung/android/graphics/spr/document/SprDocument;->getTotalAttributeCount()I

    move-result v1

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    const/16 v1, 0x50

    invoke-static {p0, v0, v1}, Lcom/samsung/android/graphics/spr/document/debug/SprDebug;->drawText(Landroid/graphics/Canvas;Ljava/lang/String;I)V

    :cond_0
    return-void

    :cond_1
    invoke-virtual {p1}, Lcom/samsung/android/graphics/spr/document/SprDocument;->isIntrinsic()Z

    move-result v0

    if-eqz v0, :cond_2

    const-string/jumbo v0, ""

    goto/16 :goto_0

    :cond_2
    const-string/jumbo v0, "C"

    goto/16 :goto_0
.end method

.method public static drawRect(Landroid/graphics/Canvas;Lcom/samsung/android/graphics/spr/document/SprDocument;II)V
    .locals 6

    new-instance v5, Landroid/graphics/Paint;

    invoke-direct {v5}, Landroid/graphics/Paint;-><init>()V

    const/4 v0, 0x1

    invoke-virtual {v5, v0}, Landroid/graphics/Paint;->setAntiAlias(Z)V

    sget-object v0, Landroid/graphics/Paint$Style;->STROKE:Landroid/graphics/Paint$Style;

    invoke-virtual {v5, v0}, Landroid/graphics/Paint;->setStyle(Landroid/graphics/Paint$Style;)V

    const/high16 v0, 0x40a00000    # 5.0f

    invoke-virtual {v5, v0}, Landroid/graphics/Paint;->setStrokeWidth(F)V

    const/high16 v0, -0x10000

    invoke-virtual {v5, v0}, Landroid/graphics/Paint;->setColor(I)V

    iget v1, p1, Lcom/samsung/android/graphics/spr/document/SprDocument;->mLeft:F

    iget v2, p1, Lcom/samsung/android/graphics/spr/document/SprDocument;->mTop:F

    iget v0, p1, Lcom/samsung/android/graphics/spr/document/SprDocument;->mLeft:F

    int-to-float v3, p2

    add-float/2addr v3, v0

    iget v0, p1, Lcom/samsung/android/graphics/spr/document/SprDocument;->mTop:F

    int-to-float v4, p3

    add-float/2addr v4, v0

    move-object v0, p0

    invoke-virtual/range {v0 .. v5}, Landroid/graphics/Canvas;->drawRect(FFFFLandroid/graphics/Paint;)V

    return-void
.end method

.method private static drawText(Landroid/graphics/Canvas;Ljava/lang/String;I)V
    .locals 5

    const/4 v4, 0x1

    const/high16 v3, 0x41a00000    # 20.0f

    const/high16 v2, 0x40a00000    # 5.0f

    sget-object v0, Lcom/samsung/android/graphics/spr/document/debug/SprDebug;->mTextOutlinePaint:Landroid/graphics/Paint;

    if-nez v0, :cond_0

    new-instance v0, Landroid/graphics/Paint;

    invoke-direct {v0}, Landroid/graphics/Paint;-><init>()V

    sput-object v0, Lcom/samsung/android/graphics/spr/document/debug/SprDebug;->mTextOutlinePaint:Landroid/graphics/Paint;

    sget-object v0, Lcom/samsung/android/graphics/spr/document/debug/SprDebug;->mTextOutlinePaint:Landroid/graphics/Paint;

    invoke-virtual {v0, v4}, Landroid/graphics/Paint;->setAntiAlias(Z)V

    sget-object v0, Lcom/samsung/android/graphics/spr/document/debug/SprDebug;->mTextOutlinePaint:Landroid/graphics/Paint;

    invoke-virtual {v0, v3}, Landroid/graphics/Paint;->setTextSize(F)V

    sget-object v0, Lcom/samsung/android/graphics/spr/document/debug/SprDebug;->mTextOutlinePaint:Landroid/graphics/Paint;

    sget-object v1, Landroid/graphics/Paint$Style;->STROKE:Landroid/graphics/Paint$Style;

    invoke-virtual {v0, v1}, Landroid/graphics/Paint;->setStyle(Landroid/graphics/Paint$Style;)V

    sget-object v0, Lcom/samsung/android/graphics/spr/document/debug/SprDebug;->mTextOutlinePaint:Landroid/graphics/Paint;

    const/high16 v1, -0x1000000

    invoke-virtual {v0, v1}, Landroid/graphics/Paint;->setColor(I)V

    sget-object v0, Lcom/samsung/android/graphics/spr/document/debug/SprDebug;->mTextOutlinePaint:Landroid/graphics/Paint;

    const/high16 v1, 0x40800000    # 4.0f

    invoke-virtual {v0, v1}, Landroid/graphics/Paint;->setStrokeWidth(F)V

    :cond_0
    sget-object v0, Lcom/samsung/android/graphics/spr/document/debug/SprDebug;->mTextPaint:Landroid/graphics/Paint;

    if-nez v0, :cond_1

    new-instance v0, Landroid/graphics/Paint;

    invoke-direct {v0}, Landroid/graphics/Paint;-><init>()V

    sput-object v0, Lcom/samsung/android/graphics/spr/document/debug/SprDebug;->mTextPaint:Landroid/graphics/Paint;

    sget-object v0, Lcom/samsung/android/graphics/spr/document/debug/SprDebug;->mTextPaint:Landroid/graphics/Paint;

    invoke-virtual {v0, v4}, Landroid/graphics/Paint;->setAntiAlias(Z)V

    sget-object v0, Lcom/samsung/android/graphics/spr/document/debug/SprDebug;->mTextPaint:Landroid/graphics/Paint;

    invoke-virtual {v0, v3}, Landroid/graphics/Paint;->setTextSize(F)V

    sget-object v0, Lcom/samsung/android/graphics/spr/document/debug/SprDebug;->mTextPaint:Landroid/graphics/Paint;

    sget-object v1, Landroid/graphics/Paint$Style;->FILL:Landroid/graphics/Paint$Style;

    invoke-virtual {v0, v1}, Landroid/graphics/Paint;->setStyle(Landroid/graphics/Paint$Style;)V

    sget-object v0, Lcom/samsung/android/graphics/spr/document/debug/SprDebug;->mTextPaint:Landroid/graphics/Paint;

    const/4 v1, -0x1

    invoke-virtual {v0, v1}, Landroid/graphics/Paint;->setColor(I)V

    :cond_1
    int-to-float v0, p2

    sget-object v1, Lcom/samsung/android/graphics/spr/document/debug/SprDebug;->mTextOutlinePaint:Landroid/graphics/Paint;

    invoke-virtual {p0, p1, v2, v0, v1}, Landroid/graphics/Canvas;->drawText(Ljava/lang/String;FFLandroid/graphics/Paint;)V

    int-to-float v0, p2

    sget-object v1, Lcom/samsung/android/graphics/spr/document/debug/SprDebug;->mTextPaint:Landroid/graphics/Paint;

    invoke-virtual {p0, p1, v2, v0, v1}, Landroid/graphics/Canvas;->drawText(Ljava/lang/String;FFLandroid/graphics/Paint;)V

    return-void
.end method

.method public static preDraw(Lcom/samsung/android/graphics/spr/document/shape/SprObjectBase;)V
    .locals 4

    const/16 v3, 0xff

    const/high16 v2, 0x40000000    # 2.0f

    sget-object v0, Lcom/samsung/android/graphics/spr/document/debug/SprDebug;->mDebugLevel:Ljava/lang/Integer;

    invoke-virtual {v0}, Ljava/lang/Integer;->intValue()I

    move-result v0

    const/4 v1, 0x3

    if-lt v0, v1, :cond_0

    iget-object v0, p0, Lcom/samsung/android/graphics/spr/document/shape/SprObjectBase;->strokePaint:Landroid/graphics/Paint;

    if-eqz v0, :cond_0

    const/4 v0, 0x1

    iput-boolean v0, p0, Lcom/samsung/android/graphics/spr/document/shape/SprObjectBase;->isVisibleStroke:Z

    iget-object v0, p0, Lcom/samsung/android/graphics/spr/document/shape/SprObjectBase;->strokePaint:Landroid/graphics/Paint;

    const/4 v1, 0x0

    invoke-static {v3, v1, v3}, Landroid/graphics/Color;->rgb(III)I

    move-result v1

    invoke-virtual {v0, v1}, Landroid/graphics/Paint;->setColor(I)V

    iget-object v0, p0, Lcom/samsung/android/graphics/spr/document/shape/SprObjectBase;->strokePaint:Landroid/graphics/Paint;

    invoke-virtual {v0}, Landroid/graphics/Paint;->getStrokeWidth()F

    move-result v0

    cmpg-float v0, v0, v2

    if-gez v0, :cond_0

    iget-object v0, p0, Lcom/samsung/android/graphics/spr/document/shape/SprObjectBase;->strokePaint:Landroid/graphics/Paint;

    invoke-virtual {v0, v2}, Landroid/graphics/Paint;->setStrokeWidth(F)V

    :cond_0
    return-void
.end method

# virtual methods
.method public dumpPNG(Lcom/samsung/android/graphics/spr/document/SprDocument;III)V
    .locals 11

    sget-object v0, Landroid/graphics/Bitmap$Config;->ARGB_8888:Landroid/graphics/Bitmap$Config;

    invoke-static {p2, p3, v0}, Landroid/graphics/Bitmap;->createBitmap(IILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;

    move-result-object v6

    new-instance v1, Landroid/graphics/Canvas;

    invoke-direct {v1, v6}, Landroid/graphics/Canvas;-><init>(Landroid/graphics/Bitmap;)V

    const/4 v4, 0x0

    move-object v0, p1

    move v2, p2

    move v3, p3

    move v5, p4

    invoke-virtual/range {v0 .. v5}, Lcom/samsung/android/graphics/spr/document/SprDocument;->draw(Landroid/graphics/Canvas;IIII)V

    :try_start_0
    new-instance v7, Ljava/io/File;

    const-string/jumbo v0, "/sdcard/spr_debug"

    invoke-direct {v7, v0}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    invoke-virtual {v7}, Ljava/io/File;->mkdir()Z

    move-result v0

    if-nez v0, :cond_0

    invoke-virtual {v7}, Ljava/io/File;->isDirectory()Z

    move-result v0

    if-eqz v0, :cond_1

    :cond_0
    new-instance v10, Ljava/io/FileOutputStream;

    new-instance v0, Ljava/io/File;

    new-instance v2, Ljava/lang/StringBuilder;

    invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V

    invoke-virtual {p1}, Lcom/samsung/android/graphics/spr/document/SprDocument;->hashCode()I

    move-result v3

    rem-int/lit16 v3, v3, 0x2710

    invoke-static {v3}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;

    move-result-object v3

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    const-string/jumbo v3, ".png"

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-direct {v0, v7, v2}, Ljava/io/File;-><init>(Ljava/io/File;Ljava/lang/String;)V

    invoke-direct {v10, v0}, Ljava/io/FileOutputStream;-><init>(Ljava/io/File;)V

    sget-object v0, Landroid/graphics/Bitmap$CompressFormat;->PNG:Landroid/graphics/Bitmap$CompressFormat;

    const/16 v2, 0x5a

    invoke-virtual {v6, v0, v2, v10}, Landroid/graphics/Bitmap;->compress(Landroid/graphics/Bitmap$CompressFormat;ILjava/io/OutputStream;)Z

    invoke-virtual {v10}, Ljava/io/OutputStream;->close()V
    :try_end_0
    .catch Ljava/io/FileNotFoundException; {:try_start_0 .. :try_end_0} :catch_1
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0

    :cond_1
    :goto_0
    return-void

    :catch_0
    move-exception v9

    invoke-virtual {v9}, Ljava/io/IOException;->printStackTrace()V

    goto :goto_0

    :catch_1
    move-exception v8

    invoke-virtual {v8}, Ljava/io/FileNotFoundException;->printStackTrace()V

    goto :goto_0
.end method


text:
namespace safe_browsing {
namespace dmg {

class ReadStream;
class UDIFBlock;
struct UDIFBlockChunk;

// UDIFParser parses a Universal Disk Image Format file, allowing access to the
// name, types, and data of the partitions held within the file. There is no
// canonical documentation for UDIF, and not all disk images use UDIF (though
// the majority do). Note that this implementation only handles UDIF and SPARSE
// image types, not SPARSEBUNDLE.
//
// No guarantees are made about the position of ReadStream when using an
// instance of this class.
//
// Note that this implementation relies on the UDIF blkx table to provide
// accurate partition information. Otherwise, Apple Partition Map and
// GUID would need to be parsed. See:
//   - http://opensource.apple.com/source/IOStorageFamily/IOStorageFamily-182.1.1/IOApplePartitionScheme.h
//   - http://opensource.apple.com/source/IOStorageFamily/IOStorageFamily-182.1.1/IOGUIDPartitionScheme.h
//
// The following references are useful for understanding the UDIF format:
//   - http://newosxbook.com/DMG.html
//   - http://www.macdisk.com/dmgen.php
class UDIFParser {
 public:
  // Constructs an instance from a stream.
  explicit UDIFParser(ReadStream* stream);
  ~UDIFParser();

  // Parses the UDIF file. This method must be called before any other method.
  // If this returns false, it is not legal to call any other methods.
  bool Parse();

  // Returns the number of partitions in this UDIF image.
  size_t GetNumberOfPartitions();

  // Returns the partition name for a given partition number, in the range of
  // [0,GetNumberOfPartitions()). This will include the number, name, and type
  // of partition. E.g., "disk image (Apple_HFS : 2)".
  std::string GetPartitionName(size_t part_number);

  // Returns the partition type as a string for the given partition number.
  // E.g., "Apple_HFS" and "Apple_Free".
  std::string GetPartitionType(size_t part_number);

  // Returns the size of the partition in bytes.
  size_t GetPartitionSize(size_t part_number);

  // Returns a stream of the raw partition data for the given partition
  // number.
  scoped_ptr<ReadStream> GetPartitionReadStream(size_t part_number);

 private:
  // Parses the blkx plist trailer structure.
  bool ParseBlkx();

  // Reads the data pointed to by the block |chunk|, decompressing it as
  // necessary, into the out-buffer |decompressed_data|.
  bool ReadBlockChunk(const UDIFBlockChunk* chunk,
                      std::vector<uint8_t>* decompressed_data);

  ReadStream* const stream_;  // The stream backing the UDIF image. Weak.
  std::vector<std::string> partition_names_;  // The names of all partitions.
  ScopedVector<const UDIFBlock> blocks_;  // All blocks in the UDIF image.
  uint16_t block_size_;  // The image's block size, in bytes.

  DISALLOW_COPY_AND_ASSIGN(UDIFParser);
};

}  // namespace dmg
}  // namespace safe_browsing

#endif  // CHROME_UTILITY_SAFE_BROWSING_MAC_UDIF_H_

redpajama_set_name: RedPajamaGithub


text:
<html>
<head>
<meta http-equiv="refresh" content="0; url=https://developers.liveperson.com/consumer-experience-ios-sdk-printalllocalizedkeys.html" />
</head>
</html>


text:
<?php
namespace Deployable\Http\Output;

use Deployable\Http\Output;
use Deployable\Traits\View;

class Web extends Output
{
    use View;

    /**
     * Display the output
     * @return string
     */
    public function __toString()
    {
        return $this->renderView();
    }
}


text:
#pragma once

#include <qrkernel/ids.h>

namespace generatorBase {

class IntermediateStructurizatorNode : public QObject
{
	Q_OBJECT

public:

	enum Type {
		simple
		, block
		, ifThenElseCondition
		, switchCondition
		, infiniteloop
		, whileloop
		, breakNode
		, nodeWithBreaks
	};

	explicit IntermediateStructurizatorNode(QObject *parent);
	virtual ~IntermediateStructurizatorNode();

	virtual Type type() const = 0;
	virtual qReal::Id firstId() const = 0;
	virtual bool analyzeBreak() = 0;
	bool hasBreakInside() const;

protected:
	bool mHasBreakInside;
	bool mBreakWasAnalyzed;
};

}


text:
SCRIPTPATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
export BDM_THISBDM_SILENT=true

# We redirect to /dev/null to ignore the success message when we want to
# extract output in CMake (e.g. in Installation.cmake we want to obtain the
# version number).
source @CMAKE_INSTALL_ROOT@/bin/thisbdm.sh

$@


text:
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using System.Collections;

public class BasicLookInputModule : BaseInputModule {

	public const int kLookId = -3;
	public string submitButtonName = "Fire1";
	public string controlAxisName = "Horizontal";
	private PointerEventData lookData;

	// use screen midpoint as locked pointer location, enabling look location to be the "mouse"
	private PointerEventData GetLookPointerEventData() {
		Vector2 lookPosition = Input.mousePosition;
//		lookPosition.x = Screen.width/2;
//		lookPosition.y = Screen.height/2;
		if (lookData == null) {
			lookData = new PointerEventData(eventSystem);
		}
		lookData.Reset();
		lookData.delta = Vector2.zero;
		lookData.position = lookPosition;
		lookData.scrollDelta = Vector2.zero;
		eventSystem.RaycastAll(lookData, m_RaycastResultCache);
		lookData.pointerCurrentRaycast = FindFirstRaycast(m_RaycastResultCache);
		m_RaycastResultCache.Clear();
		return lookData;
	}

	private bool SendUpdateEventToSelectedObject() {
		if (eventSystem.currentSelectedGameObject == null)
			return false;
		BaseEventData data = GetBaseEventData ();
		ExecuteEvents.Execute (eventSystem.currentSelectedGameObject, data, ExecuteEvents.updateSelectedHandler);
		return data.used;
	}

	public override void Process() {
		// send update events if there is a selected object - this is important for InputField to receive keyboard events
		SendUpdateEventToSelectedObject();
		PointerEventData lookData = GetLookPointerEventData();
		// use built-in enter/exit highlight handler
		HandlePointerExitAndEnter(lookData,lookData.pointerCurrentRaycast.gameObject);
		if (Input.GetButtonDown (submitButtonName)) {
			eventSystem.SetSelectedGameObject(null);
			if (lookData.pointerCurrentRaycast.gameObject != null) {
				GameObject go = lookData.pointerCurrentRaycast.gameObject;
				GameObject newPressed = ExecuteEvents.ExecuteHierarchy (go, lookData, ExecuteEvents.submitHandler);
				if (newPressed == null) {
					// submit handler not found, try select handler instead
					newPressed = ExecuteEvents.ExecuteHierarchy (go, lookData, ExecuteEvents.selectHandler);
				}
				if (newPressed != null) {
					eventSystem.SetSelectedGameObject(newPressed);
				}
			}
		}
		if (eventSystem.currentSelectedGameObject && controlAxisName != null && controlAxisName != "") {
			float newVal = Input.GetAxis (controlAxisName);
			if (newVal > 0.01f || newVal < -0.01f) {
				AxisEventData axisData = GetAxisEventData(newVal,0.0f,0.0f);
				ExecuteEvents.Execute(eventSystem.currentSelectedGameObject, axisData, ExecuteEvents.moveHandler);
			}
		}
	}
}


text:
<?php

	/**
	 * PS font support class
	 *
	 * @package WideImage
	 */
	class WideImage_Font_PS
	{
		public $size;
		public $color;
		public $handle;

		function __construct($file, $size, $color, $bgcolor = null)
		{
			$this->handle = imagepsloadfont($file);
			$this->size = $size;
			$this->color = $color;
			if ($bgcolor === null)
				$this->bgcolor = $color;
			else
				$this->color = $color;
		}

		function writeText($image, $x, $y, $text, $angle = 0)
		{
			if ($image->isTrueColor())
				$image->alphaBlending(true);

			imagepstext($image->getHandle(), $text, $this->handle, $this->size, $this->color, $this->bgcolor, $x, $y, 0, 0, $angle, 4);
		}

		function __destruct()
		{
			imagepsfreefont($this->handle);
			$this->handle = null;
		}
	}


text:
"""Tests for core.storage.user.gae_models."""

import datetime

from core.platform import models
from core.tests import test_utils
import feconf

(user_models,) = models.Registry.import_models([models.NAMES.user])

class UserSettingsModelTest(test_utils.GenericTestBase):
    """Tests for UserSettingsModel class."""
    user_id = 'user_id'
    user_email = 'user@example.com'
    user_role = feconf.ROLE_ID_ADMIN
    user2_email = 'user2@example.com'
    user2_role = feconf.ROLE_ID_BANNED_USER
    user3_email = 'user3@example.com'
    user3_role = feconf.ROLE_ID_ADMIN
    user3_id = 'user3_id'
    generic_username = 'user'
    generic_date = datetime.datetime(2019, 5, 20)
    generic_image_url = 'www.example.com/example.png'
    generic_user_bio = 'I am a user of Oppia!'
    generic_subject_interests = ['Math', 'Science']
    generic_language_codes = ['en', 'es']

    def setUp(self):
        super(UserSettingsModelTest, self).setUp()
        user_models.UserSettingsModel(
            id=self.user_id, email=self.user_email, role=self.user_role).put()
        user_models.UserSettingsModel(
            email=self.user2_email, role=self.user2_role).put()
        user_models.UserSettingsModel(
            email=self.user3_email, role=self.user3_role).put()
        user_models.UserSettingsModel(
            id=self.user3_id,
            email=self.user3_email,
            role=self.user3_role,
            username=self.generic_username,
            normalized_username=self.generic_username,
            last_agreed_to_terms=self.generic_date,
            last_started_state_editor_tutorial=self.generic_date,
            last_started_state_translation_tutorial=self.generic_date,
            last_logged_in=self.generic_date,
            last_created_an_exploration=self.generic_date,
            last_edited_an_exploration=self.generic_date,
            profile_picture_data_url=self.generic_image_url,
            default_dashboard='learner', creator_dashboard_display_pref='card',
            user_bio=self.generic_user_bio,
            subject_interests=self.generic_subject_interests,
            first_contribution_msec=1,
            preferred_language_codes=self.generic_language_codes,
            preferred_site_language_code=(self.generic_language_codes[0]),
            preferred_audio_language_code=(self.generic_language_codes[0])
        ).put()

    def test_get_by_role(self):
        user = user_models.UserSettingsModel.get_by_role(
            feconf.ROLE_ID_ADMIN)
        self.assertEqual(user[0].role, feconf.ROLE_ID_ADMIN)

    def test_export_data_trivial(self):
        user = user_models.UserSettingsModel.get_by_id(self.user_id)
        user_data = user.export_data(user.id)
        expected_user_data = {
            'email': 'user@example.com',
            'role': feconf.ROLE_ID_ADMIN,
            'username': None,
            'normalized_username': None,
            'last_agreed_to_terms': None,
            'last_started_state_editor_tutorial': None,
            'last_started_state_translation_tutorial': None,
            'last_logged_in': None,
            'last_edited_an_exploration': None,
            'profile_picture_data_url': None,
            'default_dashboard': 'learner',
            'creator_dashboard_display_pref': 'card',
            'user_bio': None,
            'subject_interests': [],
            'first_contribution_msec': None,
            'preferred_language_codes': [],
            'preferred_site_language_code': None,
            'preferred_audio_language_code': None
        }
        self.assertEqual(expected_user_data, user_data)

    def test_export_data_nontrivial(self):
        user = user_models.UserSettingsModel.get_by_id(self.user3_id)
        user_data = user.export_data(user.id)
        expected_user_data = {
            'email': self.user3_email,
            'role': feconf.ROLE_ID_ADMIN,
            'username': self.generic_username,
            'normalized_username': self.generic_username,
            'last_agreed_to_terms': self.generic_date,
            'last_started_state_editor_tutorial': self.generic_date,
            'last_started_state_translation_tutorial': self.generic_date,
            'last_logged_in': self.generic_date,
            'last_edited_an_exploration': self.generic_date,
            'profile_picture_data_url': self.generic_image_url,
            'default_dashboard': 'learner',
            'creator_dashboard_display_pref': 'card',
            'user_bio': self.generic_user_bio,
            'subject_interests': self.generic_subject_interests,
            'first_contribution_msec': 1,
            'preferred_language_codes': self.generic_language_codes,
            'preferred_site_language_code': self.generic_language_codes[0],
            'preferred_audio_language_code': self.generic_language_codes[0]
        }
        self.assertEqual(expected_user_data, user_data)

class StoryProgressModelTests(test_utils.GenericTestBase):

    def test_get_multi(self):
        model = user_models.StoryProgressModel.create(
            'user_id', 'story_id_1')
        model.put()

        model = user_models.StoryProgressModel.create(
            'user_id', 'story_id_2')
        model.put()

        story_progress_models = user_models.StoryProgressModel.get_multi(
            'user_id', ['story_id_1', 'story_id_2'])
        self.assertEqual(len(story_progress_models), 2)
        self.assertEqual(story_progress_models[0].user_id, 'user_id')
        self.assertEqual(story_progress_models[0].story_id, 'story_id_1')

        self.assertEqual(story_progress_models[1].user_id, 'user_id')
        self.assertEqual(story_progress_models[1].story_id, 'story_id_2')

class ExpUserLastPlaythroughModelTest(test_utils.GenericTestBase):
    """Tests for ExpUserLastPlaythroughModel class."""

    USER_ID = 'user_id'
    EXP_ID_0 = 'exp_id_0'
    EXP_ID_1 = 'exp_id_1'

    def setUp(self):
        super(ExpUserLastPlaythroughModelTest, self).setUp()
        user_models.ExpUserLastPlaythroughModel(
            id='%s.%s' % (self.USER_ID, self.EXP_ID_0), user_id=self.USER_ID,
            exploration_id=self.EXP_ID_0, last_played_exp_version=1,
            last_played_state_name='state_name').put()

    def test_create_success(self):
        user_models.ExpUserLastPlaythroughModel.create(
            self.USER_ID, self.EXP_ID_1).put()
        retrieved_object = user_models.ExpUserLastPlaythroughModel.get_by_id(
            '%s.%s' % (self.USER_ID, self.EXP_ID_1))

        self.assertEqual(retrieved_object.user_id, self.USER_ID)
        self.assertEqual(retrieved_object.exploration_id, self.EXP_ID_1)

    def test_get_success(self):
        retrieved_object = user_models.ExpUserLastPlaythroughModel.get(
            self.USER_ID, self.EXP_ID_0)

        self.assertEqual(retrieved_object.user_id, self.USER_ID)
        self.assertEqual(retrieved_object.exploration_id, self.EXP_ID_0)
        self.assertEqual(retrieved_object.last_played_exp_version, 1)
        self.assertEqual(retrieved_object.last_played_state_name, 'state_name')

    def test_get_failure(self):
        retrieved_object = user_models.ExpUserLastPlaythroughModel.get(
            self.USER_ID, 'unknown_exp_id')

        self.assertEqual(retrieved_object, None)

class UserStatsModelTest(test_utils.GenericTestBase):
    """Tests for the UserStatsModel class."""

    USER_ID_1 = 1
    USER_ID_2 = 2
    USER_ID_3 = 3

    USER_1_IMPACT_SCORE = 0.87
    USER_1_TOTAL_PLAYS = 33
    USER_1_AVERAGE_RATINGS = 4.37
    USER_1_NUM_RATINGS = 22
    USER_1_WEEKLY_CREATOR_STATS_LIST = [
        {
            ('2019-05-21'): {
                'average_ratings': 4.00,
                'total_plays': 5
            }
        },
        {
            ('2019-05-28'): {
                'average_ratings': 4.95,
                'total_plays': 10
            }
        }
    ]

    USER_2_IMPACT_SCORE = 0.33
    USER_2_TOTAL_PLAYS = 15
    USER_2_AVERAGE_RATINGS = 2.50
    USER_2_NUM_RATINGS = 10
    USER_2_WEEKLY_CREATOR_STATS_LIST = [
        {
            ('2019-05-21'): {
                'average_ratings': 2.50,
                'total_plays': 4
            }
        },
        {
            ('2019-05-28'): {
                'average_ratings': 2.50,
                'total_plays': 6
            }
        }
    ]

    def setUp(self):
        """Set up user models in datastore for use in testing."""
        super(UserStatsModelTest, self).setUp()

        user_model_1 = user_models.UserStatsModel(id=self.USER_ID_1)
        user_model_1.impact_score = self.USER_1_IMPACT_SCORE
        user_model_1.total_plays = self.USER_1_TOTAL_PLAYS
        user_model_1.average_ratings = self.USER_1_AVERAGE_RATINGS
        user_model_1.num_ratings = self.USER_1_NUM_RATINGS
        user_model_1.weekly_creator_stats_list = (
            self.USER_1_WEEKLY_CREATOR_STATS_LIST)
        user_models.UserStatsModel.put(user_model_1)

        user_model_2 = user_models.UserStatsModel(id=self.USER_ID_2)
        user_model_2.impact_score = self.USER_2_IMPACT_SCORE
        user_model_2.total_plays = self.USER_2_TOTAL_PLAYS
        user_model_2.average_ratings = self.USER_2_AVERAGE_RATINGS
        user_model_2.num_ratings = self.USER_2_NUM_RATINGS
        user_model_2.weekly_creator_stats_list = (
            self.USER_2_WEEKLY_CREATOR_STATS_LIST)
        user_models.UserStatsModel.put(user_model_2)

    def test_export_data_on_existing_user(self):
        """Test if export_data works when user is in data store."""
        user_data = user_models.UserStatsModel.export_data(self.USER_ID_1)
        test_data = {
            'impact_score': self.USER_1_IMPACT_SCORE,
            'total_plays': self.USER_1_TOTAL_PLAYS,
            'average_ratings': self.USER_1_AVERAGE_RATINGS,
            'num_ratings': self.USER_1_NUM_RATINGS,
            'weekly_creator_stats_list': self.USER_1_WEEKLY_CREATOR_STATS_LIST
        }
        self.assertEqual(user_data, test_data)

    def test_export_data_on_multiple_users(self):
        """Test if export_data works on multiple users in data store."""
        user_1_data = user_models.UserStatsModel.export_data(self.USER_ID_1)
        test_1_data = {
            'impact_score': self.USER_1_IMPACT_SCORE,
            'total_plays': self.USER_1_TOTAL_PLAYS,
            'average_ratings': self.USER_1_AVERAGE_RATINGS,
            'num_ratings': self.USER_1_NUM_RATINGS,
            'weekly_creator_stats_list': self.USER_1_WEEKLY_CREATOR_STATS_LIST
        }

        user_2_data = user_models.UserStatsModel.export_data(self.USER_ID_2)
        test_2_data = {
            'impact_score': self.USER_2_IMPACT_SCORE,
            'total_plays': self.USER_2_TOTAL_PLAYS,
            'average_ratings': self.USER_2_AVERAGE_RATINGS,
            'num_ratings': self.USER_2_NUM_RATINGS,
            'weekly_creator_stats_list': self.USER_2_WEEKLY_CREATOR_STATS_LIST
        }

        self.assertEqual(user_1_data, test_1_data)
        self.assertEqual(user_2_data, test_2_data)

    def test_export_data_on_nonexistent_user(self):
        """Test if export_data returns None when user is not in data store."""
        user_data = user_models.UserStatsModel.export_data(self.USER_ID_3)
        test_data = None
        self.assertEqual(user_data, test_data)

class ExplorationUserDataModelTest(test_utils.GenericTestBase):
    """Tests for the ExplorationUserDataModel class."""

    DATETIME_OBJECT = datetime.datetime.strptime('2016-02-16', '%Y-%m-%d')
    USER_ID = 'user_id'
    EXP_ID_ONE = 'exp_id_one'
    EXP_ID_TWO = 'exp_id_two'

    def setUp(self):
        super(ExplorationUserDataModelTest, self).setUp()
        user_models.ExplorationUserDataModel(
            id='%s.%s' % (self.USER_ID, self.EXP_ID_ONE), user_id=self.USER_ID,
            exploration_id=self.EXP_ID_ONE, rating=2,
            rated_on=self.DATETIME_OBJECT,
            draft_change_list={'new_content': {}},
            draft_change_list_last_updated=self.DATETIME_OBJECT,
            draft_change_list_exp_version=3,
            draft_change_list_id=1).put()

    def test_create_success(self):
        user_models.ExplorationUserDataModel.create(
            self.USER_ID, self.EXP_ID_TWO).put()
        retrieved_object = user_models.ExplorationUserDataModel.get_by_id(
            '%s.%s' % (self.USER_ID, self.EXP_ID_TWO))

        self.assertEqual(retrieved_object.user_id, self.USER_ID)
        self.assertEqual(retrieved_object.exploration_id, self.EXP_ID_TWO)

    def test_get_success(self):
        retrieved_object = user_models.ExplorationUserDataModel.get(
            self.USER_ID, self.EXP_ID_ONE)

        self.assertEqual(retrieved_object.user_id, self.USER_ID)
        self.assertEqual(retrieved_object.exploration_id, self.EXP_ID_ONE)
        self.assertEqual(retrieved_object.rating, 2)
        self.assertEqual(retrieved_object.rated_on, self.DATETIME_OBJECT)
        self.assertEqual(
            retrieved_object.draft_change_list, {'new_content': {}})
        self.assertEqual(
            retrieved_object.draft_change_list_last_updated,
            self.DATETIME_OBJECT)
        self.assertEqual(retrieved_object.draft_change_list_exp_version, 3)
        self.assertEqual(retrieved_object.draft_change_list_id, 1)

    def test_get_failure(self):
        retrieved_object = user_models.ExplorationUserDataModel.get(
            self.USER_ID, 'unknown_exp_id')

        self.assertEqual(retrieved_object, None)

class UserQueryModelTests(test_utils.GenericTestBase):
    """Tests for UserQueryModel."""

    def test_instance_stores_correct_data(self):
        submitter_id = 'submitter'
        query_id = 'qid'
        inactive_in_last_n_days = 5
        created_at_least_n_exps = 1
        created_fewer_than_n_exps = 3
        edited_at_least_n_exps = 2
        edited_fewer_than_n_exps = 5
        has_not_logged_in_for_n_days = 10
        user_models.UserQueryModel(
            id=query_id,
            inactive_in_last_n_days=inactive_in_last_n_days,
            created_at_least_n_exps=created_at_least_n_exps,
            created_fewer_than_n_exps=created_fewer_than_n_exps,
            edited_at_least_n_exps=edited_at_least_n_exps,
            edited_fewer_than_n_exps=edited_fewer_than_n_exps,
            has_not_logged_in_for_n_days=has_not_logged_in_for_n_days,
            submitter_id=submitter_id).put()

        query_model = user_models.UserQueryModel.get(query_id)
        self.assertEqual(query_model.submitter_id, submitter_id)
        self.assertEqual(
            query_model.inactive_in_last_n_days, inactive_in_last_n_days)
        self.assertEqual(
            query_model.has_not_logged_in_for_n_days,
            has_not_logged_in_for_n_days)
        self.assertEqual(
            query_model.created_at_least_n_exps, created_at_least_n_exps)
        self.assertEqual(
            query_model.created_fewer_than_n_exps, created_fewer_than_n_exps)
        self.assertEqual(
            query_model.edited_at_least_n_exps, edited_at_least_n_exps)
        self.assertEqual(
            query_model.edited_fewer_than_n_exps, edited_fewer_than_n_exps)

    def test_fetch_page(self):

        submitter_id = 'submitter_1'
        query_id = 'qid_1'
        inactive_in_last_n_days = 5
        created_at_least_n_exps = 1
        created_fewer_than_n_exps = 3
        edited_at_least_n_exps = 2
        edited_fewer_than_n_exps = 5
        has_not_logged_in_for_n_days = 10
        user_models.UserQueryModel(
            id=query_id,
            inactive_in_last_n_days=inactive_in_last_n_days,
            created_at_least_n_exps=created_at_least_n_exps,
            created_fewer_than_n_exps=created_fewer_than_n_exps,
            edited_at_least_n_exps=edited_at_least_n_exps,
            edited_fewer_than_n_exps=edited_fewer_than_n_exps,
            has_not_logged_in_for_n_days=has_not_logged_in_for_n_days,
            submitter_id=submitter_id).put()

        submitter_id = 'submitter_2'
        query_id = 'qid_2'
        inactive_in_last_n_days = 6
        created_at_least_n_exps = 7
        created_fewer_than_n_exps = 4
        edited_at_least_n_exps = 3
        edited_fewer_than_n_exps = 6
        has_not_logged_in_for_n_days = 11
        user_models.UserQueryModel(
            id=query_id,
            inactive_in_last_n_days=inactive_in_last_n_days,
            created_at_least_n_exps=created_at_least_n_exps,
            created_fewer_than_n_exps=created_fewer_than_n_exps,
            edited_at_least_n_exps=edited_at_least_n_exps,
            edited_fewer_than_n_exps=edited_fewer_than_n_exps,
            has_not_logged_in_for_n_days=has_not_logged_in_for_n_days,
            submitter_id=submitter_id).put()

        # Fetch only one entity.
        query_models, _, _ = user_models.UserQueryModel.fetch_page(
            1, None)
        self.assertEqual(len(query_models), 1)

        self.assertEqual(query_models[0].submitter_id, 'submitter_2')
        self.assertEqual(query_models[0].id, 'qid_2')
        self.assertEqual(query_models[0].inactive_in_last_n_days, 6)
        self.assertEqual(query_models[0].created_at_least_n_exps, 7)
        self.assertEqual(query_models[0].created_fewer_than_n_exps, 4)
        self.assertEqual(query_models[0].edited_at_least_n_exps, 3)
        self.assertEqual(query_models[0].edited_fewer_than_n_exps, 6)
        self.assertEqual(query_models[0].has_not_logged_in_for_n_days, 11)

        # Fetch both entities.
        query_models, _, _ = user_models.UserQueryModel.fetch_page(
            2, None)
        self.assertEqual(len(query_models), 2)

        self.assertEqual(query_models[0].submitter_id, 'submitter_2')
        self.assertEqual(query_models[0].id, 'qid_2')
        self.assertEqual(query_models[0].inactive_in_last_n_days, 6)
        self.assertEqual(query_models[0].created_at_least_n_exps, 7)
        self.assertEqual(query_models[0].created_fewer_than_n_exps, 4)
        self.assertEqual(query_models[0].edited_at_least_n_exps, 3)
        self.assertEqual(query_models[0].edited_fewer_than_n_exps, 6)
        self.assertEqual(query_models[0].has_not_logged_in_for_n_days, 11)

        self.assertEqual(query_models[1].submitter_id, 'submitter_1')
        self.assertEqual(query_models[1].id, 'qid_1')
        self.assertEqual(query_models[1].inactive_in_last_n_days, 5)
        self.assertEqual(query_models[1].created_at_least_n_exps, 1)
        self.assertEqual(query_models[1].created_fewer_than_n_exps, 3)
        self.assertEqual(query_models[1].edited_at_least_n_exps, 2)
        self.assertEqual(query_models[1].edited_fewer_than_n_exps, 5)
        self.assertEqual(query_models[1].has_not_logged_in_for_n_days, 10)

class UserSkillMasteryModelTests(test_utils.GenericTestBase):
    """Tests for UserSkillMasteryModel."""

    USER_ID = 'user_id'
    SKILL_ID_1 = 'skill_id_1'
    SKILL_ID_2 = 'skill_id_2'
    DEGREE_OF_MASTERY = 0.5

    def setUp(self):
        super(UserSkillMasteryModelTests, self).setUp()
        user_models.UserSkillMasteryModel(
            id=user_models.UserSkillMasteryModel.construct_model_id(
                self.USER_ID, self.SKILL_ID_1),
            user_id=self.USER_ID,
            skill_id=self.SKILL_ID_1,
            degree_of_mastery=self.DEGREE_OF_MASTERY).put()

        user_models.UserSkillMasteryModel(
            id=user_models.UserSkillMasteryModel.construct_model_id(
                self.USER_ID, self.SKILL_ID_2),
            user_id=self.USER_ID,
            skill_id=self.SKILL_ID_2,
            degree_of_mastery=self.DEGREE_OF_MASTERY).put()

    def test_construct_model_id(self):
        constructed_model_id = (
            user_models.UserSkillMasteryModel.construct_model_id(
                self.USER_ID, self.SKILL_ID_1))

        self.assertEqual(constructed_model_id, 'user_id.skill_id_1')

    def test_get_success(self):
        constructed_model_id = (
            user_models.UserSkillMasteryModel.construct_model_id(
                self.USER_ID, self.SKILL_ID_1))
        retrieved_object = user_models.UserSkillMasteryModel.get(
            constructed_model_id)

        self.assertEqual(retrieved_object.user_id, 'user_id')
        self.assertEqual(retrieved_object.skill_id, 'skill_id_1')
        self.assertEqual(retrieved_object.degree_of_mastery, 0.5)

    def test_get_failure(self):
        retrieved_object = user_models.UserSkillMasteryModel.get(
            'unknown_model_id', strict=False)

        self.assertEqual(retrieved_object, None)

    def test_get_multi_success(self):
        skill_ids = [
            user_models.UserSkillMasteryModel.construct_model_id(
                self.USER_ID, self.SKILL_ID_1),
            user_models.UserSkillMasteryModel.construct_model_id(
                self.USER_ID, self.SKILL_ID_2)]
        retrieved_object = user_models.UserSkillMasteryModel.get_multi(
            skill_ids)

        self.assertEqual(retrieved_object[0].user_id, 'user_id')
        self.assertEqual(retrieved_object[0].skill_id, 'skill_id_1')
        self.assertEqual(retrieved_object[0].degree_of_mastery, 0.5)
        self.assertEqual(retrieved_object[1].user_id, 'user_id')
        self.assertEqual(retrieved_object[1].skill_id, 'skill_id_2')
        self.assertEqual(retrieved_object[1].degree_of_mastery, 0.5)

    def test_get_multi_failure(self):
        skill_ids = ['unknown_model_id_1', 'unknown_model_id_2']
        retrieved_object = user_models.UserSkillMasteryModel.get_multi(
            skill_ids)

        self.assertEqual(retrieved_object, [None, None])

class UserContributionsScoringModelTests(test_utils.GenericTestBase):
    """Tests for UserContributionScoringModel."""

    def test_create_model(self):
        user_models.UserContributionScoringModel.create('user1', 'category1', 1)
        score_models = (user_models.UserContributionScoringModel
                        .get_all_scores_of_user('user1'))
        self.assertEqual(len(score_models), 1)
        self.assertEqual(score_models[0].id, 'category1.user1')
        self.assertEqual(score_models[0].user_id, 'user1')
        self.assertEqual(score_models[0].score_category, 'category1')
        self.assertEqual(score_models[0].score, 1)

    def test_create_entry_already_exists_failure(self):
        user_models.UserContributionScoringModel.create('user1', 'category1', 1)
        with self.assertRaisesRegexp(
            Exception, 'There is already an entry with the given id:'
                       ' category1.user1'):
            user_models.UserContributionScoringModel.create(
                'user1', 'category1', 2)

    def test_get_all_users_with_score_above_minimum_for_category(self):
        user_models.UserContributionScoringModel.create('user1', 'category1', 1)
        user_models.UserContributionScoringModel.create(
            'user2', 'category1', 21)
        user_models.UserContributionScoringModel.create(
            'user3', 'category1', 11)
        user_models.UserContributionScoringModel.create(
            'user4', 'category1', 11)
        user_models.UserContributionScoringModel.create(
            'user1', 'category2', 11)
        user_models.UserContributionScoringModel.create('user2', 'category2', 1)
        user_models.UserContributionScoringModel.create('user3', 'category2', 1)
        user_models.UserContributionScoringModel.create('user4', 'category2', 1)

        score_models = (user_models.UserContributionScoringModel
                        .get_all_users_with_score_above_minimum_for_category(
                            'category1'))

        self.assertEqual(len(score_models), 3)
        self.assertIn(user_models.UserContributionScoringModel.get_by_id(
            'category1.user2'), score_models)
        self.assertIn(user_models.UserContributionScoringModel.get_by_id(
            'category1.user3'), score_models)
        self.assertIn(user_models.UserContributionScoringModel.get_by_id(
            'category1.user4'), score_models)

        score_models = (user_models.UserContributionScoringModel
                        .get_all_users_with_score_above_minimum_for_category(
                            'category2'))

        self.assertEqual(len(score_models), 1)
        self.assertIn(user_models.UserContributionScoringModel.get_by_id(
            'category2.user1'), score_models)

    def test_get_score_of_user_for_category(self):
        user_models.UserContributionScoringModel.create('user1', 'category1', 1)

        score = (user_models.UserContributionScoringModel
                 .get_score_of_user_for_category('user1', 'category1'))

        self.assertEqual(score, 1)

    def test_increment_score_for_user(self):
        user_models.UserContributionScoringModel.create('user1', 'category1', 1)

        user_models.UserContributionScoringModel.increment_score_for_user(
            'user1', 'category1', 2)

        score = (user_models.UserContributionScoringModel
                 .get_score_of_user_for_category('user1', 'category1'))

        self.assertEqual(score, 3)

    def test_get_all_scores_of_user(self):
        user_models.UserContributionScoringModel.create('user1', 'category1', 1)
        user_models.UserContributionScoringModel.create('user1', 'category2', 1)
        user_models.UserContributionScoringModel.create('user1', 'category3', 1)

        score_models = (user_models.UserContributionScoringModel
                        .get_all_scores_of_user('user1'))
        self.assertEqual(len(score_models), 3)
        self.assertIn(user_models.UserContributionScoringModel.get_by_id(
            'category1.user1'), score_models)
        self.assertIn(user_models.UserContributionScoringModel.get_by_id(
            'category2.user1'), score_models)
        self.assertIn(user_models.UserContributionScoringModel.get_by_id(
            'category3.user1'), score_models)

    def test_get_categories_where_user_can_review(self):
        user_models.UserContributionScoringModel.create(
            'user1', 'category1', 15)
        user_models.UserContributionScoringModel.create('user1', 'category2', 1)
        user_models.UserContributionScoringModel.create(
            'user1', 'category3', 15)
        score_categories = (
            user_models.UserContributionScoringModel
            .get_all_categories_where_user_can_review('user1'))
        self.assertIn('category1', score_categories)
        self.assertIn('category3', score_categories)
        self.assertNotIn('category2', score_categories)

class UserSubscriptionsModelTests(test_utils.GenericTestBase):
    """Tests for UserSubscriptionsModel."""
    USER_ID_1 = 'user_id_1'
    USER_ID_2 = 'user_id_2'
    USER_ID_3 = 'user_id_3'
    CREATOR_IDS = ['4', '8', '16']
    COLLECTION_IDS = ['23', '42', '4']
    ACTIVITY_IDS = ['8', '16', '23']
    GENERAL_FEEDBACK_THREAD_IDS = ['42', '4', '8']

    def setUp(self):
        """Set up user models in datastore for use in testing."""
        super(UserSubscriptionsModelTests, self).setUp()
        user_models.UserSubscriptionsModel(id=self.USER_ID_1).put()

        user_models.UserSubscriptionsModel(
            id=self.USER_ID_2, creator_ids=self.CREATOR_IDS,
            collection_ids=self.COLLECTION_IDS,
            activity_ids=self.ACTIVITY_IDS,
            general_feedback_thread_ids=self.GENERAL_FEEDBACK_THREAD_IDS).put()

    def test_export_data_trivial(self):
        """Test if empty user data is properly exported."""
        user_data = (
            user_models.UserSubscriptionsModel.export_data(self.USER_ID_1))
        test_data = {
            'creator_ids': [],
            'collection_ids': [],
            'activity_ids': [],
            'general_feedback_thread_ids': [],
            'last_checked': None
        }
        self.assertEqual(user_data, test_data)

    def test_export_data_nontrivial(self):
        """Test if nonempty user data is properly exported."""
        user_data = (
            user_models.UserSubscriptionsModel.export_data(self.USER_ID_2))
        test_data = {
            'creator_ids': self.CREATOR_IDS,
            'collection_ids': self.COLLECTION_IDS,
            'activity_ids': self.ACTIVITY_IDS,
            'general_feedback_thread_ids': self.GENERAL_FEEDBACK_THREAD_IDS,
            'last_checked': None
        }
        self.assertEqual(user_data, test_data)

    def test_export_data_on_nonexistent_user(self):
        """Test if exception is raised on nonexistent UserSubscriptionsModel."""
        export_data_exception = (
            self.assertRaisesRegexp(
                Exception, 'UserSubscriptionsModel does not exist.'))
        with export_data_exception:
            user_models.UserSubscriptionsModel.export_data(self.USER_ID_3)


text:
@interface MJMotisObjectWithFormatter : MJTestMotisMappingObject

@end


text:
ACCEPTED

#### According to
International Plant Names Index

#### Published in
null

#### Original name
Cuscuta convallariiflora Pavlov

### Remarks
null


text:
/**
 * Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0
 * Changes may cause incorrect behavior and will be lost if the code is
 * regenerated.
 */

package storage.models;

import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * The StorageAccountCheckNameAvailabilityParameters model.
 */
public class StorageAccountCheckNameAvailabilityParameters {
    /**
     * The name property.
     */
    @JsonProperty(value = "name", required = true)
    private String name;

    /**
     * The type property.
     */
    @JsonProperty(value = "type")
    private String type;

    /**
     * Get the name value.
     *
     * @return the name value
     */
    public String name() {
        return this.name;
    }

    /**
     * Set the name value.
     *
     * @param name the name value to set
     * @return the StorageAccountCheckNameAvailabilityParameters object itself.
     */
    public StorageAccountCheckNameAvailabilityParameters withName(String name) {
        this.name = name;
        return this;
    }

    /**
     * Get the type value.
     *
     * @return the type value
     */
    public String type() {
        return this.type;
    }

    /**
     * Set the type value.
     *
     * @param type the type value to set
     * @return the StorageAccountCheckNameAvailabilityParameters object itself.
     */
    public StorageAccountCheckNameAvailabilityParameters withType(String type) {
        this.type = type;
        return this;
    }

}


text:
from __future__ import absolute_import, print_function, division

from collections import MutableSet
import types
import weakref

from six import string_types

def check_deterministic(iterable):
    # Most places where OrderedSet is used, theano interprets any exception
    # whatsoever as a problem that an optimization introduced into the graph.
    # If I raise a TypeError when the DestoryHandler tries to do something
    # non-deterministic, it will just result in optimizations getting ignored.
    # So I must use an assert here. In the long term we should fix the rest of
    # theano to use exceptions correctly, so that this can be a TypeError.
    if iterable is not None:
        if not isinstance(iterable, (
                list, tuple, OrderedSet,
                types.GeneratorType, string_types)):
            if len(iterable) > 1:
                # We need to accept length 1 size to allow unpickle in tests.
                raise AssertionError(
                    "Get an not ordered iterable when one was expected")

# Copyright (C) 2009 Raymond Hettinger
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to permit
# persons to whom the Software is furnished to do so, subject to the
# following conditions:

# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# {{{ http://code.activestate.com/recipes/576696/ (r5)

class Link(object):
    # This make that we need to use a different pickle protocol
    # then the default.  Othewise, there is pickling errors
    __slots__ = 'prev', 'next', 'key', '__weakref__'

    def __getstate__(self):
        # weakref.proxy don't pickle well, so we use weakref.ref
        # manually and don't pickle the weakref.
        # We restore the weakref when we unpickle.
        ret = [self.prev(), self.next()]
        try:
            ret.append(self.key)
        except AttributeError:
            pass
        return ret

    def __setstate__(self, state):
        self.prev = weakref.ref(state[0])
        self.next = weakref.ref(state[1])
        if len(state) == 3:
            self.key = state[2]

class OrderedSet(MutableSet):
    'Set the remembers the order elements were added'
    # Big-O running times for all methods are the same as for regular sets.
    # The internal self.__map dictionary maps keys to links in a doubly linked list.
    # The circular doubly linked list starts and ends with a sentinel element.
    # The sentinel element never gets deleted (this simplifies the algorithm).
    # The prev/next links are weakref proxies (to prevent circular references).
    # Individual links are kept alive by the hard reference in self.__map.
    # Those hard references disappear when a key is deleted from an OrderedSet.

    # Added by IG-- pre-existing theano code expected sets
    #   to have this method
    def update(self, iterable):
        check_deterministic(iterable)
        self |= iterable

    def __init__(self, iterable=None):
        # Checks added by IG
        check_deterministic(iterable)
        self.__root = root = Link()         # sentinel node for doubly linked list
        root.prev = root.next = weakref.ref(root)
        self.__map = {}                     # key --> link
        if iterable is not None:
            self |= iterable

    def __len__(self):
        return len(self.__map)

    def __contains__(self, key):
        return key in self.__map

    def add(self, key):
        # Store new key in a new link at the end of the linked list
        if key not in self.__map:
            self.__map[key] = link = Link()
            root = self.__root
            last = root.prev
            link.prev, link.next, link.key = last, weakref.ref(root), key
            last().next = root.prev = weakref.ref(link)

    def union(self, s):
        check_deterministic(s)
        n = self.copy()
        for elem in s:
            if elem not in n:
                n.add(elem)
        return n

    def intersection_update(self, s):
        l = []
        for elem in self:
            if elem not in s:
                l.append(elem)
        for elem in l:
            self.remove(elem)
        return self

    def difference_update(self, s):
        check_deterministic(s)
        for elem in s:
            if elem in self:
                self.remove(elem)
        return self

    def copy(self):
        n = OrderedSet()
        n.update(self)
        return n

    def discard(self, key):
        # Remove an existing item using self.__map to find the link which is
        # then removed by updating the links in the predecessor and successors.
        if key in self.__map:
            link = self.__map.pop(key)
            link.prev().next = link.next
            link.next().prev = link.prev

    def __iter__(self):
        # Traverse the linked list in order.
        root = self.__root
        curr = root.next()
        while curr is not root:
            yield curr.key
            curr = curr.next()

    def __reversed__(self):
        # Traverse the linked list in reverse order.
        root = self.__root
        curr = root.prev()
        while curr is not root:
            yield curr.key
            curr = curr.prev()

    def pop(self, last=True):
        if not self:
            raise KeyError('set is empty')
        if last:
            key = next(reversed(self))
        else:
            key = next(iter(self))
        self.discard(key)
        return key

    def __repr__(self):
        if not self:
            return '%s()' % (self.__class__.__name__,)
        return '%s(%r)' % (self.__class__.__name__, list(self))

    def __eq__(self, other):
        # Note that we implement only the comparison to another
        # `OrderedSet`, and not to a regular `set`, because otherwise we
        # could have a non-symmetric equality relation like:
        #       my_ordered_set == my_set and my_set != my_ordered_set
        if isinstance(other, OrderedSet):
            return len(self) == len(other) and list(self) == list(other)
        elif isinstance(other, set):
            # Raise exception to avoid confusion.
            raise TypeError(
                'Cannot compare an `OrderedSet` to a `set` because '
                'this comparison cannot be made symmetric: please '
                'manually cast your `OrderedSet` into `set` before '
                'performing this comparison.')
        else:
            return NotImplemented

# end of http://code.activestate.com/recipes/576696/ }}}

if __name__ == '__main__':
    print(list(OrderedSet('abracadaba')))
    print(list(OrderedSet('simsalabim')))
    print(OrderedSet('boom') == OrderedSet('moob'))
    print(OrderedSet('boom') == 'moob')


text:
layout:     post
title:      cheater
date:       2016-05-09 23:16:10
summary:
categories: drawing
---
![cheater](/images/diary/cheater.png "hate to be dishonest")


text:
set :application, 'applicationname'
set :repository,  'git@github.com:username/project.git'


text:
/*
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
 */
package com.ocs.dynamo.utils;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.List;
import java.util.Map;

import javax.persistence.Entity;
import javax.validation.constraints.Size;

import org.junit.jupiter.api.Test;

import com.ocs.dynamo.domain.TestEntity;
import com.ocs.dynamo.domain.TestEntity2;
import com.ocs.dynamo.domain.model.annotation.Attribute;
import com.ocs.dynamo.exception.OCSRuntimeException;

public class ClassUtilsTest {

    @SuppressWarnings("unused")
    private class NestedTestObject {

        private String name;

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

    }

    @SuppressWarnings("unused")
    private class TestObject {

        private byte[] fieldBytes = new byte[] { 1, 2, 3 };

        @Attribute(description = "desc")
        private Integer fieldOne;

        @Size(max = 123)
        private String fieldTwo;

        private NestedTestObject nested;

        public byte[] getFieldBytes() {
            return fieldBytes;
        }

        public Integer getFieldOne() {
            return fieldOne;
        }

        @Attribute(displayName = "Bert")
        public String getFieldThree() {
            return null;
        }

        public String getFieldTwo() {
            return fieldTwo;
        }

        public NestedTestObject getNested() {
            return nested;
        }

        public void setFieldBytes(byte[] fieldBytes) {
            this.fieldBytes = fieldBytes;
        }

        public void setFieldOne(Integer fieldOne) {
            this.fieldOne = fieldOne;
        }

        public void setFieldTwo(String fieldTwo) {
            this.fieldTwo = fieldTwo;
        }

        public void setNested(NestedTestObject nested) {
            this.nested = nested;
        }

    }

    private class TestObject2 extends TestObject {

    }

    private class TestObject3 {
        private Map<Integer, List<TestObject>> indexedObjects;
        private List<TestObject> objects;

        @SuppressWarnings("unused")
        public Map<Integer, List<TestObject>> getIndexedObjects() {
            return indexedObjects;
        }

        @SuppressWarnings("unused")
        public List<TestObject> getObjects() {
            return objects;
        }
    }

    @Test
    public void testClearFieldValue() {
        TestEntity entity = new TestEntity();
        entity.setSomeBytes(new byte[] { 1, 2, 3, 4 });
        entity.setName("Bob");
        entity.setAge(44L);

        ClassUtils.clearFieldValue(entity, "someBytes", byte[].class);
        assertNull(entity.getSomeBytes());

        ClassUtils.clearFieldValue(entity, "name", String.class);
        assertNull(entity.getName());

        TestEntity2 entity2 = new TestEntity2();
        entity2.setTestEntity(entity);

        ClassUtils.clearFieldValue(entity2, "testEntity.age", Long.class);
        assertNull(entity.getAge());
    }

    @Test
    public void testCanSetProperty() {

        TestEntity2 entity2 = new TestEntity2();

        // non-nested
        assertTrue(ClassUtils.canSetProperty(entity2, "name"));
        assertFalse(ClassUtils.canSetProperty(entity2, "phone"));

        // nested property - cannot be set since the reference to testEntity is
        // empty
        assertFalse(ClassUtils.canSetProperty(entity2, "testEntity.name"));

        // the reference is now non-empty and the property can be set
        entity2.setTestEntity(new TestEntity());
        assertTrue(ClassUtils.canSetProperty(entity2, "testEntity.name"));
        // neste property that does not exist
        assertFalse(ClassUtils.canSetProperty(entity2, "testEntity.phone"));
    }

    @Test
    public void testForClass() {
        Class<?> clazz = ClassUtils.forClass("com.ocs.dynamo.domain.TestEntity");
        assertNotNull(clazz);
    }

    @Test
    public void testForClassBogus() {
        Class<?> clazz = ClassUtils.forClass("com.ocs.dynamo.domain.TestEntityZ");
        assertNull(clazz);
    }

    @Test
    public void testForClassNull() {
        Class<?> clazz = ClassUtils.forClass("");
        assertNull(clazz);
    }

    @Test
    public void testGetAnnotationOnField() {
        Field fieldOne = ClassUtils.getField(TestObject.class, "fieldOne");

        // retrieve an annotation from a field
        Attribute attribute = ClassUtils.getAnnotationOnField(fieldOne, Attribute.class);
        assertNotNull(attribute);
        assertEquals("desc", attribute.description());

        // retrieve the annotation from the class and the field name
        attribute = ClassUtils.getAnnotationOnField(TestObject.class, "fieldOne", Attribute.class);
        assertEquals("desc", attribute.description());

        String desc = ClassUtils.getAnnotationAttributeValue(fieldOne, Attribute.class, "description");
        assertEquals("desc", desc);

        // check for null
        Entity entity = ClassUtils.getAnnotationOnField(fieldOne, Entity.class);
        assertNull(entity);
    }

    /**
     * Test that retrieving an annotation from a getter method also works
     */
    @Test
    public void testGetAnnotationOnMethod() {
        Attribute attribute = ClassUtils.getAnnotationOnMethod(TestObject.class, "fieldThree", Attribute.class);
        assertNotNull(attribute);
        assertEquals("Bert", attribute.displayName());
    }

    @Test
    public void testGetBytes() {
        TestEntity entity = new TestEntity();
        entity.setSomeBytes(new byte[] { 1, 2, 3 });

        byte[] bytes = ClassUtils.getBytes(entity, "someBytes");
        assertNotNull(bytes);
        assertEquals(3, bytes.length);

        ClassUtils.setBytes(new byte[] { 2, 3, 4 }, entity, "someBytes");
        bytes = entity.getSomeBytes();
        assertEquals(2, bytes[0]);
        assertEquals(3, bytes[1]);
        assertEquals(4, bytes[2]);

        ClassUtils.setBytes(null, entity, "someBytes");
        assertNull(entity.getSomeBytes());
    }

    /**
     * Basic test case for retrieving a field from a class
     */
    @Test
    public void testGetField() {

        assertNull(ClassUtils.getField(TestObject.class, "bogus"));

        Field fieldOne = ClassUtils.getField(TestObject.class, "fieldOne");
        assertEquals(Integer.class, fieldOne.getType());

        Field fieldTwo = ClassUtils.getField(TestObject.class, "fieldTwo");
        assertEquals(String.class, fieldTwo.getType());
    }

    /**
     * Verify that getting a field also works for a super class
     */
    @Test
    public void testGetFieldRecursive() {
        Field fieldOne = ClassUtils.getField(TestObject2.class, "fieldOne");
        assertEquals(Integer.class, fieldOne.getType());
    }

    @Test
    public void testGetFieldValue() {
        TestEntity entity = new TestEntity();
        entity.setAge(12L);
        assertEquals(12L, ClassUtils.getFieldValue(entity, "age"));
    }

    @Test
    public void testGetFieldValueAsString() {
        TestEntity entity = new TestEntity();
        entity.setAge(12L);

        assertEquals("12", ClassUtils.getFieldValueAsString(entity, "age"));

        entity.setAge(null);
        assertNull(ClassUtils.getFieldValueAsString(entity, "age"));
    }

    @Test
    public void testGetFieldValueDoesntExists() {
        TestEntity entity = new TestEntity();
        entity.setAge(12L);
        assertThrows(OCSRuntimeException.class, () -> ClassUtils.getFieldValue(entity, "age2"));
    }

    @Test
    public void testGetFieldValueRecursive() {
        TestEntity entity = new TestEntity();
        entity.setAge(12L);

        TestEntity2 entity2 = new TestEntity2();
        entity2.setTestEntity(entity);

        assertEquals(12L, ClassUtils.getFieldValue(entity2, "testEntity.age"));
    }

    @Test
    public void testGetGetterMethod() {

        Method method = ClassUtils.getGetterMethod(TestEntity.class, "age");
        assertNotNull(method);

        // non existing method
        Method method3 = ClassUtils.getGetterMethod(TestEntity.class, "age2");
        assertNull(method3);

    }

    @Test
    public void testGetMaxLength() {
        assertEquals(-1, ClassUtils.getMaxLength(TestObject.class, "fieldOne"));
        assertEquals(123, ClassUtils.getMaxLength(TestObject.class, "fieldTwo"));
    }

    /**
     * Basic test case for retrieving a getter method from a class
     */
    @Test
    public void testGetMethod() {

        assertNull(ClassUtils.getGetterMethod(TestObject.class, "bogus"));

        Method method = ClassUtils.getGetterMethod(TestObject.class, "fieldOne");
        assertEquals(Integer.class, method.getReturnType());

        method = ClassUtils.getGetterMethod(TestObject.class, "fieldTwo");
        assertEquals(String.class, method.getReturnType());
    }

    @Test
    public void testGetResolvedType() {
        Class<?> type = ClassUtils.getResolvedType(TestObject3.class, "objects", 0);
        assertNotNull(type);
        assertEquals(TestObject.class, type);

        type = ClassUtils.getResolvedType(TestObject3.class, "indexedObjects", 0);
        assertNotNull(type);
        assertEquals(Integer.class, type);
        type = ClassUtils.getResolvedType(TestObject3.class, "indexedObjects", 1, 0);
        assertNotNull(type);
        assertEquals(TestObject.class, type);
    }

    @Test
    public void testHasMethod() {
        TestEntity entity = new TestEntity();
        assertTrue(ClassUtils.hasMethod(entity, "getAge"));
        assertTrue(ClassUtils.hasMethod(entity, "getSomeBoolean"));

        // check is case sensitive
        assertFalse(ClassUtils.hasMethod(entity, "getAGe"));
        // must provide the full method name
        assertFalse(ClassUtils.hasMethod(entity, "age"));
    }

    @Test
    public void testSetFieldValue() {
        TestEntity entity = new TestEntity();
        ClassUtils.setFieldValue(entity, "age", 12L);

        assertEquals(12L, entity.getAge().longValue());
    }

    @Test
    public void testSetFieldValueDoenstExist() {
        TestEntity entity = new TestEntity();
        assertThrows(OCSRuntimeException.class, () -> ClassUtils.setFieldValue(entity, "age2", 12L));
    }

    @Test
    public void testSetFieldValueRecursive() {
        TestEntity entity = new TestEntity();
        TestEntity2 entity2 = new TestEntity2();
        entity2.setTestEntity(entity);

        ClassUtils.setFieldValue(entity2, "testEntity.age", 12L);

        assertEquals(12L, entity.getAge().longValue());
    }
}


text:
package io.hekate.core;

import io.hekate.cluster.ClusterNode;
import io.hekate.cluster.ClusterNodeFilter;
import io.hekate.cluster.ClusterService;
import io.hekate.cluster.ClusterServiceFactory;
import io.hekate.cluster.ClusterTopology;
import io.hekate.cluster.ClusterView;
import io.hekate.codec.Codec;
import io.hekate.codec.CodecFactory;
import io.hekate.codec.CodecService;
import io.hekate.codec.JdkCodecFactory;
import io.hekate.coordinate.CoordinationService;
import io.hekate.coordinate.CoordinationServiceFactory;
import io.hekate.core.internal.HekateNodeFactory;
import io.hekate.core.internal.util.ConfigCheck;
import io.hekate.core.jmx.JmxService;
import io.hekate.core.jmx.JmxServiceFactory;
import io.hekate.core.plugin.Plugin;
import io.hekate.core.service.Service;
import io.hekate.core.service.ServiceFactory;
import io.hekate.election.ElectionService;
import io.hekate.election.ElectionServiceFactory;
import io.hekate.lock.LockService;
import io.hekate.lock.LockServiceFactory;
import io.hekate.messaging.MessagingService;
import io.hekate.messaging.MessagingServiceFactory;
import io.hekate.network.NetworkService;
import io.hekate.network.NetworkServiceFactory;
import io.hekate.rpc.RpcService;
import io.hekate.rpc.RpcServiceFactory;
import io.hekate.util.format.ToString;
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Consumer;

import static io.hekate.core.internal.util.StreamUtils.nullSafe;

/**
 * Main configuration and factory for {@link Hekate} instances.
 *
 *

 * This class provides bean-style properties with getters/setters (to be used in the Spring Framework XML files) as well as fluent-style API for programmatic configuration from within the Java code.
 *

 *
 *

 * Configuration options are:
 *

 *

 *
{@link #setNodeName(String) Node name}

 *
{@link #setProperties(Map) Node properties}

 *
{@link #setRoles(List) Node roles}

 *
{@link #setDefaultCodec(CodecFactory) Data serialization codec}

 *
{@link #setPlugins(List) Plugins} that should run within the node

 *

 *     {@link #setServices(List) Services} to be provided by the node:
 *

 *
{@link #withNetwork(Consumer) Network Service}

 *
{@link #withCluster(Consumer) Cluster Service}

 *
{@link #withMessaging(Consumer) Messaging Service}

 *
{@link #withRpc(Consumer) RPC Service}

 *
{@link #withLocks(Consumer) Lock Service}

 *
{@link #withElection(Consumer) Election Service}

 *
{@link #withCoordination(Consumer) Coordination Service}

 *
{@link #withJmx(Consumer) JMX Service}

 *

 *

 *

 *
 *

 * Once configured, the {@link #join()} method must be called in order to construct a new {@link Hekate} instance and join the cluster.
 *

 *
 *

 * For more details about the lifecycle and available services please see the documentation of {@link Hekate} interface.
 *

 */
public class HekateBootstrap {
    /** See {@link #setNodeName(String)}. */
    private String nodeName;

    /** See {@link #setRoles(List)}. */
    private List<String> roles;

    /** See {@link #setProperties(Map)}. */
    private Map<String, String> properties;

    /** See {@link #setPropertyProviders(List)}. */
    private List<PropertyProvider> propertyProviders;

    /** See {@link #setServices(List)}. */
    private List<ServiceFactory<? extends Service>> services;

    /** See {@link #setDefaultCodec(CodecFactory)}. */
    private CodecFactory<Object> defaultCodec = new JdkCodecFactory<>();

    /** See {@link #setPlugins(List)}. */
    private List<Plugin> plugins;

    /** See {@link #setMetrics(MeterRegistry)}. */
    private MeterRegistry metrics;

    /** See {@link #setLifecycleListeners(List)}. */
    private List<Hekate.LifecycleListener> lifecycleListeners;

    /** See {@link #setConfigReport(boolean)}. */
    private boolean configReport;

    /** See {@link #setFatalErrorPolicy(HekateFatalErrorPolicy)}. */
    private HekateFatalErrorPolicy fatalErrorPolicy = HekateFatalErrorPolicy.terminate();

    /**
     * Constructs a new {@link Hekate} instance and asynchronously {@link Hekate#joinAsync() joins} the cluster.
     *
     * @return Future result of this operation.
     *
     * @throws HekateException If configuration is invalid.
     */
    public JoinFuture joinAsync() throws HekateException {
        return create().joinAsync();
    }

    /**
     * Constructs a new {@link Hekate} instance and synchronously {@link Hekate#join() joins} the cluster.
     *
     * @return new {@link Hekate} instance.
     *
     * @throws HekateException If failure occurred while initializing or joining to cluster.
     */
    public Hekate join() throws HekateException {
        return create().join();
    }

    /**
     * Constructs a new {@link Hekate} instance and synchronously {@link Hekate#initialize() initializes} it without joining the cluster.
     *
     *

     * Joining to the cluster can be later performed via {@link Hekate#join()} method.
     *

     *
     * @return new {@link Hekate} instance.
     *
     * @throws HekateException If failure occurred while initializing or joining to cluster.
     */
    public Hekate initialize() throws HekateException {
        return create().initialize();
    }

    /**
     * Returns the node name (see {@link #setNodeName(String)}).
     *
     * @return Node name.
     */
    public String getNodeName() {
        return nodeName;
    }

    /**
     * Sets the node name. Can contain only alpha-numeric characters and non-repeatable dots/hyphens.
     *
     *

     * Node name is optional and its default value is {@code null}.
     *

     *
     * @param nodeName Node name (can contain only alpha-numeric characters and non-repeatable dots/hyphens).
     *
     * @see ClusterNode#name()
     */
    public void setNodeName(String nodeName) {
        this.nodeName = nodeName;
    }

    /**
     * Fluent-style version of {@link #setNodeName(String)}.
     *
     * @param nodeName Node name.
     *
     * @return This instance.
     */
    public HekateBootstrap withNodeName(String nodeName) {
        setNodeName(nodeName);

        return this;
    }

    /**
     * Returns a list of the local node's roles (see {@link #setRoles(List)}).
     *
     * @return List of local node roles.
     */
    public List<String> getRoles() {
        return roles;
    }

    /**
     * Sets node's roles.
     *
     *

     * Roles are string identifiers that can be used for logical grouping of cluster nodes. Roles of each node are visible to all other
     * cluster members via {@link ClusterNode#roles()} and can be used by applications to operate on a sub-set of cluster nodes with
     * specific role(s) (see {@link ClusterView#forRole(String)}).
     *

     *
     * @param roles Set of roles.
     *
     * @see ClusterNode#roles()
     * @see ClusterTopology#filter(ClusterNodeFilter)
     */
    public void setRoles(List<String> roles) {
        this.roles = roles;
    }

    /**
     * Adds the specified {@code role} to the {@link #setRoles(List) roles set}.
     *
     * @param role Role.
     *
     * @return This instance.
     */
    public HekateBootstrap withRole(String role) {
        ConfigCheck.get(getClass()).notNull(role, "role");

        if (roles == null) {
            roles = new ArrayList<>();
        }

        roles.add(role);

        return this;
    }

    /**
     * Returns a map of local node properties (see {@link #setProperties(Map)}).
     *
     * @return Map of local node properties.
     */
    public Map<String, String> getProperties() {
        return properties;
    }

    /**
     * Sets node's properties.
     *
     *

     * Properties of each node are visible to all other cluster members via {@link ClusterNode#properties()}.
     *

     *
     * @param properties Map of local node properties.
     *
     * @see ClusterNode#properties()
     * @see #setPropertyProviders(List)
     */
    public void setProperties(Map<String, String> properties) {
        this.properties = properties;
    }

    /**
     * Puts the specified property value into the node's {@link #setProperties(Map) properties map}.
     *
     * @param key Property key.
     * @param value Property value.
     *
     * @return This instance.
     */
    public HekateBootstrap withProperty(String key, String value) {
        if (properties == null) {
            properties = new HashMap<>();
        }

        properties.put(key, value);

        return this;
    }

    /**
     * Returns a list of node property providers (see {@link #setPropertyProviders(List)}).
     *
     * @return Node property providers.
     */
    public List<PropertyProvider> getPropertyProviders() {
        return propertyProviders;
    }

    /**
     * Sets the list of node property providers.
     *
     *

     * Such providers can be used to provide properties that were dynamically obtained from some third party sources and should become part
     * of {@link #setProperties(Map) node properties}.
     *

     *
     * @param propertyProviders Node property providers.
     *
     * @see #setProperties(Map)
     */
    public void setPropertyProviders(List<PropertyProvider> propertyProviders) {
        this.propertyProviders = propertyProviders;
    }

    /**
     * Fluent-style version of {@link #setPropertyProviders(List)}.
     *
     * @param propertyProvider Property provider.
     *
     * @return This instance.
     */
    public HekateBootstrap withPropertyProvider(PropertyProvider propertyProvider) {
        if (propertyProviders == null) {
            propertyProviders = new ArrayList<>();
        }

        propertyProviders.add(propertyProvider);

        return this;
    }

    /**
     * Returns services of the local node (see {@link #setServices(List)}).
     *
     * @return List of service factories.
     */
    public List<ServiceFactory<? extends Service>> getServices() {
        return services;
    }

    /**
     * Sets the list of services that should be provided by the local node.
     *
     * @param services Service factories.
     *
     * @see Service
     * @see ServiceFactory
     */
    public void setServices(List<ServiceFactory<? extends Service>> services) {
        this.services = services;
    }

    /**
     * Adds the specified factory to the list of {@link #setServices(List) service factories}.
     *
     * @param service Service factory.
     *
     * @return This instance.
     */
    public HekateBootstrap withService(ServiceFactory<? extends Service> service) {
        if (services == null) {
            services = new ArrayList<>();
        }

        services.add(service);

        return this;
    }

    /**
     * Applies the specified {@code configurer} to a service factory of the specified type. If factory is not registered yet then it will be
     * automatically registered via {@link #withService(Class)}.
     *
     * @param factoryType Service factory type.
     * @param configurer Service factory configurer.
     * @param <T> Service factory type.
     *
     * @return This instance.
     */
    public <T extends ServiceFactory<?>> HekateBootstrap withService(Class<T> factoryType, Consumer<T> configurer) {
        T factory = withService(factoryType);

        configurer.accept(factory);

        return this;
    }

    /**
     * Returns an existing service factory of the specified type or creates and registers a new one.
     *
     *

     * Note that the specified type must have a public no-arg constructor.
     *

     *
     * @param factoryType Service factory type.
     * @param <T> Service factory type.
     *
     * @return Service factory instance.
     */
    public <T extends ServiceFactory<?>> T withService(Class<T> factoryType) {
        Optional<T> mayBeFactory = service(factoryType);

        if (mayBeFactory.isPresent()) {
            return mayBeFactory.get();
        } else {
            T factory;

            try {
                factory = factoryType.getConstructor().newInstance();
            } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
                throw new HekateConfigurationException("Failed to instantiate service factory [type=" + factoryType + ']', e);
            }

            withService(factory);

            return factory;
        }
    }

    /**
     * Configures {@link JmxService}.
     *
     * @param configurer Configuration function.
     *
     * @return This instance.
     *
     * @see JmxServiceFactory
     */
    public HekateBootstrap withJmx(Consumer<JmxServiceFactory> configurer) {
        return withService(JmxServiceFactory.class, configurer);
    }

    /**
     * Configures {@link NetworkService}.
     *
     * @param configurer Configuration function.
     *
     * @return This instance.
     *
     * @see NetworkServiceFactory
     */
    public HekateBootstrap withNetwork(Consumer<NetworkServiceFactory> configurer) {
        return withService(NetworkServiceFactory.class, configurer);
    }

    /**
     * Configures {@link ClusterService}.
     *
     * @param configurer Configuration function.
     *
     * @return This instance.
     *
     * @see ClusterServiceFactory
     */
    public HekateBootstrap withCluster(Consumer<ClusterServiceFactory> configurer) {
        return withService(ClusterServiceFactory.class, configurer);
    }

    /**
     * Configures {@link MessagingService}.
     *
     * @param configurer Configuration function.
     *
     * @return This instance.
     *
     * @see MessagingServiceFactory
     */
    public HekateBootstrap withMessaging(Consumer<MessagingServiceFactory> configurer) {
        return withService(MessagingServiceFactory.class, configurer);
    }

    /**
     * Configures {@link RpcService}.
     *
     * @param configurer Configuration function.
     *
     * @return This instance.
     *
     * @see RpcServiceFactory
     */
    public HekateBootstrap withRpc(Consumer<RpcServiceFactory> configurer) {
        return withService(RpcServiceFactory.class, configurer);
    }

    /**
     * Configures {@link LockService}.
     *
     * @param configurer Configuration function.
     *
     * @return This instance.
     *
     * @see LockServiceFactory
     */
    public HekateBootstrap withLocks(Consumer<LockServiceFactory> configurer) {
        return withService(LockServiceFactory.class, configurer);
    }

    /**
     * Configures {@link ElectionService}.
     *
     * @param configurer Configuration function.
     *
     * @return This instance.
     *
     * @see ElectionServiceFactory
     */
    public HekateBootstrap withElection(Consumer<ElectionServiceFactory> configurer) {
        return withService(ElectionServiceFactory.class, configurer);
    }

    /**
     * Configures {@link CoordinationService}.
     *
     * @param configurer Configuration function.
     *
     * @return This instance.
     *
     * @see CoordinationServiceFactory
     */
    public HekateBootstrap withCoordination(Consumer<CoordinationServiceFactory> configurer) {
        return withService(CoordinationServiceFactory.class, configurer);
    }

    /**
     * Finds a service factory of the specified type (see {@link #setServices(List)}).
     *
     * @param factoryType Service factory type.
     * @param <T> Service factory type.
     *
     * @return Optional service factory if it was registered within this instance.
     */
    public <T extends ServiceFactory<?>> Optional<T> service(Class<T> factoryType) {
        return nullSafe(services)
            .filter(factory -> factoryType.isAssignableFrom(factory.getClass()))
            .map(factoryType::cast)
            .findFirst();
    }

    /**
     * Returns the list of plugins that should run within the local node (see {@link #setPlugins(List)}).
     *
     * @return List of plugins.
     */
    public List<Plugin> getPlugins() {
        return plugins;
    }

    /**
     * Sets the list of plugins that should run within the local node.
     *
     *

     * Plugins are custom extensions that run within the context of a local node and whose lifecycle is controlled by the lifecycle of that
     * node. For more info please see description of the {@link Plugin} interface.
     *

     *
     * @param plugins List of plugins.
     *
     * @see Plugin
     */
    public void setPlugins(List<Plugin> plugins) {
        this.plugins = plugins;
    }

    /**
     * Adds the specified plugin to a {@link #setPlugins(List) list of plugins}.
     *
     * @param plugin Plugin.
     *
     * @return This instance.
     */
    public HekateBootstrap withPlugin(Plugin plugin) {
        if (plugins == null) {
            plugins = new ArrayList<>();
        }

        plugins.add(plugin);

        return this;
    }

    /**
     * Returns the default codec factory (see {@link #setDefaultCodec(CodecFactory)}).
     *
     * @return Default codec factory.
     */
    public CodecFactory<Object> getDefaultCodec() {
        return defaultCodec;
    }

    /**
     * Sets the codec factory that should be used by the {@link CodecService}.
     *
     *

     * This parameter is mandatory and can't be {@code null}. Also, the specified codec factory must be stateless (see {@link
     * Codec#isStateful()}).
     *

     *
     *

     * If not configured then {@link JdkCodecFactory} will be used by default.
     *

     *
     * @param defaultCodec Codec factory (must be stateless, see {@link Codec#isStateful()}) .
     *
     * @see CodecService
     */
    public void setDefaultCodec(CodecFactory<Object> defaultCodec) {
        this.defaultCodec = defaultCodec;
    }

    /**
     * Fluent-style version of {@link #setDefaultCodec(CodecFactory)}.
     *
     * @param defaultCodec Default codec factory.
     *
     * @return This instance.
     */
    public HekateBootstrap withDefaultCodec(CodecFactory<Object> defaultCodec) {
        setDefaultCodec(defaultCodec);

        return this;
    }

    /**
     * Returns the metrics registry.
     *
     * @return Metrics registry.
     */
    public MeterRegistry getMetrics() {
        return metrics;
    }

    /**
     * Sets the metrics registry.
     *
     *

     * If not specified then {@link SimpleMeterRegistry} will be used by default.
     *

     *
     * @param metrics Metrics registry.
     */
    public void setMetrics(MeterRegistry metrics) {
        this.metrics = metrics;
    }

    /**
     * Fluent-style version of {@link #setMetrics(MeterRegistry)}.
     *
     * @param metrics Metrics registry.
     *
     * @return This instance.
     */
    public HekateBootstrap withMetrics(MeterRegistry metrics) {
        setMetrics(metrics);

        return this;
    }

    /**
     * Returns the list of instance lifecycle listeners (see {@link #setLifecycleListeners(List)}).
     *
     * @return Lifecycle listeners.
     */
    public List<Hekate.LifecycleListener> getLifecycleListeners() {
        return lifecycleListeners;
    }

    /**
     * Sets the list of {@link Hekate} lifecycle listeners.
     *
     * @param lifecycleListeners Lifecycle listeners.
     *
     * @see Hekate#addListener(Hekate.LifecycleListener)
     */
    public void setLifecycleListeners(List<Hekate.LifecycleListener> lifecycleListeners) {
        this.lifecycleListeners = lifecycleListeners;
    }

    /**
     * Fluent-style version of {@link #setLifecycleListeners(List)}.
     *
     * @param listener Lifecycle listener.
     *
     * @return This instance.
     */
    public HekateBootstrap withLifecycleListener(Hekate.LifecycleListener listener) {
        if (lifecycleListeners == null) {
            lifecycleListeners = new ArrayList<>();
        }

        lifecycleListeners.add(listener);

        return this;
    }

    /**
     * Returns fatal error handling policy (see {@link #setFatalErrorPolicy(HekateFatalErrorPolicy)}).
     *
     * @return Fatal error handling policy.
     */
    public HekateFatalErrorPolicy getFatalErrorPolicy() {
        return fatalErrorPolicy;
    }

    /**
     * Sets the fatal error handling policy.
     *
     *

     * This policy is applied if {@link Hekate} node faces an unrecoverable internal error.
     *

     *
     *

     * If not specified then {@link HekateFatalErrorPolicy#terminate()} policy will be used by default.
     *

     *
     * @param fatalErrorPolicy Fatal error handling policy.
     */
    public void setFatalErrorPolicy(HekateFatalErrorPolicy fatalErrorPolicy) {
        this.fatalErrorPolicy = fatalErrorPolicy;
    }

    /**
     * Fluent-style version of {@link #setFatalErrorPolicy(HekateFatalErrorPolicy)}.
     *
     * @param fatalErrorPolicy Fatal error handling policy.
     *
     * @return Fatal error handling policy.
     */
    public HekateBootstrap withFatalErrorPolicy(HekateFatalErrorPolicy fatalErrorPolicy) {
        setFatalErrorPolicy(fatalErrorPolicy);

        return this;
    }

    /**
     * {@code true} if the configuration report should be logged during node initialization.
     *
     * @return {@code true} if the configuration report should be logged during node initialization.
     */
    public boolean isConfigReport() {
        return configReport;
    }

    /**
     * {@code true} if the configuration report should be logged during node initialization.
     *
     *

     * Default value of this property is {@code false}.
     *

     *
     * @param configReport {@code true} if the configuration report should be logged during node initialization.
     */
    public void setConfigReport(boolean configReport) {
        this.configReport = configReport;
    }

    /**
     * Fluent-style version of {@link #setConfigReport(boolean)}.
     *
     * @param configReport {@code true} if the configuration report should be logged during node initialization.
     *
     * @return This instance.
     */
    public HekateBootstrap withConfigReport(boolean configReport) {
        setConfigReport(configReport);

        return this;
    }

    /**
     * Creates a new {@link Hekate} instance.
     *
     * @return New {@link Hekate} instance.
     */
    protected Hekate create() {
        return HekateNodeFactory.create(this);
    }

    @Override
    public String toString() {
        return ToString.format(this);
    }
}