<?hh
/**
 * Autogenerated by Thrift
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */

type StructWithWrapper = \MyStructWrapper<\thrift_adapted_types\StructWithWrapper>;
/**
 * Original thrift enum:-
 * MyEnum
 */
enum MyEnum: int {
  UNKNOWN = 0;
  ONE = 1;
}

class MyEnum_TEnumStaticMetadata implements \IThriftEnumStaticMetadata {
  public static function getEnumMetadata()[]: \tmeta_ThriftEnum {
    return tmeta_ThriftEnum::fromShape(
      shape(
        "name" => "annotations.MyEnum",
        "elements" => dict[
          0 => "UNKNOWN",
          1 => "ONE",
        ],
      )
    );
  }

  public static function getAllStructuredAnnotations()[write_props]: \TEnumAnnotations {
    $structured_annotation_recursive0 = structured_annotation_recursive::withDefaultValues();
    $structured_annotation_recursive0->name = "abc_enum";

    $structured_annotation_recursive1 = structured_annotation_recursive::withDefaultValues();
    $structured_annotation_recursive1->name = "cba_enum";

    $structured_annotation_recursive0->get_recurse()->setValue_DO_NOT_USE_THRIFT_INTERNAL($structured_annotation_recursive1);

    $structured_annotation_recursive0->default = structured_annotation_with_default::fromShape(
      shape(
        "count" => 3,
      )
    );

    $structured_annotation_recursive2 = structured_annotation_recursive::withDefaultValues();
    $structured_annotation_recursive2->name = "key_enum1";

    $structured_annotation_recursive3 = structured_annotation_recursive::withDefaultValues();
    $structured_annotation_recursive3->name = "def_enum";

    $structured_annotation_recursive2->get_recurse()->setValue_DO_NOT_USE_THRIFT_INTERNAL($structured_annotation_recursive3);

    $structured_annotation_recursive4 = structured_annotation_recursive::withDefaultValues();
    $structured_annotation_recursive4->name = "key_enum2";

    $structured_annotation_recursive5 = structured_annotation_recursive::withDefaultValues();
    $structured_annotation_recursive5->name = "fed_enum";

    $structured_annotation_recursive4->get_recurse()->setValue_DO_NOT_USE_THRIFT_INTERNAL($structured_annotation_recursive5);

    $structured_annotation_recursive0->recurse_map = dict[
      "key_enum1" => $structured_annotation_recursive2,
      "key_enum2" => $structured_annotation_recursive4,
    ];

    return shape(
      'enum' => dict[],
      'constants' => dict[
        'UNKNOWN' => dict[
          'structured_annotation_recursive' => $structured_annotation_recursive0,
        ],
      ],
    );
  }
}

type i64WithWrapper = \MyTypeIntWrapper<\thrift_adapted_types\i64WithWrapper>;
/**
 * Original thrift struct:-
 * structured_annotation_with_default
 */
class structured_annotation_with_default implements \IThriftSyncStruct, \IThriftStructMetadata, \IThriftShapishSyncStruct {
  use \ThriftSerializationTrait;

  const \ThriftStructTypes::TSpec SPEC = dict[
    1 => shape(
      'var' => 'count',
      'type' => \TType::I32,
    ),
  ];
  const dict<string, int> FIELDMAP = dict[
    'count' => 1,
  ];

  const type TConstructorShape = shape(
    ?'count' => ?int,
  );

  const type TShape = shape(
    'count' => int,
  );
  const int STRUCTURAL_ID = 1502749363246025945;
  /**
   * Original thrift field:-
   * 1: i32 count
   */
  public int $count;

  public function __construct(?int $count = null)[] {
    $this->count = $count ?? 0;
  }

  public static function withDefaultValues()[]: this {
    return new static();
  }

  public static function fromShape(self::TConstructorShape $shape)[]: this {
    return new static(
      Shapes::idx($shape, 'count'),
    );
  }

  public static function fromMap_DEPRECATED(@KeyedContainer<string, mixed> $map)[]: this {
    return new static(
      HH\FIXME\UNSAFE_CAST<mixed, int>(idx($map, 'count'), 'map value is mixed'),
    );
  }

  public function getName()[]: string {
    return 'structured_annotation_with_default';
  }

  public function clearTerseFields()[write_props]: void {
  }

  public static function getStructMetadata()[]: \tmeta_ThriftStruct {
    return tmeta_ThriftStruct::fromShape(
      shape(
        "name" => "annotations.structured_annotation_with_default",
        "fields" => vec[
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 1,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_I32_TYPE,
                )
              ),
              "name" => "count",
            )
          ),
        ],
        "is_union" => false,
      )
    );
  }

  public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations {
    return shape(
      'struct' => dict[],
      'fields' => dict[
      ],
    );
  }

  public static function __stringifyMapKeys<T>(dict<arraykey, T> $m)[]: dict<string, T> {
    return Dict\map_keys($m, $key ==> (string)$key);
  }

  public static function __fromShape(self::TShape $shape)[]: this {
    return new static(
      $shape['count'],
    );
  }

  public function __toShape()[]: self::TShape {
    return shape(
      'count' => $this->count,
    );
  }
  public function getInstanceKey()[write_props]: string {
    return \TCompactSerializer::serialize($this);
  }

  public function readFromJson(string $jsonText): void {
    $parsed = json_decode($jsonText, true);

    if ($parsed === null || !($parsed is KeyedContainer<_, _>)) {
      throw new \TProtocolException("Cannot parse the given json string.");
    }

    if (idx($parsed, 'count') !== null) {
      $_tmp0 = (int)HH\FIXME\UNSAFE_CAST<mixed, int>($parsed['count']);
      if ($_tmp0 > 0x7fffffff) {
        throw new \TProtocolException("number exceeds limit in field");
      } else {
        $this->count = (int)$_tmp0;
      }
    }
  }

}

/**
 * Original thrift struct:-
 * structured_annotation_recursive
 */
class structured_annotation_recursive implements \IThriftAsyncStruct, \IThriftStructMetadata, \IThriftShapishAsyncStruct {
  use \ThriftSerializationTrait;

  const \ThriftStructTypes::TSpec SPEC = dict[
    1 => shape(
      'var' => 'name',
      'type' => \TType::STRING,
    ),
    2 => shape(
      'var' => 'recurse',
      'is_wrapped' => true,
      'type' => \TType::STRUCT,
      'class' => structured_annotation_recursive::class,
    ),
    3 => shape(
      'var' => 'default',
      'type' => \TType::STRUCT,
      'class' => structured_annotation_with_default::class,
    ),
    4 => shape(
      'var' => 'recurse_map',
      'type' => \TType::MAP,
      'ktype' => \TType::STRING,
      'vtype' => \TType::STRUCT,
      'key' => shape(
        'type' => \TType::STRING,
      ),
      'val' => shape(
        'type' => \TType::STRUCT,
        'class' => structured_annotation_recursive::class,
      ),
      'format' => 'harray',
    ),
    5 => shape(
      'var' => 'int_field',
      'is_type_wrapped' => true,
      'type' => \TType::I64,
    ),
  ];
  const dict<string, int> FIELDMAP = dict[
    'name' => 1,
    'recurse' => 2,
    'default' => 3,
    'recurse_map' => 4,
    'int_field' => 5,
  ];

  const type TConstructorShape = shape(
    ?'name' => ?string,
    ?'recurse' => ?structured_annotation_recursive,
    ?'default' => ?structured_annotation_with_default,
    ?'recurse_map' => ?dict<string, structured_annotation_recursive>,
    ?'int_field' => ?\thrift_adapted_types\i64WithWrapper,
  );

  const type TShape = shape(
    'name' => string,
    ?'recurse' => ?structured_annotation_recursive::TShape,
    ?'default' => ?structured_annotation_with_default::TShape,
    'recurse_map' => dict<arraykey, structured_annotation_recursive::TShape>,
    'int_field' => \thrift_adapted_types\i64WithWrapper,
  );
  const int STRUCTURAL_ID = 3145177041506723998;
  /**
   * Original thrift field:-
   * 1: string name
   */
  public string $name;
  /**
   * Original thrift field:-
   * 2: annotations.structured_annotation_recursive recurse
   */
  private ?MyFieldWrapper<?structured_annotation_recursive, structured_annotation_recursive> $recurse;

  public function get_recurse()[]: MyFieldWrapper<?structured_annotation_recursive, structured_annotation_recursive> {
    return $this->recurse as nonnull;
  }

  /**
   * Original thrift field:-
   * 3: annotations.structured_annotation_with_default default
   */
  public ?structured_annotation_with_default $default;
  /**
   * Original thrift field:-
   * 4: map<string, annotations.structured_annotation_recursive> recurse_map
   */
  public dict<string, structured_annotation_recursive> $recurse_map;
  /**
   * Original thrift field:-
   * 5: annotations.i64WithWrapper int_field
   */
  public i64WithWrapper $int_field;

  public function set_int_field_DO_NOT_USE_THRIFT_INTERNAL(int $int_field)[write_props]: void {
    $this->int_field = \MyTypeIntWrapper::fromThrift_DO_NOT_USE_THRIFT_INTERNAL<\thrift_adapted_types\i64WithWrapper>($int_field);
  }

  public function __construct()[] {
    $this->name = '';
    $this->recurse_map = dict[];
    $this->int_field = \MyTypeIntWrapper::fromThrift_DO_NOT_USE_THRIFT_INTERNAL<\thrift_adapted_types\i64WithWrapper>(0);
    $this->recurse = MyFieldWrapper::fromThrift_DO_NOT_USE_THRIFT_INTERNAL<?structured_annotation_recursive, structured_annotation_recursive>(null, 2, $this);
  }

  public static function withDefaultValues()[]: this {
    return new static();
  }

  public static async function genFromShape(self::TConstructorShape $shape)[zoned_shallow]: Awaitable<this> {
    $obj = new static();
    $name = Shapes::idx($shape, 'name');
    if ($name !== null) {
      $obj->name = $name;
    }
    $recurse = Shapes::idx($shape, 'recurse');
    if ($recurse !== null) {
      await $obj->get_recurse()->genWrap($recurse);
    }
    $default = Shapes::idx($shape, 'default');
    if ($default !== null) {
      $obj->default = $default;
    }
    $recurse_map = Shapes::idx($shape, 'recurse_map');
    if ($recurse_map !== null) {
      $obj->recurse_map = $recurse_map;
    }
    $int_field = Shapes::idx($shape, 'int_field');
    if ($int_field !== null) {
      $obj->int_field = await \MyTypeIntWrapper::genFromThrift<\thrift_adapted_types\i64WithWrapper>($int_field);
    }
    return $obj;
  }

  public static async function genFromMap_DEPRECATED(@KeyedContainer<string, mixed> $map): Awaitable<this> {
    $obj = new static();
    $name = idx($map, 'name');
    if ($name !== null) {
      $obj->name = HH\FIXME\UNSAFE_CAST<mixed, string>($name, 'Map value is mixed');
    }
    $recurse = idx($map, 'recurse');
    if ($recurse !== null) {
      await $obj->get_recurse()->genWrap(HH\FIXME\UNSAFE_CAST<mixed, structured_annotation_recursive>($recurse, 'Map value is mixed'));
    }
    $default = idx($map, 'default');
    if ($default !== null) {
      $obj->default = HH\FIXME\UNSAFE_CAST<mixed, structured_annotation_with_default>($default, 'Map value is mixed');
    }
    $recurse_map = idx($map, 'recurse_map');
    if ($recurse_map !== null) {
      $obj->recurse_map = HH\FIXME\UNSAFE_CAST<mixed, dict<string, structured_annotation_recursive>>($recurse_map, 'Map value is mixed');
    }
    $int_field = idx($map, 'int_field');
    if ($int_field !== null) {
      $obj->int_field = await \MyTypeIntWrapper::genFromThrift<\thrift_adapted_types\i64WithWrapper>(HH\FIXME\UNSAFE_CAST<mixed, \thrift_adapted_types\i64WithWrapper>($int_field, 'Map value is mixed'));
    }
    return $obj;
  }

  public function getName()[]: string {
    return 'structured_annotation_recursive';
  }

  public function clearTerseFields()[write_props]: void {
  }

  public static function getStructMetadata()[]: \tmeta_ThriftStruct {
    return tmeta_ThriftStruct::fromShape(
      shape(
        "name" => "annotations.structured_annotation_recursive",
        "fields" => vec[
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 1,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                )
              ),
              "name" => "name",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 2,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_typedef" => tmeta_ThriftTypedefType::fromShape(
                    shape(
                      "name" => "annotations.structured_annotation_recursive",
                      "underlyingType" => tmeta_ThriftType::fromShape(
                        shape(
                          "t_struct" => tmeta_ThriftStructType::fromShape(
                            shape(
                              "name" => "annotations.structured_annotation_recursive",
                            )
                          ),
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "recurse",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 3,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_struct" => tmeta_ThriftStructType::fromShape(
                    shape(
                      "name" => "annotations.structured_annotation_with_default",
                    )
                  ),
                )
              ),
              "name" => "default",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 4,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_map" => tmeta_ThriftMapType::fromShape(
                    shape(
                      "keyType" => tmeta_ThriftType::fromShape(
                        shape(
                          "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                        )
                      ),
                      "valueType" => tmeta_ThriftType::fromShape(
                        shape(
                          "t_typedef" => tmeta_ThriftTypedefType::fromShape(
                            shape(
                              "name" => "annotations.structured_annotation_recursive",
                              "underlyingType" => tmeta_ThriftType::fromShape(
                                shape(
                                  "t_struct" => tmeta_ThriftStructType::fromShape(
                                    shape(
                                      "name" => "annotations.structured_annotation_recursive",
                                    )
                                  ),
                                )
                              ),
                            )
                          ),
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "recurse_map",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 5,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_typedef" => tmeta_ThriftTypedefType::fromShape(
                    shape(
                      "name" => "annotations.i64WithWrapper",
                      "underlyingType" => tmeta_ThriftType::fromShape(
                        shape(
                          "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_I64_TYPE,
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "int_field",
            )
          ),
        ],
        "is_union" => false,
      )
    );
  }

  public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations {
    return shape(
      'struct' => dict[],
      'fields' => dict[
        'recurse' => shape(
          'field' => dict[
            '\facebook\thrift\annotation\hack\FieldWrapper' => \facebook\thrift\annotation\hack\FieldWrapper::fromShape(
              shape(
                "name" => "MyFieldWrapper",
              )
            ),
          ],
          'type' => dict[],
        ),
        'int_field' => shape(
          'field' => dict[],
          'type' => dict[
            '\facebook\thrift\annotation\hack\Wrapper' => \facebook\thrift\annotation\hack\Wrapper::fromShape(
              shape(
                "name" => "\\MyTypeIntWrapper",
              )
            ),
          ],
        ),
      ],
    );
  }

  public static function __stringifyMapKeys<T>(dict<arraykey, T> $m)[]: dict<string, T> {
    return Dict\map_keys($m, $key ==> (string)$key);
  }

  public static async function __genFromShape(self::TShape $shape): Awaitable<this> {
    $obj = new static();
    $obj->name = $shape['name'];
    $recurse = Shapes::idx($shape, 'recurse');
    if ($recurse !== null) {
      $recurse = await structured_annotation_recursive::__genFromShape($recurse);
      await $obj->get_recurse()->genWrap($recurse);
    }
    $default = Shapes::idx($shape, 'default');
    if ($default !== null) {
      $obj->default = structured_annotation_with_default::__fromShape($default);
    }
    $obj->recurse_map = self::__stringifyMapKeys(
      await Dict\map_async(
        $shape['recurse_map'],
        async $val0 ==>
          await structured_annotation_recursive::__genFromShape($val0)
      )
    );
    $obj->int_field = await \MyTypeIntWrapper::genFromThrift<\thrift_adapted_types\i64WithWrapper>($shape['int_field']);
    return $obj;
  }

  public async function __genToShape(): Awaitable<self::TShape> {
    $recurse = await ($this->recurse as nonnull)->genUnwrap();
    $int_field = await $this->int_field->genUnwrap();
    return shape(
      'name' => $this->name,
      'recurse' => await ($recurse === null
        ? null
        : (
        $recurse->__genToShape()
        )
      ),
      'default' => ($this->default === null
        ? null
        : (
        $this->default->__toShape()
        )
      ),
      'recurse_map' => await Dict\map_async(
        $this->recurse_map,
        async $val0 ==>
          await $val0->__genToShape()
      ),
      'int_field' => $int_field,
    );
  }
  public function getInstanceKey()[write_props]: string {
    return \TCompactSerializer::serialize($this);
  }

  public function readFromJson(string $jsonText): void {
    $parsed = json_decode($jsonText, true);

    if ($parsed === null || !($parsed is KeyedContainer<_, _>)) {
      throw new \TProtocolException("Cannot parse the given json string.");
    }

    if (idx($parsed, 'name') !== null) {
      $this->name = HH\FIXME\UNSAFE_CAST<mixed, string>($parsed['name']);
    }
    if (idx($parsed, 'recurse') !== null) {
      $_tmp0 = \json_encode(HH\FIXME\UNSAFE_CAST<mixed, structured_annotation_recursive>($parsed['recurse']));
      $_tmp1 = structured_annotation_recursive::withDefaultValues();
      $_tmp1->readFromJson($_tmp0);
      $this->recurse = $_tmp1;
    }
    if (idx($parsed, 'default') !== null) {
      $_tmp2 = \json_encode(HH\FIXME\UNSAFE_CAST<mixed, structured_annotation_with_default>($parsed['default']));
      $_tmp3 = structured_annotation_with_default::withDefaultValues();
      $_tmp3->readFromJson($_tmp2);
      $this->default = $_tmp3;
    }
    if (idx($parsed, 'recurse_map') !== null) {
      $_json7 = HH\FIXME\UNSAFE_CAST<mixed, dict<string, structured_annotation_recursive>>($parsed['recurse_map']);
      $_container8 = dict[];
      foreach($_json7 as $_key5 => $_value6) {
        $_value9 = structured_annotation_recursive::withDefaultValues();
        $_tmp10 = \json_encode($_value6);
        $_tmp11 = structured_annotation_recursive::withDefaultValues();
        $_tmp11->readFromJson($_tmp10);
        $_value9 = $_tmp11;
        $_container8[$_key5] = $_value9;
      }
      $this->recurse_map = $_container8;
    }
    if (idx($parsed, 'int_field') !== null) {
      $this->int_field = HH\FIXME\UNSAFE_CAST<mixed, i64WithWrapper>($parsed['int_field']);
    }
  }

}

/**
 * Original thrift struct:-
 * MyStruct
 */
class MyStruct implements \IThriftSyncStruct, \IThriftStructMetadata, \IThriftShapishSyncStruct {
  use \ThriftSerializationTrait;

  const \ThriftStructTypes::TSpec SPEC = dict[
    1 => shape(
      'var' => 'annotated_recursive',
      'type' => \TType::STRING,
    ),
    2 => shape(
      'var' => 'annotated_struct_wrapper',
      'type' => \TType::STRING,
    ),
  ];
  const dict<string, int> FIELDMAP = dict[
    'annotated_recursive' => 1,
    'annotated_struct_wrapper' => 2,
  ];

  const type TConstructorShape = shape(
    ?'annotated_recursive' => ?string,
    ?'annotated_struct_wrapper' => ?string,
  );

  const type TShape = shape(
    'annotated_recursive' => string,
    'annotated_struct_wrapper' => string,
  );
  const int STRUCTURAL_ID = 589959247947768145;
  /**
   * Original thrift field:-
   * 1: string annotated_recursive
   */
  public string $annotated_recursive;
  /**
   * Original thrift field:-
   * 2: string annotated_struct_wrapper
   */
  public string $annotated_struct_wrapper;

  public function __construct(?string $annotated_recursive = null, ?string $annotated_struct_wrapper = null)[] {
    $this->annotated_recursive = $annotated_recursive ?? '';
    $this->annotated_struct_wrapper = $annotated_struct_wrapper ?? '';
  }

  public static function withDefaultValues()[]: this {
    return new static();
  }

  public static function fromShape(self::TConstructorShape $shape)[]: this {
    return new static(
      Shapes::idx($shape, 'annotated_recursive'),
      Shapes::idx($shape, 'annotated_struct_wrapper'),
    );
  }

  public static function fromMap_DEPRECATED(@KeyedContainer<string, mixed> $map)[]: this {
    return new static(
      HH\FIXME\UNSAFE_CAST<mixed, string>(idx($map, 'annotated_recursive'), 'map value is mixed'),
      HH\FIXME\UNSAFE_CAST<mixed, string>(idx($map, 'annotated_struct_wrapper'), 'map value is mixed'),
    );
  }

  public function getName()[]: string {
    return 'MyStruct';
  }

  public function clearTerseFields()[write_props]: void {
  }

  public static function getStructMetadata()[]: \tmeta_ThriftStruct {
    return tmeta_ThriftStruct::fromShape(
      shape(
        "name" => "annotations.MyStruct",
        "fields" => vec[
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 1,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                )
              ),
              "name" => "annotated_recursive",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 2,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                )
              ),
              "name" => "annotated_struct_wrapper",
            )
          ),
        ],
        "is_union" => false,
      )
    );
  }

  public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations {
    $structured_annotation_recursive0 = structured_annotation_recursive::withDefaultValues();
    $structured_annotation_recursive0->name = "abc_struct";

    $structured_annotation_recursive1 = structured_annotation_recursive::withDefaultValues();
    $structured_annotation_recursive1->name = "cba_struct";

    $structured_annotation_recursive0->get_recurse()->setValue_DO_NOT_USE_THRIFT_INTERNAL($structured_annotation_recursive1);

    $structured_annotation_recursive0->default = structured_annotation_with_default::fromShape(
      shape(
        "count" => 3,
      )
    );

    $structured_annotation_recursive2 = structured_annotation_recursive::withDefaultValues();
    $structured_annotation_recursive2->name = "key_struct1";

    $structured_annotation_recursive3 = structured_annotation_recursive::withDefaultValues();
    $structured_annotation_recursive3->name = "def_struct";

    $structured_annotation_recursive2->get_recurse()->setValue_DO_NOT_USE_THRIFT_INTERNAL($structured_annotation_recursive3);

    $structured_annotation_recursive4 = structured_annotation_recursive::withDefaultValues();
    $structured_annotation_recursive4->name = "key_struct2";

    $structured_annotation_recursive5 = structured_annotation_recursive::withDefaultValues();
    $structured_annotation_recursive5->name = "fed_struct";

    $structured_annotation_recursive4->get_recurse()->setValue_DO_NOT_USE_THRIFT_INTERNAL($structured_annotation_recursive5);

    $structured_annotation_recursive0->recurse_map = dict[
      "key_struct1" => $structured_annotation_recursive2,
      "key_struct2" => $structured_annotation_recursive4,
    ];

    $structured_annotation_recursive0->int_field = \MyTypeIntWrapper::fromThrift_DO_NOT_USE_THRIFT_INTERNAL<\thrift_adapted_types\i64WithWrapper>(10);

    $structured_annotation_recursive6 = structured_annotation_recursive::withDefaultValues();
    $structured_annotation_recursive6->name = "abc_struct_field";

    $structured_annotation_recursive7 = structured_annotation_recursive::withDefaultValues();
    $structured_annotation_recursive7->name = "cba_struct_field";

    $structured_annotation_recursive6->get_recurse()->setValue_DO_NOT_USE_THRIFT_INTERNAL($structured_annotation_recursive7);

    $structured_annotation_recursive6->default = structured_annotation_with_default::fromShape(
      shape(
        "count" => 3,
      )
    );

    $structured_annotation_recursive8 = structured_annotation_recursive::withDefaultValues();
    $structured_annotation_recursive8->name = "key_struct_field1";

    $structured_annotation_recursive9 = structured_annotation_recursive::withDefaultValues();
    $structured_annotation_recursive9->name = "def_struct_field";

    $structured_annotation_recursive8->get_recurse()->setValue_DO_NOT_USE_THRIFT_INTERNAL($structured_annotation_recursive9);

    $structured_annotation_recursive10 = structured_annotation_recursive::withDefaultValues();
    $structured_annotation_recursive10->name = "key_struct_field2";

    $structured_annotation_recursive11 = structured_annotation_recursive::withDefaultValues();
    $structured_annotation_recursive11->name = "fed_struct_field";

    $structured_annotation_recursive10->get_recurse()->setValue_DO_NOT_USE_THRIFT_INTERNAL($structured_annotation_recursive11);

    $structured_annotation_recursive6->recurse_map = dict[
      "key_struct_field1" => $structured_annotation_recursive8,
      "key_struct_field2" => $structured_annotation_recursive10,
    ];

    return shape(
      'struct' => dict[
        'structured_annotation_recursive' => $structured_annotation_recursive0,
      ],
      'fields' => dict[
        'annotated_recursive' => shape(
          'field' => dict[
            'structured_annotation_recursive' => $structured_annotation_recursive6,
          ],
          'type' => dict[],
        ),
        'annotated_struct_wrapper' => shape(
          'field' => dict[
            'StructWithWrapper' => \thrift_adapted_types\StructWithWrapper::fromShape(
              shape(
                "int_field" => 11,
              )
            ),
          ],
          'type' => dict[],
        ),
      ],
    );
  }

  public static function __stringifyMapKeys<T>(dict<arraykey, T> $m)[]: dict<string, T> {
    return Dict\map_keys($m, $key ==> (string)$key);
  }

  public static function __fromShape(self::TShape $shape)[]: this {
    return new static(
      $shape['annotated_recursive'],
      $shape['annotated_struct_wrapper'],
    );
  }

  public function __toShape()[]: self::TShape {
    return shape(
      'annotated_recursive' => $this->annotated_recursive,
      'annotated_struct_wrapper' => $this->annotated_struct_wrapper,
    );
  }
  public function getInstanceKey()[write_props]: string {
    return \TCompactSerializer::serialize($this);
  }

  public function readFromJson(string $jsonText): void {
    $parsed = json_decode($jsonText, true);

    if ($parsed === null || !($parsed is KeyedContainer<_, _>)) {
      throw new \TProtocolException("Cannot parse the given json string.");
    }

    if (idx($parsed, 'annotated_recursive') !== null) {
      $this->annotated_recursive = HH\FIXME\UNSAFE_CAST<mixed, string>($parsed['annotated_recursive']);
    }
    if (idx($parsed, 'annotated_struct_wrapper') !== null) {
      $this->annotated_struct_wrapper = HH\FIXME\UNSAFE_CAST<mixed, string>($parsed['annotated_struct_wrapper']);
    }
  }

}


<?hh
/**
 * Autogenerated by Thrift
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */

class constants_CONSTANTS implements \IThriftConstants {
  /**
   * Original thrift constant:-
   * constants.MyCompany my_company
   */
  const MyCompany my_company = Company::FACEBOOK;

  /**
   * Original thrift constant:-
   * constants.Internship instagram
   */
  <<__Memoize>>
  public static function instagram()[write_props]: Internship{
    $Internship0 = Internship::withDefaultValues();
    $Internship0->weeks = 12;

    $Internship0->title = "Software Engineer";

    $Internship0->employer = Company::INSTAGRAM;

    $Internship0->get_compensation()->setValue_DO_NOT_USE_THRIFT_INTERNAL(1200.0);

    $Internship0->school = "Monters University";

    $Internship0->intern_id = \MyTypeIntWrapper::fromThrift_DO_NOT_USE_THRIFT_INTERNAL<\detail\i64WithWrapper>(10011);

    return $Internship0;
  }

  /**
   * Original thrift constant:-
   * list<constants.Internship> internList
   */
  <<__Memoize>>
  public static function internList()[write_props]: vec<Internship>{
    $Internship0 = Internship::withDefaultValues();
    $Internship0->weeks = 12;

    $Internship0->title = "Software Engineer";

    $Internship0->employer = Company::INSTAGRAM;

    $Internship0->get_compensation()->setValue_DO_NOT_USE_THRIFT_INTERNAL(1200.0);

    $Internship0->school = "Monters University";

    $Internship0->intern_id = \MyTypeIntWrapper::fromThrift_DO_NOT_USE_THRIFT_INTERNAL<\detail\i64WithWrapper>(10011);

    $Internship1 = Internship::withDefaultValues();
    $Internship1->weeks = 10;

    $Internship1->title = "Sales Intern";

    $Internship1->employer = Company::FACEBOOK;

    $Internship1->get_compensation()->setValue_DO_NOT_USE_THRIFT_INTERNAL(1000.0);

    $Internship1->intern_id = \MyTypeIntWrapper::fromThrift_DO_NOT_USE_THRIFT_INTERNAL<\detail\i64WithWrapper>(10013);

    return vec[
      $Internship0,
      $Internship1,
    ];
  }

  /**
   * Original thrift constant:-
   * list<constants.SWE> engineers
   */
  <<__Memoize>>
  public static function engineers()[write_props]: vec<SWE>{
    return vec[
      SWE::fromShape(
        shape(
          "employer" => Company::FACEBOOK,
          "compensation" => 1000.0,
        )
      ),
      SWE::fromShape(
        shape(
          "employer" => Company::WHATSAPP,
          "compensation" => 1200.0,
        )
      ),
      SWE::fromShape(
        shape(
          "employer" => Company::OCULUS,
          "compensation" => 1200.0,
        )
      ),
    ];
  }

  /**
   * Original thrift constant:-
   * list<include.StructWithWrapper> wrapped_structs
   */
  <<__Memoize>>
  public static function wrapped_structs()[write_props]: vec<StructWithWrapper>{
    return vec[
      \MyStructWrapper::fromThrift_DO_NOT_USE_THRIFT_INTERNAL<\thrift_adapted_types\StructWithWrapper>(\thrift_adapted_types\StructWithWrapper::fromShape(
        shape(
          "int_field" => 1,
        )
      )),
      \MyStructWrapper::fromThrift_DO_NOT_USE_THRIFT_INTERNAL<\thrift_adapted_types\StructWithWrapper>(\thrift_adapted_types\StructWithWrapper::fromShape(
        shape(
          "int_field" => 2,
        )
      )),
    ];
  }

  /**
   * Original thrift constant:-
   * list<include.i64WithWrapper> wrapped_ints
   */
  <<__Memoize>>
  public static function wrapped_ints()[write_props]: vec<i64WithWrapper>{
    return vec[
      \MyTypeIntWrapper::fromThrift_DO_NOT_USE_THRIFT_INTERNAL<\detail\i64WithWrapper>(1),
      \MyTypeIntWrapper::fromThrift_DO_NOT_USE_THRIFT_INTERNAL<\detail\i64WithWrapper>(2),
    ];
  }

  public static function getAllStructuredAnnotations()[write_props]: dict<string, dict<string, \IThriftStruct>> {
    return dict[
      'engineers' => dict[
        'AnnotationStruct' => AnnotationStruct::fromShape(
          shape(
          )
        ),
      ],
    ];
  }
}


<?hh
/**
 * Autogenerated by Thrift
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */

/**
 * Original thrift enum:-
 * Company
 */
enum Company: int {
  FACEBOOK = 0;
  WHATSAPP = 1;
  OCULUS = 2;
  INSTAGRAM = 3;
}

class Company_TEnumStaticMetadata implements \IThriftEnumStaticMetadata {
  public static function getEnumMetadata()[]: \tmeta_ThriftEnum {
    return tmeta_ThriftEnum::fromShape(
      shape(
        "name" => "constants.Company",
        "elements" => dict[
          0 => "FACEBOOK",
          1 => "WHATSAPP",
          2 => "OCULUS",
          3 => "INSTAGRAM",
        ],
      )
    );
  }

  public static function getAllStructuredAnnotations()[write_props]: \TEnumAnnotations {
    return shape(
      'enum' => dict[],
      'constants' => dict[
        'FACEBOOK' => dict[
          'AnnotationStruct' => AnnotationStruct::fromShape(
            shape(
            )
          ),
        ],
      ],
    );
  }
}

type MyCompany = Company;
/**
 * Original thrift struct:-
 * Internship
 */
class Internship implements \IThriftAsyncStruct, \IThriftStructMetadata, \IThriftShapishAsyncStruct {
  use \ThriftSerializationTrait;

  const \ThriftStructTypes::TSpec SPEC = dict[
    1 => shape(
      'var' => 'weeks',
      'type' => \TType::I32,
    ),
    2 => shape(
      'var' => 'title',
      'type' => \TType::STRING,
    ),
    3 => shape(
      'var' => 'employer',
      'type' => \TType::I32,
      'enum' => Company::class,
    ),
    4 => shape(
      'var' => 'compensation',
      'is_wrapped' => true,
      'type' => \TType::DOUBLE,
    ),
    5 => shape(
      'var' => 'school',
      'type' => \TType::STRING,
    ),
    6 => shape(
      'var' => 'intern_id',
      'is_type_wrapped' => true,
      'type' => \TType::I64,
    ),
  ];
  const dict<string, int> FIELDMAP = dict[
    'weeks' => 1,
    'title' => 2,
    'employer' => 3,
    'compensation' => 4,
    'school' => 5,
    'intern_id' => 6,
  ];

  const type TConstructorShape = shape(
    ?'weeks' => ?int,
    ?'title' => ?string,
    ?'employer' => ?Company,
    ?'compensation' => ?float,
    ?'school' => ?string,
    ?'intern_id' => ?\detail\i64WithWrapper,
  );

  const type TShape = shape(
    'weeks' => int,
    'title' => string,
    ?'employer' => ?Company,
    ?'compensation' => ?float,
    ?'school' => ?string,
    'intern_id' => \detail\i64WithWrapper,
  );
  const int STRUCTURAL_ID = 2043029874796299989;
  /**
   * Original thrift field:-
   * 1: i32 weeks
   */
  public int $weeks;
  /**
   * Original thrift field:-
   * 2: string title
   */
  public string $title;
  /**
   * Original thrift field:-
   * 3: constants.Company employer
   */
  public ?Company $employer;
  /**
   * Original thrift field:-
   * 4: double compensation
   */
  private ?\MyFieldWrapper<?float, Internship> $compensation;

  public function get_compensation()[]: \MyFieldWrapper<?float, Internship> {
    return $this->compensation as nonnull;
  }

  /**
   * Original thrift field:-
   * 5: string school
   */
  public ?string $school;
  /**
   * Original thrift field:-
   * 6: include.i64WithWrapper intern_id
   */
  public i64WithWrapper $intern_id;

  public function set_intern_id_DO_NOT_USE_THRIFT_INTERNAL(int $intern_id)[write_props]: void {
    $this->intern_id = \MyTypeIntWrapper::fromThrift_DO_NOT_USE_THRIFT_INTERNAL<\detail\i64WithWrapper>($intern_id);
  }

  public function __construct()[] {
    $this->weeks = 0;
    $this->title = '';
    $this->intern_id = \MyTypeIntWrapper::fromThrift_DO_NOT_USE_THRIFT_INTERNAL<\detail\i64WithWrapper>(0);
    $this->compensation = \MyFieldWrapper::fromThrift_DO_NOT_USE_THRIFT_INTERNAL<?float, Internship>(null, 4, $this);
  }

  public static function withDefaultValues()[]: this {
    return new static();
  }

  public static async function genFromShape(self::TConstructorShape $shape)[zoned_shallow]: Awaitable<this> {
    $obj = new static();
    $weeks = Shapes::idx($shape, 'weeks');
    if ($weeks !== null) {
      $obj->weeks = $weeks;
    }
    $title = Shapes::idx($shape, 'title');
    if ($title !== null) {
      $obj->title = $title;
    }
    $employer = Shapes::idx($shape, 'employer');
    if ($employer !== null) {
      $obj->employer = $employer;
    }
    $compensation = Shapes::idx($shape, 'compensation');
    if ($compensation !== null) {
      await $obj->get_compensation()->genWrap($compensation);
    }
    $school = Shapes::idx($shape, 'school');
    if ($school !== null) {
      $obj->school = $school;
    }
    $intern_id = Shapes::idx($shape, 'intern_id');
    if ($intern_id !== null) {
      $obj->intern_id = await \MyTypeIntWrapper::genFromThrift<\detail\i64WithWrapper>($intern_id);
    }
    return $obj;
  }

  public static async function genFromMap_DEPRECATED(@KeyedContainer<string, mixed> $map): Awaitable<this> {
    $obj = new static();
    $weeks = idx($map, 'weeks');
    if ($weeks !== null) {
      $obj->weeks = HH\FIXME\UNSAFE_CAST<mixed, int>($weeks, 'Map value is mixed');
    }
    $title = idx($map, 'title');
    if ($title !== null) {
      $obj->title = HH\FIXME\UNSAFE_CAST<mixed, string>($title, 'Map value is mixed');
    }
    $employer = idx($map, 'employer');
    if ($employer !== null) {
      $obj->employer = HH\FIXME\UNSAFE_CAST<mixed, Company>($employer, 'Map value is mixed');
    }
    $compensation = idx($map, 'compensation');
    if ($compensation !== null) {
      await $obj->get_compensation()->genWrap(HH\FIXME\UNSAFE_CAST<mixed, float>($compensation, 'Map value is mixed'));
    }
    $school = idx($map, 'school');
    if ($school !== null) {
      $obj->school = HH\FIXME\UNSAFE_CAST<mixed, string>($school, 'Map value is mixed');
    }
    $intern_id = idx($map, 'intern_id');
    if ($intern_id !== null) {
      $obj->intern_id = await \MyTypeIntWrapper::genFromThrift<\detail\i64WithWrapper>(HH\FIXME\UNSAFE_CAST<mixed, \detail\i64WithWrapper>($intern_id, 'Map value is mixed'));
    }
    return $obj;
  }

  public function getName()[]: string {
    return 'Internship';
  }

  public function clearTerseFields()[write_props]: void {
  }

  public static function getStructMetadata()[]: \tmeta_ThriftStruct {
    return tmeta_ThriftStruct::fromShape(
      shape(
        "name" => "constants.Internship",
        "fields" => vec[
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 1,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_I32_TYPE,
                )
              ),
              "name" => "weeks",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 2,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                )
              ),
              "name" => "title",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 3,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_enum" => tmeta_ThriftEnumType::fromShape(
                    shape(
                      "name" => "constants.Company",
                    )
                  ),
                )
              ),
              "name" => "employer",
              "is_optional" => true,
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 4,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_DOUBLE_TYPE,
                )
              ),
              "name" => "compensation",
              "is_optional" => true,
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 5,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                )
              ),
              "name" => "school",
              "is_optional" => true,
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 6,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_typedef" => tmeta_ThriftTypedefType::fromShape(
                    shape(
                      "name" => "include.i64WithWrapper",
                      "underlyingType" => tmeta_ThriftType::fromShape(
                        shape(
                          "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_I64_TYPE,
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "intern_id",
            )
          ),
        ],
        "is_union" => false,
      )
    );
  }

  public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations {
    return shape(
      'struct' => dict[],
      'fields' => dict[
        'compensation' => shape(
          'field' => dict[
            'AnnotationStruct' => AnnotationStruct::fromShape(
              shape(
              )
            ),
          ],
          'type' => dict[],
        ),
        'intern_id' => shape(
          'field' => dict[],
          'type' => dict[
            '\facebook\thrift\annotation\hack\Wrapper' => \facebook\thrift\annotation\hack\Wrapper::fromShape(
              shape(
                "name" => "\\MyTypeIntWrapper",
                "extraNamespace" => "detail",
              )
            ),
          ],
        ),
      ],
    );
  }

  public static function __stringifyMapKeys<T>(dict<arraykey, T> $m)[]: dict<string, T> {
    return Dict\map_keys($m, $key ==> (string)$key);
  }

  public static async function __genFromShape(self::TShape $shape): Awaitable<this> {
    $obj = new static();
    $obj->weeks = $shape['weeks'];
    $obj->title = $shape['title'];
    $employer = Shapes::idx($shape, 'employer');
    if ($employer !== null) {
      $obj->employer = $employer;
    }
    $compensation = Shapes::idx($shape, 'compensation');
    if ($compensation !== null) {
      await $obj->get_compensation()->genWrap($compensation);
    }
    $school = Shapes::idx($shape, 'school');
    if ($school !== null) {
      $obj->school = $school;
    }
    $obj->intern_id = await \MyTypeIntWrapper::genFromThrift<\detail\i64WithWrapper>($shape['intern_id']);
    return $obj;
  }

  public async function __genToShape(): Awaitable<self::TShape> {
    $compensation = await ($this->compensation as nonnull)->genUnwrap();
    $intern_id = await $this->intern_id->genUnwrap();
    return shape(
      'weeks' => $this->weeks,
      'title' => $this->title,
      'employer' => $this->employer,
      'compensation' => $compensation,
      'school' => $this->school,
      'intern_id' => $intern_id,
    );
  }
  public function getInstanceKey()[write_props]: string {
    return \TCompactSerializer::serialize($this);
  }

  public function readFromJson(string $jsonText): void {
    $parsed = json_decode($jsonText, true);

    if ($parsed === null || !($parsed is KeyedContainer<_, _>)) {
      throw new \TProtocolException("Cannot parse the given json string.");
    }

    if (idx($parsed, 'weeks') !== null) {
      $_tmp0 = (int)HH\FIXME\UNSAFE_CAST<mixed, int>($parsed['weeks']);
      if ($_tmp0 > 0x7fffffff) {
        throw new \TProtocolException("number exceeds limit in field");
      } else {
        $this->weeks = (int)$_tmp0;
      }
    } else {
      throw new \TProtocolException("Required field weeks cannot be found.");
    }
    if (idx($parsed, 'title') !== null) {
      $this->title = HH\FIXME\UNSAFE_CAST<mixed, string>($parsed['title']);
    }
    if (idx($parsed, 'employer') !== null) {
      $this->employer = Company::coerce(HH\FIXME\UNSAFE_CAST<mixed, Company>($parsed['employer']));
    }
    if (idx($parsed, 'compensation') !== null) {
      $this->compensation = HH\FIXME\UNSAFE_CAST<mixed, float>($parsed['compensation']);
    }
    if (idx($parsed, 'school') !== null) {
      $this->school = HH\FIXME\UNSAFE_CAST<mixed, string>($parsed['school']);
    }
    if (idx($parsed, 'intern_id') !== null) {
      $this->intern_id = HH\FIXME\UNSAFE_CAST<mixed, i64WithWrapper>($parsed['intern_id']);
    }
  }

}

/**
 * Original thrift struct:-
 * SWE
 */
class SWE implements \IThriftSyncStruct, \IThriftStructMetadata, \IThriftShapishSyncStruct {
  use \ThriftSerializationTrait;

  const \ThriftStructTypes::TSpec SPEC = dict[
    1 => shape(
      'var' => 'employer',
      'type' => \TType::I32,
      'enum' => Company::class,
    ),
    2 => shape(
      'var' => 'compensation',
      'type' => \TType::DOUBLE,
    ),
  ];
  const dict<string, int> FIELDMAP = dict[
    'employer' => 1,
    'compensation' => 2,
  ];

  const type TConstructorShape = shape(
    ?'employer' => ?Company,
    ?'compensation' => ?float,
  );

  const type TShape = shape(
    ?'employer' => ?Company,
    ?'compensation' => ?float,
  );
  const int STRUCTURAL_ID = 1922683334218183646;
  /**
   * Original thrift field:-
   * 1: constants.Company employer
   */
  public ?Company $employer;
  /**
   * Original thrift field:-
   * 2: double compensation
   */
  public ?float $compensation;

  public function __construct(?Company $employer = null, ?float $compensation = null)[] {
    $this->employer = $employer;
    $this->compensation = $compensation;
  }

  public static function withDefaultValues()[]: this {
    return new static();
  }

  public static function fromShape(self::TConstructorShape $shape)[]: this {
    return new static(
      Shapes::idx($shape, 'employer'),
      Shapes::idx($shape, 'compensation'),
    );
  }

  public static function fromMap_DEPRECATED(@KeyedContainer<string, mixed> $map)[]: this {
    return new static(
      HH\FIXME\UNSAFE_CAST<mixed, Company>(idx($map, 'employer'), 'map value is mixed'),
      HH\FIXME\UNSAFE_CAST<mixed, float>(idx($map, 'compensation'), 'map value is mixed'),
    );
  }

  public function getName()[]: string {
    return 'SWE';
  }

  public function clearTerseFields()[write_props]: void {
  }

  public static function getStructMetadata()[]: \tmeta_ThriftStruct {
    return tmeta_ThriftStruct::fromShape(
      shape(
        "name" => "constants.SWE",
        "fields" => vec[
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 1,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_enum" => tmeta_ThriftEnumType::fromShape(
                    shape(
                      "name" => "constants.Company",
                    )
                  ),
                )
              ),
              "name" => "employer",
              "is_optional" => true,
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 2,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_DOUBLE_TYPE,
                )
              ),
              "name" => "compensation",
              "is_optional" => true,
            )
          ),
        ],
        "is_union" => false,
      )
    );
  }

  public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations {
    return shape(
      'struct' => dict[],
      'fields' => dict[
      ],
    );
  }

  public static function __stringifyMapKeys<T>(dict<arraykey, T> $m)[]: dict<string, T> {
    return Dict\map_keys($m, $key ==> (string)$key);
  }

  public static function __fromShape(self::TShape $shape)[]: this {
    return new static(
      Shapes::idx($shape, 'employer'),
      Shapes::idx($shape, 'compensation'),
    );
  }

  public function __toShape()[]: self::TShape {
    return shape(
      'employer' => $this->employer,
      'compensation' => $this->compensation,
    );
  }
  public function getInstanceKey()[write_props]: string {
    return \TCompactSerializer::serialize($this);
  }

  public function readFromJson(string $jsonText): void {
    $parsed = json_decode($jsonText, true);

    if ($parsed === null || !($parsed is KeyedContainer<_, _>)) {
      throw new \TProtocolException("Cannot parse the given json string.");
    }

    if (idx($parsed, 'employer') !== null) {
      $this->employer = Company::coerce(HH\FIXME\UNSAFE_CAST<mixed, Company>($parsed['employer']));
    }
    if (idx($parsed, 'compensation') !== null) {
      $this->compensation = HH\FIXME\UNSAFE_CAST<mixed, float>($parsed['compensation']);
    }
  }

}


<?hh
/**
 * Autogenerated by Thrift
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */

namespace facebook\thrift\annotation\hack;

/**
 * Original thrift struct:-
 * FieldWrapper
 */
<<\ThriftTypeInfo(shape('uri' => 'facebook.com/thrift/annotation/hack/FieldWrapper'))>>
class FieldWrapper implements \IThriftSyncStruct, \IThriftStructMetadata, \IThriftShapishSyncStruct {
  use \ThriftSerializationTrait;

  const \ThriftStructTypes::TSpec SPEC = dict[
    1 => shape(
      'var' => 'name',
      'type' => \TType::STRING,
    ),
  ];
  const dict<string, int> FIELDMAP = dict[
    'name' => 1,
  ];

  const type TConstructorShape = shape(
    ?'name' => ?string,
  );

  const type TShape = shape(
    'name' => string,
  );
  const int STRUCTURAL_ID = 2593878277785201336;
  /**
   * Original thrift field:-
   * 1: string name
   */
  public string $name;

  public function __construct(?string $name = null)[] {
    $this->name = $name ?? '';
  }

  public static function withDefaultValues()[]: this {
    return new static();
  }

  public static function fromShape(self::TConstructorShape $shape)[]: this {
    return new static(
      Shapes::idx($shape, 'name'),
    );
  }

  public static function fromMap_DEPRECATED(@KeyedContainer<string, mixed> $map)[]: this {
    return new static(
      HH\FIXME\UNSAFE_CAST<mixed, string>(idx($map, 'name'), 'map value is mixed'),
    );
  }

  public function getName()[]: string {
    return 'FieldWrapper';
  }

  public function clearTerseFields()[write_props]: void {
  }

  public static function getStructMetadata()[]: \tmeta_ThriftStruct {
    return \tmeta_ThriftStruct::fromShape(
      shape(
        "name" => "hack.FieldWrapper",
        "fields" => vec[
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 1,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                )
              ),
              "name" => "name",
            )
          ),
        ],
        "is_union" => false,
      )
    );
  }

  public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations {
    return shape(
      'struct' => dict[
        '\facebook\thrift\annotation\Field' => \facebook\thrift\annotation\Field::fromShape(
          shape(
          )
        ),
      ],
      'fields' => dict[
      ],
    );
  }

  public static function __stringifyMapKeys<T>(dict<arraykey, T> $m)[]: dict<string, T> {
    return Dict\map_keys($m, $key ==> (string)$key);
  }

  public static function __fromShape(self::TShape $shape)[]: this {
    return new static(
      $shape['name'],
    );
  }

  public function __toShape()[]: self::TShape {
    return shape(
      'name' => $this->name,
    );
  }
  public function getInstanceKey()[write_props]: string {
    return \TCompactSerializer::serialize($this);
  }

  public function readFromJson(string $jsonText): void {
    $parsed = json_decode($jsonText, true);

    if ($parsed === null || !($parsed is KeyedContainer<_, _>)) {
      throw new \TProtocolException("Cannot parse the given json string.");
    }

    if (idx($parsed, 'name') !== null) {
      $this->name = HH\FIXME\UNSAFE_CAST<mixed, string>($parsed['name']);
    }
  }

}

/**
 * Original thrift struct:-
 * Wrapper
 */
<<\ThriftTypeInfo(shape('uri' => 'facebook.com/thrift/annotation/hack/Wrapper'))>>
class Wrapper implements \IThriftSyncStruct, \IThriftStructMetadata, \IThriftShapishSyncStruct {
  use \ThriftSerializationTrait;

  const \ThriftStructTypes::TSpec SPEC = dict[
    1 => shape(
      'var' => 'name',
      'type' => \TType::STRING,
    ),
    2 => shape(
      'var' => 'underlyingName',
      'type' => \TType::STRING,
    ),
    3 => shape(
      'var' => 'extraNamespace',
      'type' => \TType::STRING,
    ),
  ];
  const dict<string, int> FIELDMAP = dict[
    'name' => 1,
    'underlyingName' => 2,
    'extraNamespace' => 3,
  ];

  const type TConstructorShape = shape(
    ?'name' => ?string,
    ?'underlyingName' => ?string,
    ?'extraNamespace' => ?string,
  );

  const type TShape = shape(
    'name' => string,
    'underlyingName' => string,
    'extraNamespace' => string,
  );
  const int STRUCTURAL_ID = 1284986773698322040;
  /**
   * Original thrift field:-
   * 1: string name
   */
  public string $name;
  /**
   * Original thrift field:-
   * 2: string underlyingName
   */
  public string $underlyingName;
  /**
   * Original thrift field:-
   * 3: string extraNamespace
   */
  public string $extraNamespace;

  public function __construct(?string $name = null, ?string $underlyingName = null, ?string $extraNamespace = null)[] {
    $this->name = $name ?? '';
    $this->underlyingName = $underlyingName ?? '';
    $this->extraNamespace = $extraNamespace ?? "thrift_adapted_types";
  }

  public static function withDefaultValues()[]: this {
    return new static();
  }

  public static function fromShape(self::TConstructorShape $shape)[]: this {
    return new static(
      Shapes::idx($shape, 'name'),
      Shapes::idx($shape, 'underlyingName'),
      Shapes::idx($shape, 'extraNamespace'),
    );
  }

  public static function fromMap_DEPRECATED(@KeyedContainer<string, mixed> $map)[]: this {
    return new static(
      HH\FIXME\UNSAFE_CAST<mixed, string>(idx($map, 'name'), 'map value is mixed'),
      HH\FIXME\UNSAFE_CAST<mixed, string>(idx($map, 'underlyingName'), 'map value is mixed'),
      HH\FIXME\UNSAFE_CAST<mixed, string>(idx($map, 'extraNamespace'), 'map value is mixed'),
    );
  }

  public function getName()[]: string {
    return 'Wrapper';
  }

  public function clearTerseFields()[write_props]: void {
  }

  public static function getStructMetadata()[]: \tmeta_ThriftStruct {
    return \tmeta_ThriftStruct::fromShape(
      shape(
        "name" => "hack.Wrapper",
        "fields" => vec[
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 1,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                )
              ),
              "name" => "name",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 2,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                )
              ),
              "name" => "underlyingName",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 3,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                )
              ),
              "name" => "extraNamespace",
            )
          ),
        ],
        "is_union" => false,
      )
    );
  }

  public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations {
    return shape(
      'struct' => dict[
        '\facebook\thrift\annotation\Typedef' => \facebook\thrift\annotation\Typedef::fromShape(
          shape(
          )
        ),
        '\facebook\thrift\annotation\Struct' => \facebook\thrift\annotation\Struct::fromShape(
          shape(
          )
        ),
        '\facebook\thrift\annotation\Field' => \facebook\thrift\annotation\Field::fromShape(
          shape(
          )
        ),
      ],
      'fields' => dict[
      ],
    );
  }

  public static function __stringifyMapKeys<T>(dict<arraykey, T> $m)[]: dict<string, T> {
    return Dict\map_keys($m, $key ==> (string)$key);
  }

  public static function __fromShape(self::TShape $shape)[]: this {
    return new static(
      $shape['name'],
      $shape['underlyingName'],
      $shape['extraNamespace'],
    );
  }

  public function __toShape()[]: self::TShape {
    return shape(
      'name' => $this->name,
      'underlyingName' => $this->underlyingName,
      'extraNamespace' => $this->extraNamespace,
    );
  }
  public function getInstanceKey()[write_props]: string {
    return \TCompactSerializer::serialize($this);
  }

  public function readFromJson(string $jsonText): void {
    $parsed = json_decode($jsonText, true);

    if ($parsed === null || !($parsed is KeyedContainer<_, _>)) {
      throw new \TProtocolException("Cannot parse the given json string.");
    }

    if (idx($parsed, 'name') !== null) {
      $this->name = HH\FIXME\UNSAFE_CAST<mixed, string>($parsed['name']);
    }
    if (idx($parsed, 'underlyingName') !== null) {
      $this->underlyingName = HH\FIXME\UNSAFE_CAST<mixed, string>($parsed['underlyingName']);
    }
    if (idx($parsed, 'extraNamespace') !== null) {
      $this->extraNamespace = HH\FIXME\UNSAFE_CAST<mixed, string>($parsed['extraNamespace']);
    }
  }

}

/**
 * Original thrift struct:-
 * Adapter
 */
<<\ThriftTypeInfo(shape('uri' => 'facebook.com/thrift/annotation/hack/Adapter'))>>
class Adapter implements \IThriftSyncStruct, \IThriftStructMetadata, \IThriftShapishSyncStruct {
  use \ThriftSerializationTrait;

  const \ThriftStructTypes::TSpec SPEC = dict[
    1 => shape(
      'var' => 'name',
      'type' => \TType::STRING,
    ),
  ];
  const dict<string, int> FIELDMAP = dict[
    'name' => 1,
  ];

  const type TConstructorShape = shape(
    ?'name' => ?string,
  );

  const type TShape = shape(
    'name' => string,
  );
  const int STRUCTURAL_ID = 2593878277785201336;
  /**
   * Original thrift field:-
   * 1: string name
   */
  public string $name;

  public function __construct(?string $name = null)[] {
    $this->name = $name ?? '';
  }

  public static function withDefaultValues()[]: this {
    return new static();
  }

  public static function fromShape(self::TConstructorShape $shape)[]: this {
    return new static(
      Shapes::idx($shape, 'name'),
    );
  }

  public static function fromMap_DEPRECATED(@KeyedContainer<string, mixed> $map)[]: this {
    return new static(
      HH\FIXME\UNSAFE_CAST<mixed, string>(idx($map, 'name'), 'map value is mixed'),
    );
  }

  public function getName()[]: string {
    return 'Adapter';
  }

  public function clearTerseFields()[write_props]: void {
  }

  public static function getStructMetadata()[]: \tmeta_ThriftStruct {
    return \tmeta_ThriftStruct::fromShape(
      shape(
        "name" => "hack.Adapter",
        "fields" => vec[
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 1,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                )
              ),
              "name" => "name",
            )
          ),
        ],
        "is_union" => false,
      )
    );
  }

  public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations {
    return shape(
      'struct' => dict[
        '\facebook\thrift\annotation\Typedef' => \facebook\thrift\annotation\Typedef::fromShape(
          shape(
          )
        ),
        '\facebook\thrift\annotation\Field' => \facebook\thrift\annotation\Field::fromShape(
          shape(
          )
        ),
      ],
      'fields' => dict[
      ],
    );
  }

  public static function __stringifyMapKeys<T>(dict<arraykey, T> $m)[]: dict<string, T> {
    return Dict\map_keys($m, $key ==> (string)$key);
  }

  public static function __fromShape(self::TShape $shape)[]: this {
    return new static(
      $shape['name'],
    );
  }

  public function __toShape()[]: self::TShape {
    return shape(
      'name' => $this->name,
    );
  }
  public function getInstanceKey()[write_props]: string {
    return \TCompactSerializer::serialize($this);
  }

  public function readFromJson(string $jsonText): void {
    $parsed = json_decode($jsonText, true);

    if ($parsed === null || !($parsed is KeyedContainer<_, _>)) {
      throw new \TProtocolException("Cannot parse the given json string.");
    }

    if (idx($parsed, 'name') !== null) {
      $this->name = HH\FIXME\UNSAFE_CAST<mixed, string>($parsed['name']);
    }
  }

}

/**
 * Original thrift struct:-
 * SkipCodegen
 */
<<\ThriftTypeInfo(shape('uri' => 'facebook.com/thrift/annotation/hack/SkipCodegen'))>>
class SkipCodegen implements \IThriftSyncStruct, \IThriftStructMetadata, \IThriftShapishSyncStruct {
  use \ThriftSerializationTrait;

  const \ThriftStructTypes::TSpec SPEC = dict[
    1 => shape(
      'var' => 'reason',
      'type' => \TType::STRING,
    ),
  ];
  const dict<string, int> FIELDMAP = dict[
    'reason' => 1,
  ];

  const type TConstructorShape = shape(
    ?'reason' => ?string,
  );

  const type TShape = shape(
    'reason' => string,
  );
  const int STRUCTURAL_ID = 3707764047816594739;
  /**
   * Original thrift field:-
   * 1: string reason
   */
  public string $reason;

  public function __construct(?string $reason = null)[] {
    $this->reason = $reason ?? '';
  }

  public static function withDefaultValues()[]: this {
    return new static();
  }

  public static function fromShape(self::TConstructorShape $shape)[]: this {
    return new static(
      Shapes::idx($shape, 'reason'),
    );
  }

  public static function fromMap_DEPRECATED(@KeyedContainer<string, mixed> $map)[]: this {
    return new static(
      HH\FIXME\UNSAFE_CAST<mixed, string>(idx($map, 'reason'), 'map value is mixed'),
    );
  }

  public function getName()[]: string {
    return 'SkipCodegen';
  }

  public function clearTerseFields()[write_props]: void {
  }

  public static function getStructMetadata()[]: \tmeta_ThriftStruct {
    return \tmeta_ThriftStruct::fromShape(
      shape(
        "name" => "hack.SkipCodegen",
        "fields" => vec[
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 1,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                )
              ),
              "name" => "reason",
            )
          ),
        ],
        "is_union" => false,
      )
    );
  }

  public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations {
    return shape(
      'struct' => dict[
        '\facebook\thrift\annotation\Typedef' => \facebook\thrift\annotation\Typedef::fromShape(
          shape(
          )
        ),
        '\facebook\thrift\annotation\Field' => \facebook\thrift\annotation\Field::fromShape(
          shape(
          )
        ),
        '\facebook\thrift\annotation\TFunction' => \facebook\thrift\annotation\TFunction::fromShape(
          shape(
          )
        ),
      ],
      'fields' => dict[
      ],
    );
  }

  public static function __stringifyMapKeys<T>(dict<arraykey, T> $m)[]: dict<string, T> {
    return Dict\map_keys($m, $key ==> (string)$key);
  }

  public static function __fromShape(self::TShape $shape)[]: this {
    return new static(
      $shape['reason'],
    );
  }

  public function __toShape()[]: self::TShape {
    return shape(
      'reason' => $this->reason,
    );
  }
  public function getInstanceKey()[write_props]: string {
    return \TCompactSerializer::serialize($this);
  }

  public function readFromJson(string $jsonText): void {
    $parsed = json_decode($jsonText, true);

    if ($parsed === null || !($parsed is KeyedContainer<_, _>)) {
      throw new \TProtocolException("Cannot parse the given json string.");
    }

    if (idx($parsed, 'reason') !== null) {
      $this->reason = HH\FIXME\UNSAFE_CAST<mixed, string>($parsed['reason']);
    }
  }

}

/**
 * Original thrift struct:-
 * Name
 */
<<\ThriftTypeInfo(shape('uri' => 'facebook.com/thrift/annotation/hack/Name'))>>
class Name implements \IThriftSyncStruct, \IThriftStructMetadata, \IThriftShapishSyncStruct {
  use \ThriftSerializationTrait;

  const \ThriftStructTypes::TSpec SPEC = dict[
    1 => shape(
      'var' => 'name',
      'type' => \TType::STRING,
    ),
    2 => shape(
      'var' => 'reason',
      'type' => \TType::STRING,
    ),
  ];
  const dict<string, int> FIELDMAP = dict[
    'name' => 1,
    'reason' => 2,
  ];

  const type TConstructorShape = shape(
    ?'name' => ?string,
    ?'reason' => ?string,
  );

  const type TShape = shape(
    'name' => string,
    'reason' => string,
  );
  const int STRUCTURAL_ID = 4844827548325959202;
  /**
   * Original thrift field:-
   * 1: string name
   */
  public string $name;
  /**
   * Original thrift field:-
   * 2: string reason
   */
  public string $reason;

  public function __construct(?string $name = null, ?string $reason = null)[] {
    $this->name = $name ?? '';
    $this->reason = $reason ?? '';
  }

  public static function withDefaultValues()[]: this {
    return new static();
  }

  public static function fromShape(self::TConstructorShape $shape)[]: this {
    return new static(
      Shapes::idx($shape, 'name'),
      Shapes::idx($shape, 'reason'),
    );
  }

  public static function fromMap_DEPRECATED(@KeyedContainer<string, mixed> $map)[]: this {
    return new static(
      HH\FIXME\UNSAFE_CAST<mixed, string>(idx($map, 'name'), 'map value is mixed'),
      HH\FIXME\UNSAFE_CAST<mixed, string>(idx($map, 'reason'), 'map value is mixed'),
    );
  }

  public function getName()[]: string {
    return 'Name';
  }

  public function clearTerseFields()[write_props]: void {
  }

  public static function getStructMetadata()[]: \tmeta_ThriftStruct {
    return \tmeta_ThriftStruct::fromShape(
      shape(
        "name" => "hack.Name",
        "fields" => vec[
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 1,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                )
              ),
              "name" => "name",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 2,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                )
              ),
              "name" => "reason",
            )
          ),
        ],
        "is_union" => false,
      )
    );
  }

  public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations {
    return shape(
      'struct' => dict[],
      'fields' => dict[
      ],
    );
  }

  public static function __stringifyMapKeys<T>(dict<arraykey, T> $m)[]: dict<string, T> {
    return Dict\map_keys($m, $key ==> (string)$key);
  }

  public static function __fromShape(self::TShape $shape)[]: this {
    return new static(
      $shape['name'],
      $shape['reason'],
    );
  }

  public function __toShape()[]: self::TShape {
    return shape(
      'name' => $this->name,
      'reason' => $this->reason,
    );
  }
  public function getInstanceKey()[write_props]: string {
    return \TCompactSerializer::serialize($this);
  }

  public function readFromJson(string $jsonText): void {
    $parsed = json_decode($jsonText, true);

    if ($parsed === null || !($parsed is KeyedContainer<_, _>)) {
      throw new \TProtocolException("Cannot parse the given json string.");
    }

    if (idx($parsed, 'name') !== null) {
      $this->name = HH\FIXME\UNSAFE_CAST<mixed, string>($parsed['name']);
    }
    if (idx($parsed, 'reason') !== null) {
      $this->reason = HH\FIXME\UNSAFE_CAST<mixed, string>($parsed['reason']);
    }
  }

}

/**
 * Original thrift struct:-
 * UnionEnumAttributes
 */
<<\ThriftTypeInfo(shape('uri' => 'facebook.com/thrift/annotation/hack/UnionEnumAttributes'))>>
class UnionEnumAttributes implements \IThriftSyncStruct, \IThriftStructMetadata, \IThriftShapishSyncStruct {
  use \ThriftSerializationTrait;

  const \ThriftStructTypes::TSpec SPEC = dict[
    1 => shape(
      'var' => 'attributes',
      'type' => \TType::LST,
      'etype' => \TType::STRING,
      'elem' => shape(
        'type' => \TType::STRING,
      ),
      'format' => 'harray',
    ),
  ];
  const dict<string, int> FIELDMAP = dict[
    'attributes' => 1,
  ];

  const type TConstructorShape = shape(
    ?'attributes' => ?vec<string>,
  );

  const type TShape = shape(
    'attributes' => vec<string>,
  );
  const int STRUCTURAL_ID = 4379867690114498379;
  /**
   * Original thrift field:-
   * 1: list<string> attributes
   */
  public vec<string> $attributes;

  public function __construct(?vec<string> $attributes = null)[] {
    $this->attributes = $attributes ?? vec[];
  }

  public static function withDefaultValues()[]: this {
    return new static();
  }

  public static function fromShape(self::TConstructorShape $shape)[]: this {
    return new static(
      Shapes::idx($shape, 'attributes'),
    );
  }

  public static function fromMap_DEPRECATED(@KeyedContainer<string, mixed> $map)[]: this {
    return new static(
      HH\FIXME\UNSAFE_CAST<mixed, vec<string>>(idx($map, 'attributes'), 'map value is mixed'),
    );
  }

  public function getName()[]: string {
    return 'UnionEnumAttributes';
  }

  public function clearTerseFields()[write_props]: void {
  }

  public static function getStructMetadata()[]: \tmeta_ThriftStruct {
    return \tmeta_ThriftStruct::fromShape(
      shape(
        "name" => "hack.UnionEnumAttributes",
        "fields" => vec[
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 1,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_list" => \tmeta_ThriftListType::fromShape(
                    shape(
                      "valueType" => \tmeta_ThriftType::fromShape(
                        shape(
                          "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "attributes",
            )
          ),
        ],
        "is_union" => false,
      )
    );
  }

  public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations {
    return shape(
      'struct' => dict[
        '\facebook\thrift\annotation\Union' => \facebook\thrift\annotation\Union::fromShape(
          shape(
          )
        ),
      ],
      'fields' => dict[
      ],
    );
  }

  public static function __stringifyMapKeys<T>(dict<arraykey, T> $m)[]: dict<string, T> {
    return Dict\map_keys($m, $key ==> (string)$key);
  }

  public static function __fromShape(self::TShape $shape)[]: this {
    return new static(
      $shape['attributes'],
    );
  }

  public function __toShape()[]: self::TShape {
    return shape(
      'attributes' => $this->attributes,
    );
  }
  public function getInstanceKey()[write_props]: string {
    return \TCompactSerializer::serialize($this);
  }

  public function readFromJson(string $jsonText): void {
    $parsed = json_decode($jsonText, true);

    if ($parsed === null || !($parsed is KeyedContainer<_, _>)) {
      throw new \TProtocolException("Cannot parse the given json string.");
    }

    if (idx($parsed, 'attributes') !== null) {
      $_json3 = HH\FIXME\UNSAFE_CAST<mixed, vec<string>>($parsed['attributes']);
      $_container4 = vec[];
      foreach($_json3 as $_key1 => $_value2) {
        $_elem5 = '';
        $_elem5 = $_value2;
        $_container4 []= $_elem5;
      }
      $this->attributes = $_container4;
    }
  }

}

/**
 * Original thrift struct:-
 * StructTrait
 */
<<\ThriftTypeInfo(shape('uri' => 'facebook.com/thrift/annotation/hack/StructTrait'))>>
class StructTrait implements \IThriftSyncStruct, \IThriftStructMetadata, \IThriftShapishSyncStruct {
  use \ThriftSerializationTrait;

  const \ThriftStructTypes::TSpec SPEC = dict[
    1 => shape(
      'var' => 'name',
      'type' => \TType::STRING,
    ),
  ];
  const dict<string, int> FIELDMAP = dict[
    'name' => 1,
  ];

  const type TConstructorShape = shape(
    ?'name' => ?string,
  );

  const type TShape = shape(
    'name' => string,
  );
  const int STRUCTURAL_ID = 2593878277785201336;
  /**
   * Original thrift field:-
   * 1: string name
   */
  public string $name;

  public function __construct(?string $name = null)[] {
    $this->name = $name ?? '';
  }

  public static function withDefaultValues()[]: this {
    return new static();
  }

  public static function fromShape(self::TConstructorShape $shape)[]: this {
    return new static(
      Shapes::idx($shape, 'name'),
    );
  }

  public static function fromMap_DEPRECATED(@KeyedContainer<string, mixed> $map)[]: this {
    return new static(
      HH\FIXME\UNSAFE_CAST<mixed, string>(idx($map, 'name'), 'map value is mixed'),
    );
  }

  public function getName()[]: string {
    return 'StructTrait';
  }

  public function clearTerseFields()[write_props]: void {
  }

  public static function getStructMetadata()[]: \tmeta_ThriftStruct {
    return \tmeta_ThriftStruct::fromShape(
      shape(
        "name" => "hack.StructTrait",
        "fields" => vec[
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 1,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                )
              ),
              "name" => "name",
            )
          ),
        ],
        "is_union" => false,
      )
    );
  }

  public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations {
    return shape(
      'struct' => dict[
        '\facebook\thrift\annotation\Struct' => \facebook\thrift\annotation\Struct::fromShape(
          shape(
          )
        ),
        '\facebook\thrift\annotation\Union' => \facebook\thrift\annotation\Union::fromShape(
          shape(
          )
        ),
        '\facebook\thrift\annotation\Exception' => \facebook\thrift\annotation\Exception::fromShape(
          shape(
          )
        ),
      ],
      'fields' => dict[
      ],
    );
  }

  public static function __stringifyMapKeys<T>(dict<arraykey, T> $m)[]: dict<string, T> {
    return Dict\map_keys($m, $key ==> (string)$key);
  }

  public static function __fromShape(self::TShape $shape)[]: this {
    return new static(
      $shape['name'],
    );
  }

  public function __toShape()[]: self::TShape {
    return shape(
      'name' => $this->name,
    );
  }
  public function getInstanceKey()[write_props]: string {
    return \TCompactSerializer::serialize($this);
  }

  public function readFromJson(string $jsonText): void {
    $parsed = json_decode($jsonText, true);

    if ($parsed === null || !($parsed is KeyedContainer<_, _>)) {
      throw new \TProtocolException("Cannot parse the given json string.");
    }

    if (idx($parsed, 'name') !== null) {
      $this->name = HH\FIXME\UNSAFE_CAST<mixed, string>($parsed['name']);
    }
  }

}

/**
 * Original thrift struct:-
 * Attributes
 */
<<\ThriftTypeInfo(shape('uri' => 'facebook.com/thrift/annotation/hack/Attributes'))>>
class Attributes implements \IThriftSyncStruct, \IThriftStructMetadata, \IThriftShapishSyncStruct {
  use \ThriftSerializationTrait;

  const \ThriftStructTypes::TSpec SPEC = dict[
    1 => shape(
      'var' => 'attributes',
      'type' => \TType::LST,
      'etype' => \TType::STRING,
      'elem' => shape(
        'type' => \TType::STRING,
      ),
      'format' => 'harray',
    ),
  ];
  const dict<string, int> FIELDMAP = dict[
    'attributes' => 1,
  ];

  const type TConstructorShape = shape(
    ?'attributes' => ?vec<string>,
  );

  const type TShape = shape(
    'attributes' => vec<string>,
  );
  const int STRUCTURAL_ID = 4379867690114498379;
  /**
   * Original thrift field:-
   * 1: list<string> attributes
   */
  public vec<string> $attributes;

  public function __construct(?vec<string> $attributes = null)[] {
    $this->attributes = $attributes ?? vec[];
  }

  public static function withDefaultValues()[]: this {
    return new static();
  }

  public static function fromShape(self::TConstructorShape $shape)[]: this {
    return new static(
      Shapes::idx($shape, 'attributes'),
    );
  }

  public static function fromMap_DEPRECATED(@KeyedContainer<string, mixed> $map)[]: this {
    return new static(
      HH\FIXME\UNSAFE_CAST<mixed, vec<string>>(idx($map, 'attributes'), 'map value is mixed'),
    );
  }

  public function getName()[]: string {
    return 'Attributes';
  }

  public function clearTerseFields()[write_props]: void {
  }

  public static function getStructMetadata()[]: \tmeta_ThriftStruct {
    return \tmeta_ThriftStruct::fromShape(
      shape(
        "name" => "hack.Attributes",
        "fields" => vec[
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 1,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_list" => \tmeta_ThriftListType::fromShape(
                    shape(
                      "valueType" => \tmeta_ThriftType::fromShape(
                        shape(
                          "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "attributes",
            )
          ),
        ],
        "is_union" => false,
      )
    );
  }

  public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations {
    return shape(
      'struct' => dict[],
      'fields' => dict[
      ],
    );
  }

  public static function __stringifyMapKeys<T>(dict<arraykey, T> $m)[]: dict<string, T> {
    return Dict\map_keys($m, $key ==> (string)$key);
  }

  public static function __fromShape(self::TShape $shape)[]: this {
    return new static(
      $shape['attributes'],
    );
  }

  public function __toShape()[]: self::TShape {
    return shape(
      'attributes' => $this->attributes,
    );
  }
  public function getInstanceKey()[write_props]: string {
    return \TCompactSerializer::serialize($this);
  }

  public function readFromJson(string $jsonText): void {
    $parsed = json_decode($jsonText, true);

    if ($parsed === null || !($parsed is KeyedContainer<_, _>)) {
      throw new \TProtocolException("Cannot parse the given json string.");
    }

    if (idx($parsed, 'attributes') !== null) {
      $_json3 = HH\FIXME\UNSAFE_CAST<mixed, vec<string>>($parsed['attributes']);
      $_container4 = vec[];
      foreach($_json3 as $_key1 => $_value2) {
        $_elem5 = '';
        $_elem5 = $_value2;
        $_container4 []= $_elem5;
      }
      $this->attributes = $_container4;
    }
  }

}

/**
 * Original thrift struct:-
 * StructAsTrait
 */
<<\ThriftTypeInfo(shape('uri' => 'facebook.com/thrift/annotation/hack/StructAsTrait'))>>
class StructAsTrait implements \IThriftSyncStruct, \IThriftStructMetadata, \IThriftShapishSyncStruct {
  use \ThriftSerializationTrait;

  const \ThriftStructTypes::TSpec SPEC = dict[
  ];
  const dict<string, int> FIELDMAP = dict[
  ];

  const type TConstructorShape = shape(
  );

  const type TShape = shape(
  );
  const int STRUCTURAL_ID = 957977401221134810;

  public function __construct()[] {
  }

  public static function withDefaultValues()[]: this {
    return new static();
  }

  public static function fromShape(self::TConstructorShape $shape)[]: this {
    return new static(
    );
  }

  public static function fromMap_DEPRECATED(@KeyedContainer<string, mixed> $map)[]: this {
    return new static(
    );
  }

  public function getName()[]: string {
    return 'StructAsTrait';
  }

  public function clearTerseFields()[write_props]: void {
  }

  public static function getStructMetadata()[]: \tmeta_ThriftStruct {
    return \tmeta_ThriftStruct::fromShape(
      shape(
        "name" => "hack.StructAsTrait",
        "is_union" => false,
      )
    );
  }

  public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations {
    return shape(
      'struct' => dict[
        '\facebook\thrift\annotation\Struct' => \facebook\thrift\annotation\Struct::fromShape(
          shape(
          )
        ),
        '\facebook\thrift\annotation\Union' => \facebook\thrift\annotation\Union::fromShape(
          shape(
          )
        ),
        '\facebook\thrift\annotation\Exception' => \facebook\thrift\annotation\Exception::fromShape(
          shape(
          )
        ),
      ],
      'fields' => dict[
      ],
    );
  }

  public static function __stringifyMapKeys<T>(dict<arraykey, T> $m)[]: dict<string, T> {
    return Dict\map_keys($m, $key ==> (string)$key);
  }

  public static function __fromShape(self::TShape $shape)[]: this {
    return new static(
    );
  }

  public function __toShape()[]: self::TShape {
    return shape(
    );
  }
  public function getInstanceKey()[write_props]: string {
    return \TCompactSerializer::serialize($this);
  }

  public function readFromJson(string $jsonText): void {
    $parsed = json_decode($jsonText, true);

    if ($parsed === null || !($parsed is KeyedContainer<_, _>)) {
      throw new \TProtocolException("Cannot parse the given json string.");
    }

  }

}

/**
 * Original thrift struct:-
 * ModuleInternal
 */
<<\ThriftTypeInfo(shape('uri' => 'facebook.com/thrift/annotation/hack/ModuleInternal'))>>
class ModuleInternal implements \IThriftSyncStruct, \IThriftStructMetadata, \IThriftShapishSyncStruct {
  use \ThriftSerializationTrait;

  const \ThriftStructTypes::TSpec SPEC = dict[
  ];
  const dict<string, int> FIELDMAP = dict[
  ];

  const type TConstructorShape = shape(
  );

  const type TShape = shape(
  );
  const int STRUCTURAL_ID = 957977401221134810;

  public function __construct()[] {
  }

  public static function withDefaultValues()[]: this {
    return new static();
  }

  public static function fromShape(self::TConstructorShape $shape)[]: this {
    return new static(
    );
  }

  public static function fromMap_DEPRECATED(@KeyedContainer<string, mixed> $map)[]: this {
    return new static(
    );
  }

  public function getName()[]: string {
    return 'ModuleInternal';
  }

  public function clearTerseFields()[write_props]: void {
  }

  public static function getStructMetadata()[]: \tmeta_ThriftStruct {
    return \tmeta_ThriftStruct::fromShape(
      shape(
        "name" => "hack.ModuleInternal",
        "is_union" => false,
      )
    );
  }

  public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations {
    return shape(
      'struct' => dict[
        '\facebook\thrift\annotation\Struct' => \facebook\thrift\annotation\Struct::fromShape(
          shape(
          )
        ),
        '\facebook\thrift\annotation\Union' => \facebook\thrift\annotation\Union::fromShape(
          shape(
          )
        ),
        '\facebook\thrift\annotation\Enum' => \facebook\thrift\annotation\Enum::fromShape(
          shape(
          )
        ),
        '\facebook\thrift\annotation\Field' => \facebook\thrift\annotation\Field::fromShape(
          shape(
          )
        ),
        '\facebook\thrift\annotation\Typedef' => \facebook\thrift\annotation\Typedef::fromShape(
          shape(
          )
        ),
        '\facebook\thrift\annotation\TFunction' => \facebook\thrift\annotation\TFunction::fromShape(
          shape(
          )
        ),
        '\facebook\thrift\annotation\Service' => \facebook\thrift\annotation\Service::fromShape(
          shape(
          )
        ),
      ],
      'fields' => dict[
      ],
    );
  }

  public static function __stringifyMapKeys<T>(dict<arraykey, T> $m)[]: dict<string, T> {
    return Dict\map_keys($m, $key ==> (string)$key);
  }

  public static function __fromShape(self::TShape $shape)[]: this {
    return new static(
    );
  }

  public function __toShape()[]: self::TShape {
    return shape(
    );
  }
  public function getInstanceKey()[write_props]: string {
    return \TCompactSerializer::serialize($this);
  }

  public function readFromJson(string $jsonText): void {
    $parsed = json_decode($jsonText, true);

    if ($parsed === null || !($parsed is KeyedContainer<_, _>)) {
      throw new \TProtocolException("Cannot parse the given json string.");
    }

  }

}


<?hh
/**
 * Autogenerated by Thrift
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */

namespace detail {
type i64WithWrapper = int;
}
namespace thrift_adapted_types {

  /**
   * Original thrift struct:-
   * StructWithWrapper
   */
class StructWithWrapper implements \IThriftSyncStruct, \IThriftStructMetadata, \IThriftShapishSyncStruct {
    use \ThriftSerializationTrait;

    const \ThriftStructTypes::TSpec SPEC = dict[
      1 => shape(
        'var' => 'int_field',
        'type' => \TType::I64,
      ),
    ];
    const dict<string, int> FIELDMAP = dict[
      'int_field' => 1,
    ];

    const type TConstructorShape = shape(
      ?'int_field' => ?int,
    );

    const type TShape = shape(
      'int_field' => int,
    );
    const int STRUCTURAL_ID = 8549930382776002541;
    /**
     * Original thrift field:-
     * 1: i64 int_field
     */
    public int $int_field;

    public function __construct(?int $int_field = null)[] {
      $this->int_field = $int_field ?? 0;
    }

    public static function withDefaultValues()[]: this {
      return new static();
    }

    public static function fromShape(self::TConstructorShape $shape)[]: this {
      return new static(
        Shapes::idx($shape, 'int_field'),
      );
    }

    public static function fromMap_DEPRECATED(@KeyedContainer<string, mixed> $map)[]: this {
      return new static(
        HH\FIXME\UNSAFE_CAST<mixed, int>(idx($map, 'int_field'), 'map value is mixed'),
      );
    }

    public function getName()[]: string {
      return 'StructWithWrapper';
    }

    public function clearTerseFields()[write_props]: void {
    }

    public static function getStructMetadata()[]: \tmeta_ThriftStruct {
      return \tmeta_ThriftStruct::fromShape(
        shape(
          "name" => "include.StructWithWrapper",
          "fields" => vec[
            \tmeta_ThriftField::fromShape(
              shape(
                "id" => 1,
                "type" => \tmeta_ThriftType::fromShape(
                  shape(
                    "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I64_TYPE,
                  )
                ),
                "name" => "int_field",
              )
            ),
          ],
          "is_union" => false,
        )
      );
    }

    public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations {
      return shape(
        'struct' => dict[
          '\facebook\thrift\annotation\hack\Wrapper' => \facebook\thrift\annotation\hack\Wrapper::fromShape(
            shape(
              "name" => "\\MyStructWrapper",
            )
          ),
        ],
        'fields' => dict[
        ],
      );
    }

    public static function __stringifyMapKeys<T>(dict<arraykey, T> $m)[]: dict<string, T> {
      return Dict\map_keys($m, $key ==> (string)$key);
    }

    public static function __fromShape(self::TShape $shape)[]: this {
      return new static(
        $shape['int_field'],
      );
    }

    public function __toShape()[]: self::TShape {
      return shape(
        'int_field' => $this->int_field,
      );
    }
    public function getInstanceKey()[write_props]: string {
      return \TCompactSerializer::serialize($this);
    }

    public function readFromJson(string $jsonText): void {
      $parsed = json_decode($jsonText, true);

      if ($parsed === null || !($parsed is KeyedContainer<_, _>)) {
        throw new \TProtocolException("Cannot parse the given json string.");
      }

      if (idx($parsed, 'int_field') !== null) {
        $this->int_field = HH\FIXME\UNSAFE_CAST<mixed, int>($parsed['int_field']);
      }
    }

  }

}