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

namespace facebook\thrift\test\terse_write;

/**
 * Original thrift enum:-
 * MyEnum
 */
<<\ThriftTypeInfo(shape('uri' => 'facebook.com/thrift/test/terse_write/MyEnum'))>>
enum MyEnum: int {
  ME0 = 0;
  ME1 = 1;
}

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

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

/**
 * Original thrift struct:-
 * MyStruct
 */
<<\ThriftTypeInfo(shape('uri' => 'facebook.com/thrift/test/terse_write/MyStruct'))>>
class MyStruct 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 function getName()[]: string {
    return 'MyStruct';
  }

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

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

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

  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.");
    }

  }

}

enum MyUnionEnum: int {
  _EMPTY_ = 0;
  bool_field = 1;
  byte_field = 2;
  short_field = 3;
  int_field = 4;
  long_field = 5;
  float_field = 6;
  double_field = 7;
  string_field = 8;
  binary_field = 9;
  enum_field = 10;
  list_field = 11;
  set_field = 12;
  map_field = 13;
  struct_field = 14;
}

/**
 * Original thrift struct:-
 * MyUnion
 */
<<\ThriftTypeInfo(shape('uri' => 'facebook.com/thrift/test/terse_write/MyUnion'))>>
class MyUnion implements \IThriftSyncStruct, \IThriftStructMetadata, \IThriftUnion<\facebook\thrift\test\terse_write\MyUnionEnum>, \IThriftShapishSyncStruct {
  use \ThriftUnionSerializationTrait;

  const \ThriftStructTypes::TSpec SPEC = dict[
    1 => shape(
      'var' => 'bool_field',
      'union' => true,
      'type' => \TType::BOOL,
    ),
    2 => shape(
      'var' => 'byte_field',
      'union' => true,
      'type' => \TType::BYTE,
    ),
    3 => shape(
      'var' => 'short_field',
      'union' => true,
      'type' => \TType::I16,
    ),
    4 => shape(
      'var' => 'int_field',
      'union' => true,
      'type' => \TType::I32,
    ),
    5 => shape(
      'var' => 'long_field',
      'union' => true,
      'type' => \TType::I64,
    ),
    6 => shape(
      'var' => 'float_field',
      'union' => true,
      'type' => \TType::FLOAT,
    ),
    7 => shape(
      'var' => 'double_field',
      'union' => true,
      'type' => \TType::DOUBLE,
    ),
    8 => shape(
      'var' => 'string_field',
      'union' => true,
      'type' => \TType::STRING,
    ),
    9 => shape(
      'var' => 'binary_field',
      'union' => true,
      'type' => \TType::STRING,
      'is_binary' => true,
    ),
    10 => shape(
      'var' => 'enum_field',
      'union' => true,
      'type' => \TType::I32,
      'enum' => \facebook\thrift\test\terse_write\MyEnum::class,
    ),
    11 => shape(
      'var' => 'list_field',
      'union' => true,
      'type' => \TType::LST,
      'etype' => \TType::I16,
      'elem' => shape(
        'type' => \TType::I16,
      ),
      'format' => 'collection',
    ),
    12 => shape(
      'var' => 'set_field',
      'union' => true,
      'type' => \TType::SET,
      'etype' => \TType::I16,
      'elem' => shape(
        'type' => \TType::I16,
      ),
      'format' => 'collection',
    ),
    13 => shape(
      'var' => 'map_field',
      'union' => true,
      'type' => \TType::MAP,
      'ktype' => \TType::I16,
      'vtype' => \TType::I16,
      'key' => shape(
        'type' => \TType::I16,
      ),
      'val' => shape(
        'type' => \TType::I16,
      ),
      'format' => 'collection',
    ),
    14 => shape(
      'var' => 'struct_field',
      'union' => true,
      'type' => \TType::STRUCT,
      'class' => \facebook\thrift\test\terse_write\MyStruct::class,
    ),
  ];
  const dict<string, int> FIELDMAP = dict[
    'bool_field' => 1,
    'byte_field' => 2,
    'short_field' => 3,
    'int_field' => 4,
    'long_field' => 5,
    'float_field' => 6,
    'double_field' => 7,
    'string_field' => 8,
    'binary_field' => 9,
    'enum_field' => 10,
    'list_field' => 11,
    'set_field' => 12,
    'map_field' => 13,
    'struct_field' => 14,
  ];

  const type TConstructorShape = shape(
    ?'bool_field' => ?bool,
    ?'byte_field' => ?int,
    ?'short_field' => ?int,
    ?'int_field' => ?int,
    ?'long_field' => ?int,
    ?'float_field' => ?float,
    ?'double_field' => ?float,
    ?'string_field' => ?string,
    ?'binary_field' => ?string,
    ?'enum_field' => ?\facebook\thrift\test\terse_write\MyEnum,
    ?'list_field' => ?Vector<int>,
    ?'set_field' => ?Set<int>,
    ?'map_field' => ?Map<int, int>,
    ?'struct_field' => ?\facebook\thrift\test\terse_write\MyStruct,
  );

  const type TShape = shape(
    ?'bool_field' => ?bool,
    ?'byte_field' => ?int,
    ?'short_field' => ?int,
    ?'int_field' => ?int,
    ?'long_field' => ?int,
    ?'float_field' => ?float,
    ?'double_field' => ?float,
    ?'string_field' => ?string,
    ?'binary_field' => ?string,
    ?'enum_field' => ?\facebook\thrift\test\terse_write\MyEnum,
    ?'list_field' => ?vec<int>,
    ?'set_field' => ?dict<int, bool>,
    ?'map_field' => ?dict<int, int>,
    ?'struct_field' => ?\facebook\thrift\test\terse_write\MyStruct::TShape,
    ...
  );
  const int STRUCTURAL_ID = 586689148575201005;
  /**
   * Original thrift field:-
   * 1: bool bool_field
   */
  public ?bool $bool_field;
  /**
   * Original thrift field:-
   * 2: byte byte_field
   */
  public ?int $byte_field;
  /**
   * Original thrift field:-
   * 3: i16 short_field
   */
  public ?int $short_field;
  /**
   * Original thrift field:-
   * 4: i32 int_field
   */
  public ?int $int_field;
  /**
   * Original thrift field:-
   * 5: i64 long_field
   */
  public ?int $long_field;
  /**
   * Original thrift field:-
   * 6: float float_field
   */
  public ?float $float_field;
  /**
   * Original thrift field:-
   * 7: double double_field
   */
  public ?float $double_field;
  /**
   * Original thrift field:-
   * 8: string string_field
   */
  public ?string $string_field;
  /**
   * Original thrift field:-
   * 9: binary binary_field
   */
  public ?string $binary_field;
  /**
   * Original thrift field:-
   * 10: terse_write.MyEnum enum_field
   */
  public ?\facebook\thrift\test\terse_write\MyEnum $enum_field;
  /**
   * Original thrift field:-
   * 11: list<i16> list_field
   */
  public ?Vector<int> $list_field;
  /**
   * Original thrift field:-
   * 12: set<i16> set_field
   */
  public ?Set<int> $set_field;
  /**
   * Original thrift field:-
   * 13: map<i16, i16> map_field
   */
  public ?Map<int, int> $map_field;
  /**
   * Original thrift field:-
   * 14: terse_write.MyStruct struct_field
   */
  public ?\facebook\thrift\test\terse_write\MyStruct $struct_field;
  protected \facebook\thrift\test\terse_write\MyUnionEnum $_type = \facebook\thrift\test\terse_write\MyUnionEnum::_EMPTY_;

  public function __construct(?bool $bool_field = null, ?int $byte_field = null, ?int $short_field = null, ?int $int_field = null, ?int $long_field = null, ?float $float_field = null, ?float $double_field = null, ?string $string_field = null, ?string $binary_field = null, ?\facebook\thrift\test\terse_write\MyEnum $enum_field = null, ?Vector<int> $list_field = null, ?Set<int> $set_field = null, ?Map<int, int> $map_field = null, ?\facebook\thrift\test\terse_write\MyStruct $struct_field = null)[] {
    $this->_type = \facebook\thrift\test\terse_write\MyUnionEnum::_EMPTY_;
    if ($bool_field !== null) {
      $this->bool_field = $bool_field;
      $this->_type = \facebook\thrift\test\terse_write\MyUnionEnum::bool_field;
    }
    if ($byte_field !== null) {
      $this->byte_field = $byte_field;
      $this->_type = \facebook\thrift\test\terse_write\MyUnionEnum::byte_field;
    }
    if ($short_field !== null) {
      $this->short_field = $short_field;
      $this->_type = \facebook\thrift\test\terse_write\MyUnionEnum::short_field;
    }
    if ($int_field !== null) {
      $this->int_field = $int_field;
      $this->_type = \facebook\thrift\test\terse_write\MyUnionEnum::int_field;
    }
    if ($long_field !== null) {
      $this->long_field = $long_field;
      $this->_type = \facebook\thrift\test\terse_write\MyUnionEnum::long_field;
    }
    if ($float_field !== null) {
      $this->float_field = $float_field;
      $this->_type = \facebook\thrift\test\terse_write\MyUnionEnum::float_field;
    }
    if ($double_field !== null) {
      $this->double_field = $double_field;
      $this->_type = \facebook\thrift\test\terse_write\MyUnionEnum::double_field;
    }
    if ($string_field !== null) {
      $this->string_field = $string_field;
      $this->_type = \facebook\thrift\test\terse_write\MyUnionEnum::string_field;
    }
    if ($binary_field !== null) {
      $this->binary_field = $binary_field;
      $this->_type = \facebook\thrift\test\terse_write\MyUnionEnum::binary_field;
    }
    if ($enum_field !== null) {
      $this->enum_field = $enum_field;
      $this->_type = \facebook\thrift\test\terse_write\MyUnionEnum::enum_field;
    }
    if ($list_field !== null) {
      $this->list_field = $list_field;
      $this->_type = \facebook\thrift\test\terse_write\MyUnionEnum::list_field;
    }
    if ($set_field !== null) {
      $this->set_field = $set_field;
      $this->_type = \facebook\thrift\test\terse_write\MyUnionEnum::set_field;
    }
    if ($map_field !== null) {
      $this->map_field = $map_field;
      $this->_type = \facebook\thrift\test\terse_write\MyUnionEnum::map_field;
    }
    if ($struct_field !== null) {
      $this->struct_field = $struct_field;
      $this->_type = \facebook\thrift\test\terse_write\MyUnionEnum::struct_field;
    }
  }

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

  public static function fromShape(self::TConstructorShape $shape)[]: this {
    return new static(
      Shapes::idx($shape, 'bool_field'),
      Shapes::idx($shape, 'byte_field'),
      Shapes::idx($shape, 'short_field'),
      Shapes::idx($shape, 'int_field'),
      Shapes::idx($shape, 'long_field'),
      Shapes::idx($shape, 'float_field'),
      Shapes::idx($shape, 'double_field'),
      Shapes::idx($shape, 'string_field'),
      Shapes::idx($shape, 'binary_field'),
      Shapes::idx($shape, 'enum_field'),
      Shapes::idx($shape, 'list_field'),
      Shapes::idx($shape, 'set_field'),
      Shapes::idx($shape, 'map_field'),
      Shapes::idx($shape, 'struct_field'),
    );
  }

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

  public function getType()[]: \facebook\thrift\test\terse_write\MyUnionEnum {
    return $this->_type;
  }

  public function reset()[write_props]: void {
    switch ($this->_type) {
      case \facebook\thrift\test\terse_write\MyUnionEnum::bool_field:
        $this->bool_field = null;
        break;
      case \facebook\thrift\test\terse_write\MyUnionEnum::byte_field:
        $this->byte_field = null;
        break;
      case \facebook\thrift\test\terse_write\MyUnionEnum::short_field:
        $this->short_field = null;
        break;
      case \facebook\thrift\test\terse_write\MyUnionEnum::int_field:
        $this->int_field = null;
        break;
      case \facebook\thrift\test\terse_write\MyUnionEnum::long_field:
        $this->long_field = null;
        break;
      case \facebook\thrift\test\terse_write\MyUnionEnum::float_field:
        $this->float_field = null;
        break;
      case \facebook\thrift\test\terse_write\MyUnionEnum::double_field:
        $this->double_field = null;
        break;
      case \facebook\thrift\test\terse_write\MyUnionEnum::string_field:
        $this->string_field = null;
        break;
      case \facebook\thrift\test\terse_write\MyUnionEnum::binary_field:
        $this->binary_field = null;
        break;
      case \facebook\thrift\test\terse_write\MyUnionEnum::enum_field:
        $this->enum_field = null;
        break;
      case \facebook\thrift\test\terse_write\MyUnionEnum::list_field:
        $this->list_field = null;
        break;
      case \facebook\thrift\test\terse_write\MyUnionEnum::set_field:
        $this->set_field = null;
        break;
      case \facebook\thrift\test\terse_write\MyUnionEnum::map_field:
        $this->map_field = null;
        break;
      case \facebook\thrift\test\terse_write\MyUnionEnum::struct_field:
        $this->struct_field = null;
        break;
      case \facebook\thrift\test\terse_write\MyUnionEnum::_EMPTY_:
        break;
    }
    $this->_type = \facebook\thrift\test\terse_write\MyUnionEnum::_EMPTY_;
  }

  public function set_bool_field(bool $bool_field)[write_props]: this {
    $this->reset();
    $this->_type = \facebook\thrift\test\terse_write\MyUnionEnum::bool_field;
    $this->bool_field = $bool_field;
    return $this;
  }

  public function get_bool_field()[]: ?bool {
    return $this->bool_field;
  }

  public function getx_bool_field()[]: bool {
    invariant(
      $this->_type === \facebook\thrift\test\terse_write\MyUnionEnum::bool_field,
      'get_bool_field called on an instance of MyUnion whose current type is %s',
      (string)$this->_type,
    );
    return $this->bool_field as nonnull;
  }

  public function set_byte_field(int $byte_field)[write_props]: this {
    $this->reset();
    $this->_type = \facebook\thrift\test\terse_write\MyUnionEnum::byte_field;
    $this->byte_field = $byte_field;
    return $this;
  }

  public function get_byte_field()[]: ?int {
    return $this->byte_field;
  }

  public function getx_byte_field()[]: int {
    invariant(
      $this->_type === \facebook\thrift\test\terse_write\MyUnionEnum::byte_field,
      'get_byte_field called on an instance of MyUnion whose current type is %s',
      (string)$this->_type,
    );
    return $this->byte_field as nonnull;
  }

  public function set_short_field(int $short_field)[write_props]: this {
    $this->reset();
    $this->_type = \facebook\thrift\test\terse_write\MyUnionEnum::short_field;
    $this->short_field = $short_field;
    return $this;
  }

  public function get_short_field()[]: ?int {
    return $this->short_field;
  }

  public function getx_short_field()[]: int {
    invariant(
      $this->_type === \facebook\thrift\test\terse_write\MyUnionEnum::short_field,
      'get_short_field called on an instance of MyUnion whose current type is %s',
      (string)$this->_type,
    );
    return $this->short_field as nonnull;
  }

  public function set_int_field(int $int_field)[write_props]: this {
    $this->reset();
    $this->_type = \facebook\thrift\test\terse_write\MyUnionEnum::int_field;
    $this->int_field = $int_field;
    return $this;
  }

  public function get_int_field()[]: ?int {
    return $this->int_field;
  }

  public function getx_int_field()[]: int {
    invariant(
      $this->_type === \facebook\thrift\test\terse_write\MyUnionEnum::int_field,
      'get_int_field called on an instance of MyUnion whose current type is %s',
      (string)$this->_type,
    );
    return $this->int_field as nonnull;
  }

  public function set_long_field(int $long_field)[write_props]: this {
    $this->reset();
    $this->_type = \facebook\thrift\test\terse_write\MyUnionEnum::long_field;
    $this->long_field = $long_field;
    return $this;
  }

  public function get_long_field()[]: ?int {
    return $this->long_field;
  }

  public function getx_long_field()[]: int {
    invariant(
      $this->_type === \facebook\thrift\test\terse_write\MyUnionEnum::long_field,
      'get_long_field called on an instance of MyUnion whose current type is %s',
      (string)$this->_type,
    );
    return $this->long_field as nonnull;
  }

  public function set_float_field(float $float_field)[write_props]: this {
    $this->reset();
    $this->_type = \facebook\thrift\test\terse_write\MyUnionEnum::float_field;
    $this->float_field = $float_field;
    return $this;
  }

  public function get_float_field()[]: ?float {
    return $this->float_field;
  }

  public function getx_float_field()[]: float {
    invariant(
      $this->_type === \facebook\thrift\test\terse_write\MyUnionEnum::float_field,
      'get_float_field called on an instance of MyUnion whose current type is %s',
      (string)$this->_type,
    );
    return $this->float_field as nonnull;
  }

  public function set_double_field(float $double_field)[write_props]: this {
    $this->reset();
    $this->_type = \facebook\thrift\test\terse_write\MyUnionEnum::double_field;
    $this->double_field = $double_field;
    return $this;
  }

  public function get_double_field()[]: ?float {
    return $this->double_field;
  }

  public function getx_double_field()[]: float {
    invariant(
      $this->_type === \facebook\thrift\test\terse_write\MyUnionEnum::double_field,
      'get_double_field called on an instance of MyUnion whose current type is %s',
      (string)$this->_type,
    );
    return $this->double_field as nonnull;
  }

  public function set_string_field(string $string_field)[write_props]: this {
    $this->reset();
    $this->_type = \facebook\thrift\test\terse_write\MyUnionEnum::string_field;
    $this->string_field = $string_field;
    return $this;
  }

  public function get_string_field()[]: ?string {
    return $this->string_field;
  }

  public function getx_string_field()[]: string {
    invariant(
      $this->_type === \facebook\thrift\test\terse_write\MyUnionEnum::string_field,
      'get_string_field called on an instance of MyUnion whose current type is %s',
      (string)$this->_type,
    );
    return $this->string_field as nonnull;
  }

  public function set_binary_field(string $binary_field)[write_props]: this {
    $this->reset();
    $this->_type = \facebook\thrift\test\terse_write\MyUnionEnum::binary_field;
    $this->binary_field = $binary_field;
    return $this;
  }

  public function get_binary_field()[]: ?string {
    return $this->binary_field;
  }

  public function getx_binary_field()[]: string {
    invariant(
      $this->_type === \facebook\thrift\test\terse_write\MyUnionEnum::binary_field,
      'get_binary_field called on an instance of MyUnion whose current type is %s',
      (string)$this->_type,
    );
    return $this->binary_field as nonnull;
  }

  public function set_enum_field(\facebook\thrift\test\terse_write\MyEnum $enum_field)[write_props]: this {
    $this->reset();
    $this->_type = \facebook\thrift\test\terse_write\MyUnionEnum::enum_field;
    $this->enum_field = $enum_field;
    return $this;
  }

  public function get_enum_field()[]: ?\facebook\thrift\test\terse_write\MyEnum {
    return $this->enum_field;
  }

  public function getx_enum_field()[]: \facebook\thrift\test\terse_write\MyEnum {
    invariant(
      $this->_type === \facebook\thrift\test\terse_write\MyUnionEnum::enum_field,
      'get_enum_field called on an instance of MyUnion whose current type is %s',
      (string)$this->_type,
    );
    return $this->enum_field as nonnull;
  }

  public function set_list_field(Vector<int> $list_field)[write_props]: this {
    $this->reset();
    $this->_type = \facebook\thrift\test\terse_write\MyUnionEnum::list_field;
    $this->list_field = $list_field;
    return $this;
  }

  public function get_list_field()[]: ?Vector<int> {
    return $this->list_field;
  }

  public function getx_list_field()[]: Vector<int> {
    invariant(
      $this->_type === \facebook\thrift\test\terse_write\MyUnionEnum::list_field,
      'get_list_field called on an instance of MyUnion whose current type is %s',
      (string)$this->_type,
    );
    return $this->list_field as nonnull;
  }

  public function set_set_field(Set<int> $set_field)[write_props]: this {
    $this->reset();
    $this->_type = \facebook\thrift\test\terse_write\MyUnionEnum::set_field;
    $this->set_field = new Set(Keyset\keys($set_field));
    return $this;
  }

  public function get_set_field()[]: ?Set<int> {
    return $this->set_field;
  }

  public function getx_set_field()[]: Set<int> {
    invariant(
      $this->_type === \facebook\thrift\test\terse_write\MyUnionEnum::set_field,
      'get_set_field called on an instance of MyUnion whose current type is %s',
      (string)$this->_type,
    );
    return $this->set_field as nonnull;
  }

  public function set_map_field(Map<int, int> $map_field)[write_props]: this {
    $this->reset();
    $this->_type = \facebook\thrift\test\terse_write\MyUnionEnum::map_field;
    $this->map_field = $map_field;
    return $this;
  }

  public function get_map_field()[]: ?Map<int, int> {
    return $this->map_field;
  }

  public function getx_map_field()[]: Map<int, int> {
    invariant(
      $this->_type === \facebook\thrift\test\terse_write\MyUnionEnum::map_field,
      'get_map_field called on an instance of MyUnion whose current type is %s',
      (string)$this->_type,
    );
    return $this->map_field as nonnull;
  }

  public function set_struct_field(\facebook\thrift\test\terse_write\MyStruct $struct_field)[write_props]: this {
    $this->reset();
    $this->_type = \facebook\thrift\test\terse_write\MyUnionEnum::struct_field;
    $this->struct_field = $struct_field;
    return $this;
  }

  public function get_struct_field()[]: ?\facebook\thrift\test\terse_write\MyStruct {
    return $this->struct_field;
  }

  public function getx_struct_field()[]: \facebook\thrift\test\terse_write\MyStruct {
    invariant(
      $this->_type === \facebook\thrift\test\terse_write\MyUnionEnum::struct_field,
      'get_struct_field called on an instance of MyUnion whose current type is %s',
      (string)$this->_type,
    );
    return $this->struct_field as nonnull;
  }

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

  public static function getStructMetadata()[]: \tmeta_ThriftStruct {
    return \tmeta_ThriftStruct::fromShape(
      shape(
        "name" => "terse_write.MyUnion",
        "fields" => vec[
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 1,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_BOOL_TYPE,
                )
              ),
              "name" => "bool_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 2,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_BYTE_TYPE,
                )
              ),
              "name" => "byte_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 3,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I16_TYPE,
                )
              ),
              "name" => "short_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 4,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I32_TYPE,
                )
              ),
              "name" => "int_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 5,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I64_TYPE,
                )
              ),
              "name" => "long_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 6,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_FLOAT_TYPE,
                )
              ),
              "name" => "float_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 7,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_DOUBLE_TYPE,
                )
              ),
              "name" => "double_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 8,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                )
              ),
              "name" => "string_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 9,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_BINARY_TYPE,
                )
              ),
              "name" => "binary_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 10,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_enum" => \tmeta_ThriftEnumType::fromShape(
                    shape(
                      "name" => "terse_write.MyEnum",
                    )
                  ),
                )
              ),
              "name" => "enum_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 11,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_list" => \tmeta_ThriftListType::fromShape(
                    shape(
                      "valueType" => \tmeta_ThriftType::fromShape(
                        shape(
                          "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I16_TYPE,
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "list_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 12,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_set" => \tmeta_ThriftSetType::fromShape(
                    shape(
                      "valueType" => \tmeta_ThriftType::fromShape(
                        shape(
                          "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I16_TYPE,
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "set_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 13,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_map" => \tmeta_ThriftMapType::fromShape(
                    shape(
                      "keyType" => \tmeta_ThriftType::fromShape(
                        shape(
                          "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I16_TYPE,
                        )
                      ),
                      "valueType" => \tmeta_ThriftType::fromShape(
                        shape(
                          "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I16_TYPE,
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "map_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 14,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_struct" => \tmeta_ThriftStructType::fromShape(
                    shape(
                      "name" => "terse_write.MyStruct",
                    )
                  ),
                )
              ),
              "name" => "struct_field",
            )
          ),
        ],
        "is_union" => true,
      )
    );
  }

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

  public static function __fromShape(self::TShape $shape)[]: this {
    return new static(
      Shapes::idx($shape, 'bool_field'),
      Shapes::idx($shape, 'byte_field'),
      Shapes::idx($shape, 'short_field'),
      Shapes::idx($shape, 'int_field'),
      Shapes::idx($shape, 'long_field'),
      Shapes::idx($shape, 'float_field'),
      Shapes::idx($shape, 'double_field'),
      Shapes::idx($shape, 'string_field'),
      Shapes::idx($shape, 'binary_field'),
      Shapes::idx($shape, 'enum_field'),
      Shapes::idx($shape, 'list_field') === null ? null : ($shape['list_field'] |> new Vector($$)),
      Shapes::idx($shape, 'set_field') === null ? null : (new Set(Keyset\keys($shape['set_field']))),
      Shapes::idx($shape, 'map_field') === null ? null : ($shape['map_field'] |> new Map($$)),
      Shapes::idx($shape, 'struct_field') === null ? null : (\facebook\thrift\test\terse_write\MyStruct::__fromShape($shape['struct_field'])),
    );
  }

  public function __toShape()[]: self::TShape {
    return shape(
      'bool_field' => $this->bool_field,
      'byte_field' => $this->byte_field,
      'short_field' => $this->short_field,
      'int_field' => $this->int_field,
      'long_field' => $this->long_field,
      'float_field' => $this->float_field,
      'double_field' => $this->double_field,
      'string_field' => $this->string_field,
      'binary_field' => $this->binary_field,
      'enum_field' => $this->enum_field,
      'list_field' => $this->list_field
        |> $$ === null ? null : vec($$),
      'set_field' => $this->set_field
        |> $$ === null ? null : ThriftUtil::toDArray(Dict\fill_keys($$->toValuesArray(), true), static::class),
      'map_field' => $this->map_field
        |> $$ === null ? null : dict($$),
      'struct_field' => $this->struct_field?->__toShape(),
    );
  }
  public function getInstanceKey()[write_props]: string {
    return \TCompactSerializer::serialize($this);
  }

  public function readFromJson(string $jsonText): void {
    $this->_type = \facebook\thrift\test\terse_write\MyUnionEnum::_EMPTY_;
    $parsed = json_decode($jsonText, true);

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

    if (idx($parsed, 'bool_field') !== null) {
      $this->bool_field = HH\FIXME\UNSAFE_CAST<mixed, bool>($parsed['bool_field']);
      $this->_type = \facebook\thrift\test\terse_write\MyUnionEnum::bool_field;
    }
    if (idx($parsed, 'byte_field') !== null) {
      $_tmp0 = (int)HH\FIXME\UNSAFE_CAST<mixed, int>($parsed['byte_field']);
      if ($_tmp0 > 0x7f) {
        throw new \TProtocolException("number exceeds limit in field");
      } else {
        $this->byte_field = (int)$_tmp0;
      }
      $this->_type = \facebook\thrift\test\terse_write\MyUnionEnum::byte_field;
    }
    if (idx($parsed, 'short_field') !== null) {
      $_tmp1 = (int)HH\FIXME\UNSAFE_CAST<mixed, int>($parsed['short_field']);
      if ($_tmp1 > 0x7fff) {
        throw new \TProtocolException("number exceeds limit in field");
      } else {
        $this->short_field = (int)$_tmp1;
      }
      $this->_type = \facebook\thrift\test\terse_write\MyUnionEnum::short_field;
    }
    if (idx($parsed, 'int_field') !== null) {
      $_tmp2 = (int)HH\FIXME\UNSAFE_CAST<mixed, int>($parsed['int_field']);
      if ($_tmp2 > 0x7fffffff) {
        throw new \TProtocolException("number exceeds limit in field");
      } else {
        $this->int_field = (int)$_tmp2;
      }
      $this->_type = \facebook\thrift\test\terse_write\MyUnionEnum::int_field;
    }
    if (idx($parsed, 'long_field') !== null) {
      $this->long_field = HH\FIXME\UNSAFE_CAST<mixed, int>($parsed['long_field']);
      $this->_type = \facebook\thrift\test\terse_write\MyUnionEnum::long_field;
    }
    if (idx($parsed, 'float_field') !== null) {
      $this->float_field = HH\FIXME\UNSAFE_CAST<mixed, float>($parsed['float_field']);
      $this->_type = \facebook\thrift\test\terse_write\MyUnionEnum::float_field;
    }
    if (idx($parsed, 'double_field') !== null) {
      $this->double_field = HH\FIXME\UNSAFE_CAST<mixed, float>($parsed['double_field']);
      $this->_type = \facebook\thrift\test\terse_write\MyUnionEnum::double_field;
    }
    if (idx($parsed, 'string_field') !== null) {
      $this->string_field = HH\FIXME\UNSAFE_CAST<mixed, string>($parsed['string_field']);
      $this->_type = \facebook\thrift\test\terse_write\MyUnionEnum::string_field;
    }
    if (idx($parsed, 'binary_field') !== null) {
      $this->binary_field = HH\FIXME\UNSAFE_CAST<mixed, string>($parsed['binary_field']);
      $this->_type = \facebook\thrift\test\terse_write\MyUnionEnum::binary_field;
    }
    if (idx($parsed, 'enum_field') !== null) {
      $this->enum_field = \facebook\thrift\test\terse_write\MyEnum::coerce(HH\FIXME\UNSAFE_CAST<mixed, \facebook\thrift\test\terse_write\MyEnum>($parsed['enum_field']));
      $this->_type = \facebook\thrift\test\terse_write\MyUnionEnum::enum_field;
    }
    if (idx($parsed, 'list_field') !== null) {
      $_json6 = HH\FIXME\UNSAFE_CAST<mixed, Vector<int>>($parsed['list_field']);
      $_container7 = Vector {};
      foreach($_json6 as $_key4 => $_value5) {
        $_elem8 = 0;
        $_tmp9 = (int)$_value5;
        if ($_tmp9 > 0x7fff) {
          throw new \TProtocolException("number exceeds limit in field");
        } else {
          $_elem8 = (int)$_tmp9;
        }
        $_container7 []= $_elem8;
      }
      $this->list_field = $_container7;
      $this->_type = \facebook\thrift\test\terse_write\MyUnionEnum::list_field;
    }
    if (idx($parsed, 'set_field') !== null) {
      $_json13 = HH\FIXME\UNSAFE_CAST<mixed, Set<int>>($parsed['set_field']);
      $_container14 = Set {};
      foreach($_json13 as $_key11 => $_value12) {
        $_elem15 = 0;
        $_tmp16 = (int)$_value12;
        if ($_tmp16 > 0x7fff) {
          throw new \TProtocolException("number exceeds limit in field");
        } else {
          $_elem15 = (int)$_tmp16;
        }
        $_container14->add($_elem15);
      }
      $this->set_field = $_container14;
      $this->_type = \facebook\thrift\test\terse_write\MyUnionEnum::set_field;
    }
    if (idx($parsed, 'map_field') !== null) {
      $_json20 = HH\FIXME\UNSAFE_CAST<mixed, Map<int, int>>($parsed['map_field']);
      $_container21 = Map {};
      foreach($_json20 as $_key18 => $_value19) {
        $_value22 = 0;
        $_tmp23 = (int)$_value19;
        if ($_tmp23 > 0x7fff) {
          throw new \TProtocolException("number exceeds limit in field");
        } else {
          $_value22 = (int)$_tmp23;
        }
        $_container21[$_key18] = $_value22;
      }
      $this->map_field = $_container21;
      $this->_type = \facebook\thrift\test\terse_write\MyUnionEnum::map_field;
    }
    if (idx($parsed, 'struct_field') !== null) {
      $_tmp24 = \json_encode(HH\FIXME\UNSAFE_CAST<mixed, \facebook\thrift\test\terse_write\MyStruct>($parsed['struct_field']));
      $_tmp25 = \facebook\thrift\test\terse_write\MyStruct::withDefaultValues();
      $_tmp25->readFromJson($_tmp24);
      $this->struct_field = $_tmp25;
      $this->_type = \facebook\thrift\test\terse_write\MyUnionEnum::struct_field;
    }
  }

}

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

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

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

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

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

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

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

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

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

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

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

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

  public function __toShape()[]: self::TShape {
    return shape(
      'field1' => $this->field1,
    );
  }
  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, 'field1') !== null) {
      $this->field1 = HH\FIXME\UNSAFE_CAST<mixed, int>($parsed['field1']);
    }
  }

}

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

  const \ThriftStructTypes::TSpec SPEC = dict[
    1 => shape(
      'var' => 'bool_field',
      'is_terse' => true,
      'type' => \TType::BOOL,
    ),
    2 => shape(
      'var' => 'byte_field',
      'is_terse' => true,
      'type' => \TType::BYTE,
    ),
    3 => shape(
      'var' => 'short_field',
      'is_terse' => true,
      'type' => \TType::I16,
    ),
    4 => shape(
      'var' => 'int_field',
      'is_terse' => true,
      'type' => \TType::I32,
    ),
    5 => shape(
      'var' => 'long_field',
      'is_terse' => true,
      'type' => \TType::I64,
    ),
    6 => shape(
      'var' => 'float_field',
      'is_terse' => true,
      'type' => \TType::FLOAT,
    ),
    7 => shape(
      'var' => 'double_field',
      'is_terse' => true,
      'type' => \TType::DOUBLE,
    ),
    8 => shape(
      'var' => 'string_field',
      'is_terse' => true,
      'type' => \TType::STRING,
    ),
    9 => shape(
      'var' => 'binary_field',
      'is_terse' => true,
      'type' => \TType::STRING,
      'is_binary' => true,
    ),
    10 => shape(
      'var' => 'enum_field',
      'is_terse' => true,
      'type' => \TType::I32,
      'enum' => \facebook\thrift\test\terse_write\MyEnum::class,
    ),
    11 => shape(
      'var' => 'list_field',
      'is_terse' => true,
      'type' => \TType::LST,
      'etype' => \TType::I16,
      'elem' => shape(
        'type' => \TType::I16,
      ),
      'format' => 'collection',
    ),
    12 => shape(
      'var' => 'set_field',
      'is_terse' => true,
      'type' => \TType::SET,
      'etype' => \TType::I16,
      'elem' => shape(
        'type' => \TType::I16,
      ),
      'format' => 'collection',
    ),
    13 => shape(
      'var' => 'map_field',
      'is_terse' => true,
      'type' => \TType::MAP,
      'ktype' => \TType::I16,
      'vtype' => \TType::I16,
      'key' => shape(
        'type' => \TType::I16,
      ),
      'val' => shape(
        'type' => \TType::I16,
      ),
      'format' => 'collection',
    ),
    14 => shape(
      'var' => 'struct_field',
      'is_terse' => true,
      'type' => \TType::STRUCT,
      'class' => \facebook\thrift\test\terse_write\MyStruct::class,
    ),
    15 => shape(
      'var' => 'union_field',
      'is_terse' => true,
      'type' => \TType::STRUCT,
      'class' => \facebook\thrift\test\terse_write\MyUnion::class,
    ),
  ];
  const dict<string, int> FIELDMAP = dict[
    'bool_field' => 1,
    'byte_field' => 2,
    'short_field' => 3,
    'int_field' => 4,
    'long_field' => 5,
    'float_field' => 6,
    'double_field' => 7,
    'string_field' => 8,
    'binary_field' => 9,
    'enum_field' => 10,
    'list_field' => 11,
    'set_field' => 12,
    'map_field' => 13,
    'struct_field' => 14,
    'union_field' => 15,
  ];

  const type TConstructorShape = shape(
    ?'bool_field' => ?bool,
    ?'byte_field' => ?int,
    ?'short_field' => ?int,
    ?'int_field' => ?int,
    ?'long_field' => ?int,
    ?'float_field' => ?float,
    ?'double_field' => ?float,
    ?'string_field' => ?string,
    ?'binary_field' => ?string,
    ?'enum_field' => ?\facebook\thrift\test\terse_write\MyEnum,
    ?'list_field' => ?Vector<int>,
    ?'set_field' => ?Set<int>,
    ?'map_field' => ?Map<int, int>,
    ?'struct_field' => ?\facebook\thrift\test\terse_write\MyStruct,
    ?'union_field' => ?\facebook\thrift\test\terse_write\MyUnion,
  );

  const type TShape = shape(
    'bool_field' => bool,
    'byte_field' => int,
    'short_field' => int,
    'int_field' => int,
    'long_field' => int,
    'float_field' => float,
    'double_field' => float,
    'string_field' => string,
    'binary_field' => string,
    ?'enum_field' => ?\facebook\thrift\test\terse_write\MyEnum,
    'list_field' => vec<int>,
    'set_field' => dict<int, bool>,
    'map_field' => dict<int, int>,
    ?'struct_field' => ?\facebook\thrift\test\terse_write\MyStruct::TShape,
    ?'union_field' => ?\facebook\thrift\test\terse_write\MyUnion::TShape,
    ...
  );
  const int STRUCTURAL_ID = 886176714715872097;
  /**
   * Original thrift field:-
   * 1: bool bool_field
   */
  public bool $bool_field;
  /**
   * Original thrift field:-
   * 2: byte byte_field
   */
  public int $byte_field;
  /**
   * Original thrift field:-
   * 3: i16 short_field
   */
  public int $short_field;
  /**
   * Original thrift field:-
   * 4: i32 int_field
   */
  public int $int_field;
  /**
   * Original thrift field:-
   * 5: i64 long_field
   */
  public int $long_field;
  /**
   * Original thrift field:-
   * 6: float float_field
   */
  public float $float_field;
  /**
   * Original thrift field:-
   * 7: double double_field
   */
  public float $double_field;
  /**
   * Original thrift field:-
   * 8: string string_field
   */
  public string $string_field;
  /**
   * Original thrift field:-
   * 9: binary binary_field
   */
  public string $binary_field;
  /**
   * Original thrift field:-
   * 10: terse_write.MyEnum enum_field
   */
  public ?\facebook\thrift\test\terse_write\MyEnum $enum_field;
  /**
   * Original thrift field:-
   * 11: list<i16> list_field
   */
  public Vector<int> $list_field;
  /**
   * Original thrift field:-
   * 12: set<i16> set_field
   */
  public Set<int> $set_field;
  /**
   * Original thrift field:-
   * 13: map<i16, i16> map_field
   */
  public Map<int, int> $map_field;
  /**
   * Original thrift field:-
   * 14: terse_write.MyStruct struct_field
   */
  public ?\facebook\thrift\test\terse_write\MyStruct $struct_field;
  /**
   * Original thrift field:-
   * 15: terse_write.MyUnion union_field
   */
  public ?\facebook\thrift\test\terse_write\MyUnion $union_field;

  public function __construct(?bool $bool_field = null, ?int $byte_field = null, ?int $short_field = null, ?int $int_field = null, ?int $long_field = null, ?float $float_field = null, ?float $double_field = null, ?string $string_field = null, ?string $binary_field = null, ?\facebook\thrift\test\terse_write\MyEnum $enum_field = null, ?Vector<int> $list_field = null, ?Set<int> $set_field = null, ?Map<int, int> $map_field = null, ?\facebook\thrift\test\terse_write\MyStruct $struct_field = null, ?\facebook\thrift\test\terse_write\MyUnion $union_field = null)[] {
    $this->bool_field = $bool_field ?? false;
    $this->byte_field = $byte_field ?? 0;
    $this->short_field = $short_field ?? 0;
    $this->int_field = $int_field ?? 0;
    $this->long_field = $long_field ?? 0;
    $this->float_field = $float_field ?? 0.0;
    $this->double_field = $double_field ?? 0.0;
    $this->string_field = $string_field ?? '';
    $this->binary_field = $binary_field ?? '';
    $this->enum_field = $enum_field;
    $this->list_field = $list_field ?? Vector {};
    $this->set_field = $set_field ?? Set {};
    $this->map_field = $map_field ?? Map {};
    $this->struct_field = $struct_field;
    $this->union_field = $union_field;
  }

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

  public static function fromShape(self::TConstructorShape $shape)[]: this {
    return new static(
      Shapes::idx($shape, 'bool_field'),
      Shapes::idx($shape, 'byte_field'),
      Shapes::idx($shape, 'short_field'),
      Shapes::idx($shape, 'int_field'),
      Shapes::idx($shape, 'long_field'),
      Shapes::idx($shape, 'float_field'),
      Shapes::idx($shape, 'double_field'),
      Shapes::idx($shape, 'string_field'),
      Shapes::idx($shape, 'binary_field'),
      Shapes::idx($shape, 'enum_field'),
      Shapes::idx($shape, 'list_field'),
      Shapes::idx($shape, 'set_field'),
      Shapes::idx($shape, 'map_field'),
      Shapes::idx($shape, 'struct_field'),
      Shapes::idx($shape, 'union_field'),
    );
  }

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

  public function clearTerseFields()[write_props]: void {
    $this->bool_field = false;
    $this->byte_field = 0;
    $this->short_field = 0;
    $this->int_field = 0;
    $this->long_field = 0;
    $this->float_field = 0.0;
    $this->double_field = 0.0;
    $this->string_field = '';
    $this->binary_field = '';
    $this->enum_field = null;
    $this->list_field = Vector {};
    $this->set_field = Set {};
    $this->map_field = Map {};
    $this->struct_field = null;
    $this->union_field = null;
  }

  public static function getStructMetadata()[]: \tmeta_ThriftStruct {
    return \tmeta_ThriftStruct::fromShape(
      shape(
        "name" => "terse_write.StructLevelTerseStruct",
        "fields" => vec[
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 1,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_BOOL_TYPE,
                )
              ),
              "name" => "bool_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 2,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_BYTE_TYPE,
                )
              ),
              "name" => "byte_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 3,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I16_TYPE,
                )
              ),
              "name" => "short_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 4,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I32_TYPE,
                )
              ),
              "name" => "int_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 5,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I64_TYPE,
                )
              ),
              "name" => "long_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 6,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_FLOAT_TYPE,
                )
              ),
              "name" => "float_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 7,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_DOUBLE_TYPE,
                )
              ),
              "name" => "double_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 8,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                )
              ),
              "name" => "string_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 9,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_BINARY_TYPE,
                )
              ),
              "name" => "binary_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 10,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_enum" => \tmeta_ThriftEnumType::fromShape(
                    shape(
                      "name" => "terse_write.MyEnum",
                    )
                  ),
                )
              ),
              "name" => "enum_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 11,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_list" => \tmeta_ThriftListType::fromShape(
                    shape(
                      "valueType" => \tmeta_ThriftType::fromShape(
                        shape(
                          "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I16_TYPE,
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "list_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 12,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_set" => \tmeta_ThriftSetType::fromShape(
                    shape(
                      "valueType" => \tmeta_ThriftType::fromShape(
                        shape(
                          "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I16_TYPE,
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "set_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 13,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_map" => \tmeta_ThriftMapType::fromShape(
                    shape(
                      "keyType" => \tmeta_ThriftType::fromShape(
                        shape(
                          "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I16_TYPE,
                        )
                      ),
                      "valueType" => \tmeta_ThriftType::fromShape(
                        shape(
                          "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I16_TYPE,
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "map_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 14,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_struct" => \tmeta_ThriftStructType::fromShape(
                    shape(
                      "name" => "terse_write.MyStruct",
                    )
                  ),
                )
              ),
              "name" => "struct_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 15,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_struct" => \tmeta_ThriftStructType::fromShape(
                    shape(
                      "name" => "terse_write.MyUnion",
                    )
                  ),
                )
              ),
              "name" => "union_field",
            )
          ),
        ],
        "is_union" => false,
      )
    );
  }

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

  public static function __fromShape(self::TShape $shape)[]: this {
    return new static(
      $shape['bool_field'],
      $shape['byte_field'],
      $shape['short_field'],
      $shape['int_field'],
      $shape['long_field'],
      $shape['float_field'],
      $shape['double_field'],
      $shape['string_field'],
      $shape['binary_field'],
      Shapes::idx($shape, 'enum_field'),
      $shape['list_field'] |> new Vector($$),
      new Set(Keyset\keys($shape['set_field'])),
      $shape['map_field'] |> new Map($$),
      Shapes::idx($shape, 'struct_field') === null ? null : (\facebook\thrift\test\terse_write\MyStruct::__fromShape($shape['struct_field'])),
      Shapes::idx($shape, 'union_field') === null ? null : (\facebook\thrift\test\terse_write\MyUnion::__fromShape($shape['union_field'])),
    );
  }

  public function __toShape()[]: self::TShape {
    return shape(
      'bool_field' => $this->bool_field,
      'byte_field' => $this->byte_field,
      'short_field' => $this->short_field,
      'int_field' => $this->int_field,
      'long_field' => $this->long_field,
      'float_field' => $this->float_field,
      'double_field' => $this->double_field,
      'string_field' => $this->string_field,
      'binary_field' => $this->binary_field,
      'enum_field' => $this->enum_field,
      'list_field' => vec($this->list_field),
      'set_field' => ThriftUtil::toDArray(Dict\fill_keys($this->set_field->toValuesArray(), true), static::class),
      'map_field' => dict($this->map_field),
      'struct_field' => $this->struct_field?->__toShape(),
      'union_field' => $this->union_field?->__toShape(),
    );
  }
  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, 'bool_field') !== null) {
      $this->bool_field = HH\FIXME\UNSAFE_CAST<mixed, bool>($parsed['bool_field']);
    }
    if (idx($parsed, 'byte_field') !== null) {
      $_tmp0 = (int)HH\FIXME\UNSAFE_CAST<mixed, int>($parsed['byte_field']);
      if ($_tmp0 > 0x7f) {
        throw new \TProtocolException("number exceeds limit in field");
      } else {
        $this->byte_field = (int)$_tmp0;
      }
    }
    if (idx($parsed, 'short_field') !== null) {
      $_tmp1 = (int)HH\FIXME\UNSAFE_CAST<mixed, int>($parsed['short_field']);
      if ($_tmp1 > 0x7fff) {
        throw new \TProtocolException("number exceeds limit in field");
      } else {
        $this->short_field = (int)$_tmp1;
      }
    }
    if (idx($parsed, 'int_field') !== null) {
      $_tmp2 = (int)HH\FIXME\UNSAFE_CAST<mixed, int>($parsed['int_field']);
      if ($_tmp2 > 0x7fffffff) {
        throw new \TProtocolException("number exceeds limit in field");
      } else {
        $this->int_field = (int)$_tmp2;
      }
    }
    if (idx($parsed, 'long_field') !== null) {
      $this->long_field = HH\FIXME\UNSAFE_CAST<mixed, int>($parsed['long_field']);
    }
    if (idx($parsed, 'float_field') !== null) {
      $this->float_field = HH\FIXME\UNSAFE_CAST<mixed, float>($parsed['float_field']);
    }
    if (idx($parsed, 'double_field') !== null) {
      $this->double_field = HH\FIXME\UNSAFE_CAST<mixed, float>($parsed['double_field']);
    }
    if (idx($parsed, 'string_field') !== null) {
      $this->string_field = HH\FIXME\UNSAFE_CAST<mixed, string>($parsed['string_field']);
    }
    if (idx($parsed, 'binary_field') !== null) {
      $this->binary_field = HH\FIXME\UNSAFE_CAST<mixed, string>($parsed['binary_field']);
    }
    if (idx($parsed, 'enum_field') !== null) {
      $this->enum_field = \facebook\thrift\test\terse_write\MyEnum::coerce(HH\FIXME\UNSAFE_CAST<mixed, \facebook\thrift\test\terse_write\MyEnum>($parsed['enum_field']));
    }
    if (idx($parsed, 'list_field') !== null) {
      $_json6 = HH\FIXME\UNSAFE_CAST<mixed, Vector<int>>($parsed['list_field']);
      $_container7 = Vector {};
      foreach($_json6 as $_key4 => $_value5) {
        $_elem8 = 0;
        $_tmp9 = (int)$_value5;
        if ($_tmp9 > 0x7fff) {
          throw new \TProtocolException("number exceeds limit in field");
        } else {
          $_elem8 = (int)$_tmp9;
        }
        $_container7 []= $_elem8;
      }
      $this->list_field = $_container7;
    }
    if (idx($parsed, 'set_field') !== null) {
      $_json13 = HH\FIXME\UNSAFE_CAST<mixed, Set<int>>($parsed['set_field']);
      $_container14 = Set {};
      foreach($_json13 as $_key11 => $_value12) {
        $_elem15 = 0;
        $_tmp16 = (int)$_value12;
        if ($_tmp16 > 0x7fff) {
          throw new \TProtocolException("number exceeds limit in field");
        } else {
          $_elem15 = (int)$_tmp16;
        }
        $_container14->add($_elem15);
      }
      $this->set_field = $_container14;
    }
    if (idx($parsed, 'map_field') !== null) {
      $_json20 = HH\FIXME\UNSAFE_CAST<mixed, Map<int, int>>($parsed['map_field']);
      $_container21 = Map {};
      foreach($_json20 as $_key18 => $_value19) {
        $_value22 = 0;
        $_tmp23 = (int)$_value19;
        if ($_tmp23 > 0x7fff) {
          throw new \TProtocolException("number exceeds limit in field");
        } else {
          $_value22 = (int)$_tmp23;
        }
        $_container21[$_key18] = $_value22;
      }
      $this->map_field = $_container21;
    }
    if (idx($parsed, 'struct_field') !== null) {
      $_tmp24 = \json_encode(HH\FIXME\UNSAFE_CAST<mixed, \facebook\thrift\test\terse_write\MyStruct>($parsed['struct_field']));
      $_tmp25 = \facebook\thrift\test\terse_write\MyStruct::withDefaultValues();
      $_tmp25->readFromJson($_tmp24);
      $this->struct_field = $_tmp25;
    }
    if (idx($parsed, 'union_field') !== null) {
      $_tmp26 = \json_encode(HH\FIXME\UNSAFE_CAST<mixed, \facebook\thrift\test\terse_write\MyUnion>($parsed['union_field']));
      $_tmp27 = \facebook\thrift\test\terse_write\MyUnion::withDefaultValues();
      $_tmp27->readFromJson($_tmp26);
      $this->union_field = $_tmp27;
    }
  }

}

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

  const \ThriftStructTypes::TSpec SPEC = dict[
    1 => shape(
      'var' => 'terse_bool_field',
      'is_terse' => true,
      'type' => \TType::BOOL,
    ),
    2 => shape(
      'var' => 'terse_byte_field',
      'is_terse' => true,
      'type' => \TType::BYTE,
    ),
    3 => shape(
      'var' => 'terse_short_field',
      'is_terse' => true,
      'type' => \TType::I16,
    ),
    4 => shape(
      'var' => 'terse_int_field',
      'is_terse' => true,
      'type' => \TType::I32,
    ),
    5 => shape(
      'var' => 'terse_long_field',
      'is_terse' => true,
      'type' => \TType::I64,
    ),
    6 => shape(
      'var' => 'terse_float_field',
      'is_terse' => true,
      'type' => \TType::FLOAT,
    ),
    7 => shape(
      'var' => 'terse_double_field',
      'is_terse' => true,
      'type' => \TType::DOUBLE,
    ),
    8 => shape(
      'var' => 'terse_string_field',
      'is_terse' => true,
      'type' => \TType::STRING,
    ),
    9 => shape(
      'var' => 'terse_binary_field',
      'is_terse' => true,
      'type' => \TType::STRING,
      'is_binary' => true,
    ),
    10 => shape(
      'var' => 'terse_enum_field',
      'is_terse' => true,
      'type' => \TType::I32,
      'enum' => \facebook\thrift\test\terse_write\MyEnum::class,
    ),
    11 => shape(
      'var' => 'terse_list_field',
      'is_terse' => true,
      'type' => \TType::LST,
      'etype' => \TType::I16,
      'elem' => shape(
        'type' => \TType::I16,
      ),
      'format' => 'collection',
    ),
    12 => shape(
      'var' => 'terse_set_field',
      'is_terse' => true,
      'type' => \TType::SET,
      'etype' => \TType::I16,
      'elem' => shape(
        'type' => \TType::I16,
      ),
      'format' => 'collection',
    ),
    13 => shape(
      'var' => 'terse_map_field',
      'is_terse' => true,
      'type' => \TType::MAP,
      'ktype' => \TType::I16,
      'vtype' => \TType::I16,
      'key' => shape(
        'type' => \TType::I16,
      ),
      'val' => shape(
        'type' => \TType::I16,
      ),
      'format' => 'collection',
    ),
    14 => shape(
      'var' => 'terse_struct_field',
      'is_terse' => true,
      'type' => \TType::STRUCT,
      'class' => \facebook\thrift\test\terse_write\MyStruct::class,
    ),
    29 => shape(
      'var' => 'terse_union_field',
      'is_terse' => true,
      'type' => \TType::STRUCT,
      'class' => \facebook\thrift\test\terse_write\MyUnion::class,
    ),
    15 => shape(
      'var' => 'bool_field',
      'type' => \TType::BOOL,
    ),
    16 => shape(
      'var' => 'byte_field',
      'type' => \TType::BYTE,
    ),
    17 => shape(
      'var' => 'short_field',
      'type' => \TType::I16,
    ),
    18 => shape(
      'var' => 'int_field',
      'type' => \TType::I32,
    ),
    19 => shape(
      'var' => 'long_field',
      'type' => \TType::I64,
    ),
    20 => shape(
      'var' => 'float_field',
      'type' => \TType::FLOAT,
    ),
    21 => shape(
      'var' => 'double_field',
      'type' => \TType::DOUBLE,
    ),
    22 => shape(
      'var' => 'string_field',
      'type' => \TType::STRING,
    ),
    23 => shape(
      'var' => 'binary_field',
      'type' => \TType::STRING,
      'is_binary' => true,
    ),
    24 => shape(
      'var' => 'enum_field',
      'type' => \TType::I32,
      'enum' => \facebook\thrift\test\terse_write\MyEnum::class,
    ),
    25 => shape(
      'var' => 'list_field',
      'type' => \TType::LST,
      'etype' => \TType::I16,
      'elem' => shape(
        'type' => \TType::I16,
      ),
      'format' => 'collection',
    ),
    26 => shape(
      'var' => 'set_field',
      'type' => \TType::SET,
      'etype' => \TType::I16,
      'elem' => shape(
        'type' => \TType::I16,
      ),
      'format' => 'collection',
    ),
    27 => shape(
      'var' => 'map_field',
      'type' => \TType::MAP,
      'ktype' => \TType::I16,
      'vtype' => \TType::I16,
      'key' => shape(
        'type' => \TType::I16,
      ),
      'val' => shape(
        'type' => \TType::I16,
      ),
      'format' => 'collection',
    ),
    28 => shape(
      'var' => 'struct_field',
      'type' => \TType::STRUCT,
      'class' => \facebook\thrift\test\terse_write\MyStruct::class,
    ),
    30 => shape(
      'var' => 'union_field',
      'type' => \TType::STRUCT,
      'class' => \facebook\thrift\test\terse_write\MyUnion::class,
    ),
  ];
  const dict<string, int> FIELDMAP = dict[
    'terse_bool_field' => 1,
    'terse_byte_field' => 2,
    'terse_short_field' => 3,
    'terse_int_field' => 4,
    'terse_long_field' => 5,
    'terse_float_field' => 6,
    'terse_double_field' => 7,
    'terse_string_field' => 8,
    'terse_binary_field' => 9,
    'terse_enum_field' => 10,
    'terse_list_field' => 11,
    'terse_set_field' => 12,
    'terse_map_field' => 13,
    'terse_struct_field' => 14,
    'terse_union_field' => 29,
    'bool_field' => 15,
    'byte_field' => 16,
    'short_field' => 17,
    'int_field' => 18,
    'long_field' => 19,
    'float_field' => 20,
    'double_field' => 21,
    'string_field' => 22,
    'binary_field' => 23,
    'enum_field' => 24,
    'list_field' => 25,
    'set_field' => 26,
    'map_field' => 27,
    'struct_field' => 28,
    'union_field' => 30,
  ];

  const type TConstructorShape = shape(
    ?'terse_bool_field' => ?bool,
    ?'terse_byte_field' => ?int,
    ?'terse_short_field' => ?int,
    ?'terse_int_field' => ?int,
    ?'terse_long_field' => ?int,
    ?'terse_float_field' => ?float,
    ?'terse_double_field' => ?float,
    ?'terse_string_field' => ?string,
    ?'terse_binary_field' => ?string,
    ?'terse_enum_field' => ?\facebook\thrift\test\terse_write\MyEnum,
    ?'terse_list_field' => ?Vector<int>,
    ?'terse_set_field' => ?Set<int>,
    ?'terse_map_field' => ?Map<int, int>,
    ?'terse_struct_field' => ?\facebook\thrift\test\terse_write\MyStruct,
    ?'terse_union_field' => ?\facebook\thrift\test\terse_write\MyUnion,
    ?'bool_field' => ?bool,
    ?'byte_field' => ?int,
    ?'short_field' => ?int,
    ?'int_field' => ?int,
    ?'long_field' => ?int,
    ?'float_field' => ?float,
    ?'double_field' => ?float,
    ?'string_field' => ?string,
    ?'binary_field' => ?string,
    ?'enum_field' => ?\facebook\thrift\test\terse_write\MyEnum,
    ?'list_field' => ?Vector<int>,
    ?'set_field' => ?Set<int>,
    ?'map_field' => ?Map<int, int>,
    ?'struct_field' => ?\facebook\thrift\test\terse_write\MyStruct,
    ?'union_field' => ?\facebook\thrift\test\terse_write\MyUnion,
  );

  const type TShape = shape(
    'terse_bool_field' => bool,
    'terse_byte_field' => int,
    'terse_short_field' => int,
    'terse_int_field' => int,
    'terse_long_field' => int,
    'terse_float_field' => float,
    'terse_double_field' => float,
    'terse_string_field' => string,
    'terse_binary_field' => string,
    ?'terse_enum_field' => ?\facebook\thrift\test\terse_write\MyEnum,
    'terse_list_field' => vec<int>,
    'terse_set_field' => dict<int, bool>,
    'terse_map_field' => dict<int, int>,
    ?'terse_struct_field' => ?\facebook\thrift\test\terse_write\MyStruct::TShape,
    ?'terse_union_field' => ?\facebook\thrift\test\terse_write\MyUnion::TShape,
    'bool_field' => bool,
    'byte_field' => int,
    'short_field' => int,
    'int_field' => int,
    'long_field' => int,
    'float_field' => float,
    'double_field' => float,
    'string_field' => string,
    'binary_field' => string,
    ?'enum_field' => ?\facebook\thrift\test\terse_write\MyEnum,
    'list_field' => vec<int>,
    'set_field' => dict<int, bool>,
    'map_field' => dict<int, int>,
    ?'struct_field' => ?\facebook\thrift\test\terse_write\MyStruct::TShape,
    ?'union_field' => ?\facebook\thrift\test\terse_write\MyUnion::TShape,
    ...
  );
  const int STRUCTURAL_ID = 8495142353295299602;
  /**
   * Original thrift field:-
   * 1: bool terse_bool_field
   */
  public bool $terse_bool_field;
  /**
   * Original thrift field:-
   * 2: byte terse_byte_field
   */
  public int $terse_byte_field;
  /**
   * Original thrift field:-
   * 3: i16 terse_short_field
   */
  public int $terse_short_field;
  /**
   * Original thrift field:-
   * 4: i32 terse_int_field
   */
  public int $terse_int_field;
  /**
   * Original thrift field:-
   * 5: i64 terse_long_field
   */
  public int $terse_long_field;
  /**
   * Original thrift field:-
   * 6: float terse_float_field
   */
  public float $terse_float_field;
  /**
   * Original thrift field:-
   * 7: double terse_double_field
   */
  public float $terse_double_field;
  /**
   * Original thrift field:-
   * 8: string terse_string_field
   */
  public string $terse_string_field;
  /**
   * Original thrift field:-
   * 9: binary terse_binary_field
   */
  public string $terse_binary_field;
  /**
   * Original thrift field:-
   * 10: terse_write.MyEnum terse_enum_field
   */
  public ?\facebook\thrift\test\terse_write\MyEnum $terse_enum_field;
  /**
   * Original thrift field:-
   * 11: list<i16> terse_list_field
   */
  public Vector<int> $terse_list_field;
  /**
   * Original thrift field:-
   * 12: set<i16> terse_set_field
   */
  public Set<int> $terse_set_field;
  /**
   * Original thrift field:-
   * 13: map<i16, i16> terse_map_field
   */
  public Map<int, int> $terse_map_field;
  /**
   * Original thrift field:-
   * 14: terse_write.MyStruct terse_struct_field
   */
  public ?\facebook\thrift\test\terse_write\MyStruct $terse_struct_field;
  /**
   * Original thrift field:-
   * 29: terse_write.MyUnion terse_union_field
   */
  public ?\facebook\thrift\test\terse_write\MyUnion $terse_union_field;
  /**
   * Original thrift field:-
   * 15: bool bool_field
   */
  public bool $bool_field;
  /**
   * Original thrift field:-
   * 16: byte byte_field
   */
  public int $byte_field;
  /**
   * Original thrift field:-
   * 17: i16 short_field
   */
  public int $short_field;
  /**
   * Original thrift field:-
   * 18: i32 int_field
   */
  public int $int_field;
  /**
   * Original thrift field:-
   * 19: i64 long_field
   */
  public int $long_field;
  /**
   * Original thrift field:-
   * 20: float float_field
   */
  public float $float_field;
  /**
   * Original thrift field:-
   * 21: double double_field
   */
  public float $double_field;
  /**
   * Original thrift field:-
   * 22: string string_field
   */
  public string $string_field;
  /**
   * Original thrift field:-
   * 23: binary binary_field
   */
  public string $binary_field;
  /**
   * Original thrift field:-
   * 24: terse_write.MyEnum enum_field
   */
  public ?\facebook\thrift\test\terse_write\MyEnum $enum_field;
  /**
   * Original thrift field:-
   * 25: list<i16> list_field
   */
  public Vector<int> $list_field;
  /**
   * Original thrift field:-
   * 26: set<i16> set_field
   */
  public Set<int> $set_field;
  /**
   * Original thrift field:-
   * 27: map<i16, i16> map_field
   */
  public Map<int, int> $map_field;
  /**
   * Original thrift field:-
   * 28: terse_write.MyStruct struct_field
   */
  public ?\facebook\thrift\test\terse_write\MyStruct $struct_field;
  /**
   * Original thrift field:-
   * 30: terse_write.MyUnion union_field
   */
  public ?\facebook\thrift\test\terse_write\MyUnion $union_field;

  public function __construct(?bool $terse_bool_field = null, ?int $terse_byte_field = null, ?int $terse_short_field = null, ?int $terse_int_field = null, ?int $terse_long_field = null, ?float $terse_float_field = null, ?float $terse_double_field = null, ?string $terse_string_field = null, ?string $terse_binary_field = null, ?\facebook\thrift\test\terse_write\MyEnum $terse_enum_field = null, ?Vector<int> $terse_list_field = null, ?Set<int> $terse_set_field = null, ?Map<int, int> $terse_map_field = null, ?\facebook\thrift\test\terse_write\MyStruct $terse_struct_field = null, ?\facebook\thrift\test\terse_write\MyUnion $terse_union_field = null, ?bool $bool_field = null, ?int $byte_field = null, ?int $short_field = null, ?int $int_field = null, ?int $long_field = null, ?float $float_field = null, ?float $double_field = null, ?string $string_field = null, ?string $binary_field = null, ?\facebook\thrift\test\terse_write\MyEnum $enum_field = null, ?Vector<int> $list_field = null, ?Set<int> $set_field = null, ?Map<int, int> $map_field = null, ?\facebook\thrift\test\terse_write\MyStruct $struct_field = null, ?\facebook\thrift\test\terse_write\MyUnion $union_field = null)[] {
    $this->terse_bool_field = $terse_bool_field ?? false;
    $this->terse_byte_field = $terse_byte_field ?? 0;
    $this->terse_short_field = $terse_short_field ?? 0;
    $this->terse_int_field = $terse_int_field ?? 0;
    $this->terse_long_field = $terse_long_field ?? 0;
    $this->terse_float_field = $terse_float_field ?? 0.0;
    $this->terse_double_field = $terse_double_field ?? 0.0;
    $this->terse_string_field = $terse_string_field ?? '';
    $this->terse_binary_field = $terse_binary_field ?? '';
    $this->terse_enum_field = $terse_enum_field;
    $this->terse_list_field = $terse_list_field ?? Vector {};
    $this->terse_set_field = $terse_set_field ?? Set {};
    $this->terse_map_field = $terse_map_field ?? Map {};
    $this->terse_struct_field = $terse_struct_field;
    $this->terse_union_field = $terse_union_field;
    $this->bool_field = $bool_field ?? false;
    $this->byte_field = $byte_field ?? 0;
    $this->short_field = $short_field ?? 0;
    $this->int_field = $int_field ?? 0;
    $this->long_field = $long_field ?? 0;
    $this->float_field = $float_field ?? 0.0;
    $this->double_field = $double_field ?? 0.0;
    $this->string_field = $string_field ?? '';
    $this->binary_field = $binary_field ?? '';
    $this->enum_field = $enum_field;
    $this->list_field = $list_field ?? Vector {};
    $this->set_field = $set_field ?? Set {};
    $this->map_field = $map_field ?? Map {};
    $this->struct_field = $struct_field;
    $this->union_field = $union_field;
  }

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

  public static function fromShape(self::TConstructorShape $shape)[]: this {
    return new static(
      Shapes::idx($shape, 'terse_bool_field'),
      Shapes::idx($shape, 'terse_byte_field'),
      Shapes::idx($shape, 'terse_short_field'),
      Shapes::idx($shape, 'terse_int_field'),
      Shapes::idx($shape, 'terse_long_field'),
      Shapes::idx($shape, 'terse_float_field'),
      Shapes::idx($shape, 'terse_double_field'),
      Shapes::idx($shape, 'terse_string_field'),
      Shapes::idx($shape, 'terse_binary_field'),
      Shapes::idx($shape, 'terse_enum_field'),
      Shapes::idx($shape, 'terse_list_field'),
      Shapes::idx($shape, 'terse_set_field'),
      Shapes::idx($shape, 'terse_map_field'),
      Shapes::idx($shape, 'terse_struct_field'),
      Shapes::idx($shape, 'terse_union_field'),
      Shapes::idx($shape, 'bool_field'),
      Shapes::idx($shape, 'byte_field'),
      Shapes::idx($shape, 'short_field'),
      Shapes::idx($shape, 'int_field'),
      Shapes::idx($shape, 'long_field'),
      Shapes::idx($shape, 'float_field'),
      Shapes::idx($shape, 'double_field'),
      Shapes::idx($shape, 'string_field'),
      Shapes::idx($shape, 'binary_field'),
      Shapes::idx($shape, 'enum_field'),
      Shapes::idx($shape, 'list_field'),
      Shapes::idx($shape, 'set_field'),
      Shapes::idx($shape, 'map_field'),
      Shapes::idx($shape, 'struct_field'),
      Shapes::idx($shape, 'union_field'),
    );
  }

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

  public function clearTerseFields()[write_props]: void {
    $this->terse_bool_field = false;
    $this->terse_byte_field = 0;
    $this->terse_short_field = 0;
    $this->terse_int_field = 0;
    $this->terse_long_field = 0;
    $this->terse_float_field = 0.0;
    $this->terse_double_field = 0.0;
    $this->terse_string_field = '';
    $this->terse_binary_field = '';
    $this->terse_enum_field = null;
    $this->terse_list_field = Vector {};
    $this->terse_set_field = Set {};
    $this->terse_map_field = Map {};
    $this->terse_struct_field = null;
    $this->terse_union_field = null;
  }

  public static function getStructMetadata()[]: \tmeta_ThriftStruct {
    return \tmeta_ThriftStruct::fromShape(
      shape(
        "name" => "terse_write.FieldLevelTerseStruct",
        "fields" => vec[
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 1,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_BOOL_TYPE,
                )
              ),
              "name" => "terse_bool_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 2,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_BYTE_TYPE,
                )
              ),
              "name" => "terse_byte_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 3,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I16_TYPE,
                )
              ),
              "name" => "terse_short_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 4,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I32_TYPE,
                )
              ),
              "name" => "terse_int_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 5,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I64_TYPE,
                )
              ),
              "name" => "terse_long_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 6,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_FLOAT_TYPE,
                )
              ),
              "name" => "terse_float_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 7,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_DOUBLE_TYPE,
                )
              ),
              "name" => "terse_double_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 8,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                )
              ),
              "name" => "terse_string_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 9,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_BINARY_TYPE,
                )
              ),
              "name" => "terse_binary_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 10,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_enum" => \tmeta_ThriftEnumType::fromShape(
                    shape(
                      "name" => "terse_write.MyEnum",
                    )
                  ),
                )
              ),
              "name" => "terse_enum_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 11,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_list" => \tmeta_ThriftListType::fromShape(
                    shape(
                      "valueType" => \tmeta_ThriftType::fromShape(
                        shape(
                          "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I16_TYPE,
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "terse_list_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 12,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_set" => \tmeta_ThriftSetType::fromShape(
                    shape(
                      "valueType" => \tmeta_ThriftType::fromShape(
                        shape(
                          "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I16_TYPE,
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "terse_set_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 13,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_map" => \tmeta_ThriftMapType::fromShape(
                    shape(
                      "keyType" => \tmeta_ThriftType::fromShape(
                        shape(
                          "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I16_TYPE,
                        )
                      ),
                      "valueType" => \tmeta_ThriftType::fromShape(
                        shape(
                          "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I16_TYPE,
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "terse_map_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 14,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_struct" => \tmeta_ThriftStructType::fromShape(
                    shape(
                      "name" => "terse_write.MyStruct",
                    )
                  ),
                )
              ),
              "name" => "terse_struct_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 29,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_struct" => \tmeta_ThriftStructType::fromShape(
                    shape(
                      "name" => "terse_write.MyUnion",
                    )
                  ),
                )
              ),
              "name" => "terse_union_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 15,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_BOOL_TYPE,
                )
              ),
              "name" => "bool_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 16,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_BYTE_TYPE,
                )
              ),
              "name" => "byte_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 17,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I16_TYPE,
                )
              ),
              "name" => "short_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 18,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I32_TYPE,
                )
              ),
              "name" => "int_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 19,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I64_TYPE,
                )
              ),
              "name" => "long_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 20,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_FLOAT_TYPE,
                )
              ),
              "name" => "float_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 21,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_DOUBLE_TYPE,
                )
              ),
              "name" => "double_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 22,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                )
              ),
              "name" => "string_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 23,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_BINARY_TYPE,
                )
              ),
              "name" => "binary_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 24,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_enum" => \tmeta_ThriftEnumType::fromShape(
                    shape(
                      "name" => "terse_write.MyEnum",
                    )
                  ),
                )
              ),
              "name" => "enum_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 25,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_list" => \tmeta_ThriftListType::fromShape(
                    shape(
                      "valueType" => \tmeta_ThriftType::fromShape(
                        shape(
                          "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I16_TYPE,
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "list_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 26,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_set" => \tmeta_ThriftSetType::fromShape(
                    shape(
                      "valueType" => \tmeta_ThriftType::fromShape(
                        shape(
                          "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I16_TYPE,
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "set_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 27,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_map" => \tmeta_ThriftMapType::fromShape(
                    shape(
                      "keyType" => \tmeta_ThriftType::fromShape(
                        shape(
                          "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I16_TYPE,
                        )
                      ),
                      "valueType" => \tmeta_ThriftType::fromShape(
                        shape(
                          "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I16_TYPE,
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "map_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 28,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_struct" => \tmeta_ThriftStructType::fromShape(
                    shape(
                      "name" => "terse_write.MyStruct",
                    )
                  ),
                )
              ),
              "name" => "struct_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 30,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_struct" => \tmeta_ThriftStructType::fromShape(
                    shape(
                      "name" => "terse_write.MyUnion",
                    )
                  ),
                )
              ),
              "name" => "union_field",
            )
          ),
        ],
        "is_union" => false,
      )
    );
  }

  public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations {
    return shape(
      'struct' => dict[],
      'fields' => dict[
        'terse_bool_field' => shape(
          'field' => dict[
            '\facebook\thrift\annotation\TerseWrite' => \facebook\thrift\annotation\TerseWrite::fromShape(
              shape(
              )
            ),
          ],
          'type' => dict[],
        ),
        'terse_byte_field' => shape(
          'field' => dict[
            '\facebook\thrift\annotation\TerseWrite' => \facebook\thrift\annotation\TerseWrite::fromShape(
              shape(
              )
            ),
          ],
          'type' => dict[],
        ),
        'terse_short_field' => shape(
          'field' => dict[
            '\facebook\thrift\annotation\TerseWrite' => \facebook\thrift\annotation\TerseWrite::fromShape(
              shape(
              )
            ),
          ],
          'type' => dict[],
        ),
        'terse_int_field' => shape(
          'field' => dict[
            '\facebook\thrift\annotation\TerseWrite' => \facebook\thrift\annotation\TerseWrite::fromShape(
              shape(
              )
            ),
          ],
          'type' => dict[],
        ),
        'terse_long_field' => shape(
          'field' => dict[
            '\facebook\thrift\annotation\TerseWrite' => \facebook\thrift\annotation\TerseWrite::fromShape(
              shape(
              )
            ),
          ],
          'type' => dict[],
        ),
        'terse_float_field' => shape(
          'field' => dict[
            '\facebook\thrift\annotation\TerseWrite' => \facebook\thrift\annotation\TerseWrite::fromShape(
              shape(
              )
            ),
          ],
          'type' => dict[],
        ),
        'terse_double_field' => shape(
          'field' => dict[
            '\facebook\thrift\annotation\TerseWrite' => \facebook\thrift\annotation\TerseWrite::fromShape(
              shape(
              )
            ),
          ],
          'type' => dict[],
        ),
        'terse_string_field' => shape(
          'field' => dict[
            '\facebook\thrift\annotation\TerseWrite' => \facebook\thrift\annotation\TerseWrite::fromShape(
              shape(
              )
            ),
          ],
          'type' => dict[],
        ),
        'terse_binary_field' => shape(
          'field' => dict[
            '\facebook\thrift\annotation\TerseWrite' => \facebook\thrift\annotation\TerseWrite::fromShape(
              shape(
              )
            ),
          ],
          'type' => dict[],
        ),
        'terse_enum_field' => shape(
          'field' => dict[
            '\facebook\thrift\annotation\TerseWrite' => \facebook\thrift\annotation\TerseWrite::fromShape(
              shape(
              )
            ),
          ],
          'type' => dict[],
        ),
        'terse_list_field' => shape(
          'field' => dict[
            '\facebook\thrift\annotation\TerseWrite' => \facebook\thrift\annotation\TerseWrite::fromShape(
              shape(
              )
            ),
          ],
          'type' => dict[],
        ),
        'terse_set_field' => shape(
          'field' => dict[
            '\facebook\thrift\annotation\TerseWrite' => \facebook\thrift\annotation\TerseWrite::fromShape(
              shape(
              )
            ),
          ],
          'type' => dict[],
        ),
        'terse_map_field' => shape(
          'field' => dict[
            '\facebook\thrift\annotation\TerseWrite' => \facebook\thrift\annotation\TerseWrite::fromShape(
              shape(
              )
            ),
          ],
          'type' => dict[],
        ),
        'terse_struct_field' => shape(
          'field' => dict[
            '\facebook\thrift\annotation\TerseWrite' => \facebook\thrift\annotation\TerseWrite::fromShape(
              shape(
              )
            ),
          ],
          'type' => dict[],
        ),
        'terse_union_field' => shape(
          'field' => dict[
            '\facebook\thrift\annotation\TerseWrite' => \facebook\thrift\annotation\TerseWrite::fromShape(
              shape(
              )
            ),
          ],
          'type' => dict[],
        ),
      ],
    );
  }

  public static function __fromShape(self::TShape $shape)[]: this {
    return new static(
      $shape['terse_bool_field'],
      $shape['terse_byte_field'],
      $shape['terse_short_field'],
      $shape['terse_int_field'],
      $shape['terse_long_field'],
      $shape['terse_float_field'],
      $shape['terse_double_field'],
      $shape['terse_string_field'],
      $shape['terse_binary_field'],
      Shapes::idx($shape, 'terse_enum_field'),
      $shape['terse_list_field'] |> new Vector($$),
      new Set(Keyset\keys($shape['terse_set_field'])),
      $shape['terse_map_field'] |> new Map($$),
      Shapes::idx($shape, 'terse_struct_field') === null ? null : (\facebook\thrift\test\terse_write\MyStruct::__fromShape($shape['terse_struct_field'])),
      Shapes::idx($shape, 'terse_union_field') === null ? null : (\facebook\thrift\test\terse_write\MyUnion::__fromShape($shape['terse_union_field'])),
      $shape['bool_field'],
      $shape['byte_field'],
      $shape['short_field'],
      $shape['int_field'],
      $shape['long_field'],
      $shape['float_field'],
      $shape['double_field'],
      $shape['string_field'],
      $shape['binary_field'],
      Shapes::idx($shape, 'enum_field'),
      $shape['list_field'] |> new Vector($$),
      new Set(Keyset\keys($shape['set_field'])),
      $shape['map_field'] |> new Map($$),
      Shapes::idx($shape, 'struct_field') === null ? null : (\facebook\thrift\test\terse_write\MyStruct::__fromShape($shape['struct_field'])),
      Shapes::idx($shape, 'union_field') === null ? null : (\facebook\thrift\test\terse_write\MyUnion::__fromShape($shape['union_field'])),
    );
  }

  public function __toShape()[]: self::TShape {
    return shape(
      'terse_bool_field' => $this->terse_bool_field,
      'terse_byte_field' => $this->terse_byte_field,
      'terse_short_field' => $this->terse_short_field,
      'terse_int_field' => $this->terse_int_field,
      'terse_long_field' => $this->terse_long_field,
      'terse_float_field' => $this->terse_float_field,
      'terse_double_field' => $this->terse_double_field,
      'terse_string_field' => $this->terse_string_field,
      'terse_binary_field' => $this->terse_binary_field,
      'terse_enum_field' => $this->terse_enum_field,
      'terse_list_field' => vec($this->terse_list_field),
      'terse_set_field' => ThriftUtil::toDArray(Dict\fill_keys($this->terse_set_field->toValuesArray(), true), static::class),
      'terse_map_field' => dict($this->terse_map_field),
      'terse_struct_field' => $this->terse_struct_field?->__toShape(),
      'terse_union_field' => $this->terse_union_field?->__toShape(),
      'bool_field' => $this->bool_field,
      'byte_field' => $this->byte_field,
      'short_field' => $this->short_field,
      'int_field' => $this->int_field,
      'long_field' => $this->long_field,
      'float_field' => $this->float_field,
      'double_field' => $this->double_field,
      'string_field' => $this->string_field,
      'binary_field' => $this->binary_field,
      'enum_field' => $this->enum_field,
      'list_field' => vec($this->list_field),
      'set_field' => ThriftUtil::toDArray(Dict\fill_keys($this->set_field->toValuesArray(), true), static::class),
      'map_field' => dict($this->map_field),
      'struct_field' => $this->struct_field?->__toShape(),
      'union_field' => $this->union_field?->__toShape(),
    );
  }
  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, 'terse_bool_field') !== null) {
      $this->terse_bool_field = HH\FIXME\UNSAFE_CAST<mixed, bool>($parsed['terse_bool_field']);
    }
    if (idx($parsed, 'terse_byte_field') !== null) {
      $_tmp0 = (int)HH\FIXME\UNSAFE_CAST<mixed, int>($parsed['terse_byte_field']);
      if ($_tmp0 > 0x7f) {
        throw new \TProtocolException("number exceeds limit in field");
      } else {
        $this->terse_byte_field = (int)$_tmp0;
      }
    }
    if (idx($parsed, 'terse_short_field') !== null) {
      $_tmp1 = (int)HH\FIXME\UNSAFE_CAST<mixed, int>($parsed['terse_short_field']);
      if ($_tmp1 > 0x7fff) {
        throw new \TProtocolException("number exceeds limit in field");
      } else {
        $this->terse_short_field = (int)$_tmp1;
      }
    }
    if (idx($parsed, 'terse_int_field') !== null) {
      $_tmp2 = (int)HH\FIXME\UNSAFE_CAST<mixed, int>($parsed['terse_int_field']);
      if ($_tmp2 > 0x7fffffff) {
        throw new \TProtocolException("number exceeds limit in field");
      } else {
        $this->terse_int_field = (int)$_tmp2;
      }
    }
    if (idx($parsed, 'terse_long_field') !== null) {
      $this->terse_long_field = HH\FIXME\UNSAFE_CAST<mixed, int>($parsed['terse_long_field']);
    }
    if (idx($parsed, 'terse_float_field') !== null) {
      $this->terse_float_field = HH\FIXME\UNSAFE_CAST<mixed, float>($parsed['terse_float_field']);
    }
    if (idx($parsed, 'terse_double_field') !== null) {
      $this->terse_double_field = HH\FIXME\UNSAFE_CAST<mixed, float>($parsed['terse_double_field']);
    }
    if (idx($parsed, 'terse_string_field') !== null) {
      $this->terse_string_field = HH\FIXME\UNSAFE_CAST<mixed, string>($parsed['terse_string_field']);
    }
    if (idx($parsed, 'terse_binary_field') !== null) {
      $this->terse_binary_field = HH\FIXME\UNSAFE_CAST<mixed, string>($parsed['terse_binary_field']);
    }
    if (idx($parsed, 'terse_enum_field') !== null) {
      $this->terse_enum_field = \facebook\thrift\test\terse_write\MyEnum::coerce(HH\FIXME\UNSAFE_CAST<mixed, \facebook\thrift\test\terse_write\MyEnum>($parsed['terse_enum_field']));
    }
    if (idx($parsed, 'terse_list_field') !== null) {
      $_json6 = HH\FIXME\UNSAFE_CAST<mixed, Vector<int>>($parsed['terse_list_field']);
      $_container7 = Vector {};
      foreach($_json6 as $_key4 => $_value5) {
        $_elem8 = 0;
        $_tmp9 = (int)$_value5;
        if ($_tmp9 > 0x7fff) {
          throw new \TProtocolException("number exceeds limit in field");
        } else {
          $_elem8 = (int)$_tmp9;
        }
        $_container7 []= $_elem8;
      }
      $this->terse_list_field = $_container7;
    }
    if (idx($parsed, 'terse_set_field') !== null) {
      $_json13 = HH\FIXME\UNSAFE_CAST<mixed, Set<int>>($parsed['terse_set_field']);
      $_container14 = Set {};
      foreach($_json13 as $_key11 => $_value12) {
        $_elem15 = 0;
        $_tmp16 = (int)$_value12;
        if ($_tmp16 > 0x7fff) {
          throw new \TProtocolException("number exceeds limit in field");
        } else {
          $_elem15 = (int)$_tmp16;
        }
        $_container14->add($_elem15);
      }
      $this->terse_set_field = $_container14;
    }
    if (idx($parsed, 'terse_map_field') !== null) {
      $_json20 = HH\FIXME\UNSAFE_CAST<mixed, Map<int, int>>($parsed['terse_map_field']);
      $_container21 = Map {};
      foreach($_json20 as $_key18 => $_value19) {
        $_value22 = 0;
        $_tmp23 = (int)$_value19;
        if ($_tmp23 > 0x7fff) {
          throw new \TProtocolException("number exceeds limit in field");
        } else {
          $_value22 = (int)$_tmp23;
        }
        $_container21[$_key18] = $_value22;
      }
      $this->terse_map_field = $_container21;
    }
    if (idx($parsed, 'terse_struct_field') !== null) {
      $_tmp24 = \json_encode(HH\FIXME\UNSAFE_CAST<mixed, \facebook\thrift\test\terse_write\MyStruct>($parsed['terse_struct_field']));
      $_tmp25 = \facebook\thrift\test\terse_write\MyStruct::withDefaultValues();
      $_tmp25->readFromJson($_tmp24);
      $this->terse_struct_field = $_tmp25;
    }
    if (idx($parsed, 'terse_union_field') !== null) {
      $_tmp26 = \json_encode(HH\FIXME\UNSAFE_CAST<mixed, \facebook\thrift\test\terse_write\MyUnion>($parsed['terse_union_field']));
      $_tmp27 = \facebook\thrift\test\terse_write\MyUnion::withDefaultValues();
      $_tmp27->readFromJson($_tmp26);
      $this->terse_union_field = $_tmp27;
    }
    if (idx($parsed, 'bool_field') !== null) {
      $this->bool_field = HH\FIXME\UNSAFE_CAST<mixed, bool>($parsed['bool_field']);
    }
    if (idx($parsed, 'byte_field') !== null) {
      $_tmp28 = (int)HH\FIXME\UNSAFE_CAST<mixed, int>($parsed['byte_field']);
      if ($_tmp28 > 0x7f) {
        throw new \TProtocolException("number exceeds limit in field");
      } else {
        $this->byte_field = (int)$_tmp28;
      }
    }
    if (idx($parsed, 'short_field') !== null) {
      $_tmp29 = (int)HH\FIXME\UNSAFE_CAST<mixed, int>($parsed['short_field']);
      if ($_tmp29 > 0x7fff) {
        throw new \TProtocolException("number exceeds limit in field");
      } else {
        $this->short_field = (int)$_tmp29;
      }
    }
    if (idx($parsed, 'int_field') !== null) {
      $_tmp30 = (int)HH\FIXME\UNSAFE_CAST<mixed, int>($parsed['int_field']);
      if ($_tmp30 > 0x7fffffff) {
        throw new \TProtocolException("number exceeds limit in field");
      } else {
        $this->int_field = (int)$_tmp30;
      }
    }
    if (idx($parsed, 'long_field') !== null) {
      $this->long_field = HH\FIXME\UNSAFE_CAST<mixed, int>($parsed['long_field']);
    }
    if (idx($parsed, 'float_field') !== null) {
      $this->float_field = HH\FIXME\UNSAFE_CAST<mixed, float>($parsed['float_field']);
    }
    if (idx($parsed, 'double_field') !== null) {
      $this->double_field = HH\FIXME\UNSAFE_CAST<mixed, float>($parsed['double_field']);
    }
    if (idx($parsed, 'string_field') !== null) {
      $this->string_field = HH\FIXME\UNSAFE_CAST<mixed, string>($parsed['string_field']);
    }
    if (idx($parsed, 'binary_field') !== null) {
      $this->binary_field = HH\FIXME\UNSAFE_CAST<mixed, string>($parsed['binary_field']);
    }
    if (idx($parsed, 'enum_field') !== null) {
      $this->enum_field = \facebook\thrift\test\terse_write\MyEnum::coerce(HH\FIXME\UNSAFE_CAST<mixed, \facebook\thrift\test\terse_write\MyEnum>($parsed['enum_field']));
    }
    if (idx($parsed, 'list_field') !== null) {
      $_json34 = HH\FIXME\UNSAFE_CAST<mixed, Vector<int>>($parsed['list_field']);
      $_container35 = Vector {};
      foreach($_json34 as $_key32 => $_value33) {
        $_elem36 = 0;
        $_tmp37 = (int)$_value33;
        if ($_tmp37 > 0x7fff) {
          throw new \TProtocolException("number exceeds limit in field");
        } else {
          $_elem36 = (int)$_tmp37;
        }
        $_container35 []= $_elem36;
      }
      $this->list_field = $_container35;
    }
    if (idx($parsed, 'set_field') !== null) {
      $_json41 = HH\FIXME\UNSAFE_CAST<mixed, Set<int>>($parsed['set_field']);
      $_container42 = Set {};
      foreach($_json41 as $_key39 => $_value40) {
        $_elem43 = 0;
        $_tmp44 = (int)$_value40;
        if ($_tmp44 > 0x7fff) {
          throw new \TProtocolException("number exceeds limit in field");
        } else {
          $_elem43 = (int)$_tmp44;
        }
        $_container42->add($_elem43);
      }
      $this->set_field = $_container42;
    }
    if (idx($parsed, 'map_field') !== null) {
      $_json48 = HH\FIXME\UNSAFE_CAST<mixed, Map<int, int>>($parsed['map_field']);
      $_container49 = Map {};
      foreach($_json48 as $_key46 => $_value47) {
        $_value50 = 0;
        $_tmp51 = (int)$_value47;
        if ($_tmp51 > 0x7fff) {
          throw new \TProtocolException("number exceeds limit in field");
        } else {
          $_value50 = (int)$_tmp51;
        }
        $_container49[$_key46] = $_value50;
      }
      $this->map_field = $_container49;
    }
    if (idx($parsed, 'struct_field') !== null) {
      $_tmp52 = \json_encode(HH\FIXME\UNSAFE_CAST<mixed, \facebook\thrift\test\terse_write\MyStruct>($parsed['struct_field']));
      $_tmp53 = \facebook\thrift\test\terse_write\MyStruct::withDefaultValues();
      $_tmp53->readFromJson($_tmp52);
      $this->struct_field = $_tmp53;
    }
    if (idx($parsed, 'union_field') !== null) {
      $_tmp54 = \json_encode(HH\FIXME\UNSAFE_CAST<mixed, \facebook\thrift\test\terse_write\MyUnion>($parsed['union_field']));
      $_tmp55 = \facebook\thrift\test\terse_write\MyUnion::withDefaultValues();
      $_tmp55->readFromJson($_tmp54);
      $this->union_field = $_tmp55;
    }
  }

}

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

  const \ThriftStructTypes::TSpec SPEC = dict[
    1 => shape(
      'var' => 'bool_field',
      'is_terse' => true,
      'type' => \TType::BOOL,
    ),
    2 => shape(
      'var' => 'byte_field',
      'is_terse' => true,
      'type' => \TType::BYTE,
    ),
    3 => shape(
      'var' => 'short_field',
      'is_terse' => true,
      'type' => \TType::I16,
    ),
    4 => shape(
      'var' => 'int_field',
      'is_terse' => true,
      'type' => \TType::I32,
    ),
    5 => shape(
      'var' => 'long_field',
      'is_terse' => true,
      'type' => \TType::I64,
    ),
    6 => shape(
      'var' => 'float_field',
      'is_terse' => true,
      'type' => \TType::FLOAT,
    ),
    7 => shape(
      'var' => 'double_field',
      'is_terse' => true,
      'type' => \TType::DOUBLE,
    ),
    8 => shape(
      'var' => 'string_field',
      'is_terse' => true,
      'type' => \TType::STRING,
    ),
    9 => shape(
      'var' => 'binary_field',
      'is_terse' => true,
      'type' => \TType::STRING,
      'is_binary' => true,
    ),
    10 => shape(
      'var' => 'enum_field',
      'is_terse' => true,
      'type' => \TType::I32,
      'enum' => \facebook\thrift\test\terse_write\MyEnum::class,
    ),
    11 => shape(
      'var' => 'list_field',
      'is_terse' => true,
      'type' => \TType::LST,
      'etype' => \TType::I16,
      'elem' => shape(
        'type' => \TType::I16,
      ),
      'format' => 'collection',
    ),
    12 => shape(
      'var' => 'set_field',
      'is_terse' => true,
      'type' => \TType::SET,
      'etype' => \TType::I16,
      'elem' => shape(
        'type' => \TType::I16,
      ),
      'format' => 'collection',
    ),
    13 => shape(
      'var' => 'map_field',
      'is_terse' => true,
      'type' => \TType::MAP,
      'ktype' => \TType::I16,
      'vtype' => \TType::I16,
      'key' => shape(
        'type' => \TType::I16,
      ),
      'val' => shape(
        'type' => \TType::I16,
      ),
      'format' => 'collection',
    ),
    14 => shape(
      'var' => 'struct_field',
      'is_terse' => true,
      'type' => \TType::STRUCT,
      'class' => \facebook\thrift\test\terse_write\MyStructWithCustomDefault::class,
    ),
  ];
  const dict<string, int> FIELDMAP = dict[
    'bool_field' => 1,
    'byte_field' => 2,
    'short_field' => 3,
    'int_field' => 4,
    'long_field' => 5,
    'float_field' => 6,
    'double_field' => 7,
    'string_field' => 8,
    'binary_field' => 9,
    'enum_field' => 10,
    'list_field' => 11,
    'set_field' => 12,
    'map_field' => 13,
    'struct_field' => 14,
  ];

  const type TConstructorShape = shape(
    ?'bool_field' => ?bool,
    ?'byte_field' => ?int,
    ?'short_field' => ?int,
    ?'int_field' => ?int,
    ?'long_field' => ?int,
    ?'float_field' => ?float,
    ?'double_field' => ?float,
    ?'string_field' => ?string,
    ?'binary_field' => ?string,
    ?'enum_field' => ?\facebook\thrift\test\terse_write\MyEnum,
    ?'list_field' => ?Vector<int>,
    ?'set_field' => ?Set<int>,
    ?'map_field' => ?Map<int, int>,
    ?'struct_field' => ?\facebook\thrift\test\terse_write\MyStructWithCustomDefault,
  );

  const type TShape = shape(
    'bool_field' => bool,
    'byte_field' => int,
    'short_field' => int,
    'int_field' => int,
    'long_field' => int,
    'float_field' => float,
    'double_field' => float,
    'string_field' => string,
    'binary_field' => string,
    ?'enum_field' => ?\facebook\thrift\test\terse_write\MyEnum,
    'list_field' => vec<int>,
    'set_field' => dict<int, bool>,
    'map_field' => dict<int, int>,
    ?'struct_field' => ?\facebook\thrift\test\terse_write\MyStructWithCustomDefault::TShape,
    ...
  );
  const int STRUCTURAL_ID = 3545739898930729460;
  /**
   * Original thrift field:-
   * 1: bool bool_field
   */
  public bool $bool_field;
  /**
   * Original thrift field:-
   * 2: byte byte_field
   */
  public int $byte_field;
  /**
   * Original thrift field:-
   * 3: i16 short_field
   */
  public int $short_field;
  /**
   * Original thrift field:-
   * 4: i32 int_field
   */
  public int $int_field;
  /**
   * Original thrift field:-
   * 5: i64 long_field
   */
  public int $long_field;
  /**
   * Original thrift field:-
   * 6: float float_field
   */
  public float $float_field;
  /**
   * Original thrift field:-
   * 7: double double_field
   */
  public float $double_field;
  /**
   * Original thrift field:-
   * 8: string string_field
   */
  public string $string_field;
  /**
   * Original thrift field:-
   * 9: binary binary_field
   */
  public string $binary_field;
  /**
   * Original thrift field:-
   * 10: terse_write.MyEnum enum_field
   */
  public ?\facebook\thrift\test\terse_write\MyEnum $enum_field;
  /**
   * Original thrift field:-
   * 11: list<i16> list_field
   */
  public Vector<int> $list_field;
  /**
   * Original thrift field:-
   * 12: set<i16> set_field
   */
  public Set<int> $set_field;
  /**
   * Original thrift field:-
   * 13: map<i16, i16> map_field
   */
  public Map<int, int> $map_field;
  /**
   * Original thrift field:-
   * 14: terse_write.MyStructWithCustomDefault struct_field
   */
  public ?\facebook\thrift\test\terse_write\MyStructWithCustomDefault $struct_field;

  public function __construct(?bool $bool_field = null, ?int $byte_field = null, ?int $short_field = null, ?int $int_field = null, ?int $long_field = null, ?float $float_field = null, ?float $double_field = null, ?string $string_field = null, ?string $binary_field = null, ?\facebook\thrift\test\terse_write\MyEnum $enum_field = null, ?Vector<int> $list_field = null, ?Set<int> $set_field = null, ?Map<int, int> $map_field = null, ?\facebook\thrift\test\terse_write\MyStructWithCustomDefault $struct_field = null)[] {
    $this->bool_field = $bool_field ?? true;
    $this->byte_field = $byte_field ?? 1;
    $this->short_field = $short_field ?? 2;
    $this->int_field = $int_field ?? 3;
    $this->long_field = $long_field ?? 4;
    $this->float_field = $float_field ?? 5.0;
    $this->double_field = $double_field ?? 6.0;
    $this->string_field = $string_field ?? "7";
    $this->binary_field = $binary_field ?? "8";
    $this->enum_field = $enum_field ?? \facebook\thrift\test\terse_write\MyEnum::ME1;
    $this->list_field = $list_field ?? Vector {
      1,
    };
    $this->set_field = $set_field ?? Set {
      1,
    };
    $this->map_field = $map_field ?? Map {
      1 => 1,
    };
    $this->struct_field = $struct_field;
  }

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

  public static function fromShape(self::TConstructorShape $shape)[]: this {
    return new static(
      Shapes::idx($shape, 'bool_field'),
      Shapes::idx($shape, 'byte_field'),
      Shapes::idx($shape, 'short_field'),
      Shapes::idx($shape, 'int_field'),
      Shapes::idx($shape, 'long_field'),
      Shapes::idx($shape, 'float_field'),
      Shapes::idx($shape, 'double_field'),
      Shapes::idx($shape, 'string_field'),
      Shapes::idx($shape, 'binary_field'),
      Shapes::idx($shape, 'enum_field'),
      Shapes::idx($shape, 'list_field'),
      Shapes::idx($shape, 'set_field'),
      Shapes::idx($shape, 'map_field'),
      Shapes::idx($shape, 'struct_field'),
    );
  }

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

  public function clearTerseFields()[write_props]: void {
    $this->bool_field = false;
    $this->byte_field = 0;
    $this->short_field = 0;
    $this->int_field = 0;
    $this->long_field = 0;
    $this->float_field = 0.0;
    $this->double_field = 0.0;
    $this->string_field = '';
    $this->binary_field = '';
    $this->enum_field = null;
    $this->list_field = Vector {};
    $this->set_field = Set {};
    $this->map_field = Map {};
    $this->struct_field = null;
  }

  public static function getStructMetadata()[]: \tmeta_ThriftStruct {
    return \tmeta_ThriftStruct::fromShape(
      shape(
        "name" => "terse_write.TerseStructWithCustomDefault",
        "fields" => vec[
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 1,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_BOOL_TYPE,
                )
              ),
              "name" => "bool_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 2,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_BYTE_TYPE,
                )
              ),
              "name" => "byte_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 3,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I16_TYPE,
                )
              ),
              "name" => "short_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 4,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I32_TYPE,
                )
              ),
              "name" => "int_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 5,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I64_TYPE,
                )
              ),
              "name" => "long_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 6,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_FLOAT_TYPE,
                )
              ),
              "name" => "float_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 7,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_DOUBLE_TYPE,
                )
              ),
              "name" => "double_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 8,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                )
              ),
              "name" => "string_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 9,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_BINARY_TYPE,
                )
              ),
              "name" => "binary_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 10,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_enum" => \tmeta_ThriftEnumType::fromShape(
                    shape(
                      "name" => "terse_write.MyEnum",
                    )
                  ),
                )
              ),
              "name" => "enum_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 11,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_list" => \tmeta_ThriftListType::fromShape(
                    shape(
                      "valueType" => \tmeta_ThriftType::fromShape(
                        shape(
                          "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I16_TYPE,
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "list_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 12,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_set" => \tmeta_ThriftSetType::fromShape(
                    shape(
                      "valueType" => \tmeta_ThriftType::fromShape(
                        shape(
                          "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I16_TYPE,
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "set_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 13,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_map" => \tmeta_ThriftMapType::fromShape(
                    shape(
                      "keyType" => \tmeta_ThriftType::fromShape(
                        shape(
                          "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I16_TYPE,
                        )
                      ),
                      "valueType" => \tmeta_ThriftType::fromShape(
                        shape(
                          "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I16_TYPE,
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "map_field",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 14,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_struct" => \tmeta_ThriftStructType::fromShape(
                    shape(
                      "name" => "terse_write.MyStructWithCustomDefault",
                    )
                  ),
                )
              ),
              "name" => "struct_field",
            )
          ),
        ],
        "is_union" => false,
      )
    );
  }

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

  public static function __fromShape(self::TShape $shape)[]: this {
    return new static(
      $shape['bool_field'],
      $shape['byte_field'],
      $shape['short_field'],
      $shape['int_field'],
      $shape['long_field'],
      $shape['float_field'],
      $shape['double_field'],
      $shape['string_field'],
      $shape['binary_field'],
      Shapes::idx($shape, 'enum_field'),
      $shape['list_field'] |> new Vector($$),
      new Set(Keyset\keys($shape['set_field'])),
      $shape['map_field'] |> new Map($$),
      Shapes::idx($shape, 'struct_field') === null ? null : (\facebook\thrift\test\terse_write\MyStructWithCustomDefault::__fromShape($shape['struct_field'])),
    );
  }

  public function __toShape()[]: self::TShape {
    return shape(
      'bool_field' => $this->bool_field,
      'byte_field' => $this->byte_field,
      'short_field' => $this->short_field,
      'int_field' => $this->int_field,
      'long_field' => $this->long_field,
      'float_field' => $this->float_field,
      'double_field' => $this->double_field,
      'string_field' => $this->string_field,
      'binary_field' => $this->binary_field,
      'enum_field' => $this->enum_field,
      'list_field' => vec($this->list_field),
      'set_field' => ThriftUtil::toDArray(Dict\fill_keys($this->set_field->toValuesArray(), true), static::class),
      'map_field' => dict($this->map_field),
      'struct_field' => $this->struct_field?->__toShape(),
    );
  }
  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, 'bool_field') !== null) {
      $this->bool_field = HH\FIXME\UNSAFE_CAST<mixed, bool>($parsed['bool_field']);
    }
    if (idx($parsed, 'byte_field') !== null) {
      $_tmp0 = (int)HH\FIXME\UNSAFE_CAST<mixed, int>($parsed['byte_field']);
      if ($_tmp0 > 0x7f) {
        throw new \TProtocolException("number exceeds limit in field");
      } else {
        $this->byte_field = (int)$_tmp0;
      }
    }
    if (idx($parsed, 'short_field') !== null) {
      $_tmp1 = (int)HH\FIXME\UNSAFE_CAST<mixed, int>($parsed['short_field']);
      if ($_tmp1 > 0x7fff) {
        throw new \TProtocolException("number exceeds limit in field");
      } else {
        $this->short_field = (int)$_tmp1;
      }
    }
    if (idx($parsed, 'int_field') !== null) {
      $_tmp2 = (int)HH\FIXME\UNSAFE_CAST<mixed, int>($parsed['int_field']);
      if ($_tmp2 > 0x7fffffff) {
        throw new \TProtocolException("number exceeds limit in field");
      } else {
        $this->int_field = (int)$_tmp2;
      }
    }
    if (idx($parsed, 'long_field') !== null) {
      $this->long_field = HH\FIXME\UNSAFE_CAST<mixed, int>($parsed['long_field']);
    }
    if (idx($parsed, 'float_field') !== null) {
      $this->float_field = HH\FIXME\UNSAFE_CAST<mixed, float>($parsed['float_field']);
    }
    if (idx($parsed, 'double_field') !== null) {
      $this->double_field = HH\FIXME\UNSAFE_CAST<mixed, float>($parsed['double_field']);
    }
    if (idx($parsed, 'string_field') !== null) {
      $this->string_field = HH\FIXME\UNSAFE_CAST<mixed, string>($parsed['string_field']);
    }
    if (idx($parsed, 'binary_field') !== null) {
      $this->binary_field = HH\FIXME\UNSAFE_CAST<mixed, string>($parsed['binary_field']);
    }
    if (idx($parsed, 'enum_field') !== null) {
      $this->enum_field = \facebook\thrift\test\terse_write\MyEnum::coerce(HH\FIXME\UNSAFE_CAST<mixed, \facebook\thrift\test\terse_write\MyEnum>($parsed['enum_field']));
    }
    if (idx($parsed, 'list_field') !== null) {
      $_json6 = HH\FIXME\UNSAFE_CAST<mixed, Vector<int>>($parsed['list_field']);
      $_container7 = Vector {};
      foreach($_json6 as $_key4 => $_value5) {
        $_elem8 = 0;
        $_tmp9 = (int)$_value5;
        if ($_tmp9 > 0x7fff) {
          throw new \TProtocolException("number exceeds limit in field");
        } else {
          $_elem8 = (int)$_tmp9;
        }
        $_container7 []= $_elem8;
      }
      $this->list_field = $_container7;
    }
    if (idx($parsed, 'set_field') !== null) {
      $_json13 = HH\FIXME\UNSAFE_CAST<mixed, Set<int>>($parsed['set_field']);
      $_container14 = Set {};
      foreach($_json13 as $_key11 => $_value12) {
        $_elem15 = 0;
        $_tmp16 = (int)$_value12;
        if ($_tmp16 > 0x7fff) {
          throw new \TProtocolException("number exceeds limit in field");
        } else {
          $_elem15 = (int)$_tmp16;
        }
        $_container14->add($_elem15);
      }
      $this->set_field = $_container14;
    }
    if (idx($parsed, 'map_field') !== null) {
      $_json20 = HH\FIXME\UNSAFE_CAST<mixed, Map<int, int>>($parsed['map_field']);
      $_container21 = Map {};
      foreach($_json20 as $_key18 => $_value19) {
        $_value22 = 0;
        $_tmp23 = (int)$_value19;
        if ($_tmp23 > 0x7fff) {
          throw new \TProtocolException("number exceeds limit in field");
        } else {
          $_value22 = (int)$_tmp23;
        }
        $_container21[$_key18] = $_value22;
      }
      $this->map_field = $_container21;
    }
    if (idx($parsed, 'struct_field') !== null) {
      $_tmp24 = \json_encode(HH\FIXME\UNSAFE_CAST<mixed, \facebook\thrift\test\terse_write\MyStructWithCustomDefault>($parsed['struct_field']));
      $_tmp25 = \facebook\thrift\test\terse_write\MyStructWithCustomDefault::withDefaultValues();
      $_tmp25->readFromJson($_tmp24);
      $this->struct_field = $_tmp25;
    }
  }

}

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

  const \ThriftStructTypes::TSpec SPEC = dict[
    1 => shape(
      'var' => 'field1',
      'is_terse' => true,
      'adapter' => \Adapter1::class,
      'type' => \TType::I32,
    ),
    2 => shape(
      'var' => 'field2',
      'adapter' => \Adapter1::class,
      'is_terse' => true,
      'type' => \TType::I32,
    ),
    3 => shape(
      'var' => 'field3',
      'is_terse' => true,
      'adapter' => \Adapter1::class,
      'type' => \TType::I32,
    ),
  ];
  const dict<string, int> FIELDMAP = dict[
    'field1' => 1,
    'field2' => 2,
    'field3' => 3,
  ];

  const type TConstructorShape = shape(
    ?'field1' => ?\Adapter1::THackType,
    ?'field2' => ?\Adapter1::THackType,
    ?'field3' => ?\Adapter1::THackType,
  );

  const type TShape = shape(
    'field1' => \Adapter1::THackType,
    'field2' => \Adapter1::THackType,
    'field3' => \Adapter1::THackType,
    ...
  );
  const int STRUCTURAL_ID = 8495441692096133093;
  /**
   * Original thrift field:-
   * 1: terse_write.MyInteger field1
   */
  public \Adapter1::THackType $field1;
  /**
   * Original thrift field:-
   * 2: i32 field2
   */
  public \Adapter1::THackType $field2;
  /**
   * Original thrift field:-
   * 3: terse_write.MyInteger field3
   */
  public \Adapter1::THackType $field3;

  public function __construct(?\Adapter1::THackType $field1 = null, ?\Adapter1::THackType $field2 = null, ?\Adapter1::THackType $field3 = null)[] {
    $this->field1 = $field1 ?? \Adapter1::fromThrift(0);
    $this->field2 = $field2 ?? \Adapter1::fromThrift(0);
    $this->field3 = $field3 ?? \Adapter1::fromThrift(0);
  }

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

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

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

  public function clearTerseFields()[write_props]: void {
    $this->field1 = \Adapter1::fromThrift(0);
    $this->field2 = \Adapter1::fromThrift(0);
    $this->field3 = \Adapter1::fromThrift(0);
  }

  public static function getStructMetadata()[]: \tmeta_ThriftStruct {
    return \tmeta_ThriftStruct::fromShape(
      shape(
        "name" => "terse_write.AdaptedFields",
        "fields" => vec[
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 1,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_typedef" => \tmeta_ThriftTypedefType::fromShape(
                    shape(
                      "name" => "terse_write.MyInteger",
                      "underlyingType" => \tmeta_ThriftType::fromShape(
                        shape(
                          "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I32_TYPE,
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "field1",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 2,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I32_TYPE,
                )
              ),
              "name" => "field2",
            )
          ),
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 3,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_typedef" => \tmeta_ThriftTypedefType::fromShape(
                    shape(
                      "name" => "terse_write.MyInteger",
                      "underlyingType" => \tmeta_ThriftType::fromShape(
                        shape(
                          "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_I32_TYPE,
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "field3",
            )
          ),
        ],
        "is_union" => false,
      )
    );
  }

  public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations {
    return shape(
      'struct' => dict[
        '\facebook\thrift\annotation\TerseWrite' => \facebook\thrift\annotation\TerseWrite::fromShape(
          shape(
          )
        ),
      ],
      'fields' => dict[
        'field1' => shape(
          'field' => dict[],
          'type' => dict[
            '\facebook\thrift\annotation\hack\Adapter' => \facebook\thrift\annotation\hack\Adapter::fromShape(
              shape(
                "name" => "\\Adapter1",
              )
            ),
            '\facebook\thrift\annotation\cpp\Adapter' => \facebook\thrift\annotation\cpp\Adapter::fromShape(
              shape(
                "name" => "::my::Adapter",
              )
            ),
          ],
        ),
        'field2' => shape(
          'field' => dict[
            '\facebook\thrift\annotation\hack\Adapter' => \facebook\thrift\annotation\hack\Adapter::fromShape(
              shape(
                "name" => "\\Adapter1",
              )
            ),
            '\facebook\thrift\annotation\cpp\Adapter' => \facebook\thrift\annotation\cpp\Adapter::fromShape(
              shape(
                "name" => "::my::Adapter",
              )
            ),
          ],
          'type' => dict[],
        ),
        'field3' => shape(
          'field' => dict[
            '\facebook\thrift\annotation\cpp\Adapter' => \facebook\thrift\annotation\cpp\Adapter::fromShape(
              shape(
                "name" => "::my::Adapter",
              )
            ),
          ],
          'type' => dict[
            '\facebook\thrift\annotation\hack\Adapter' => \facebook\thrift\annotation\hack\Adapter::fromShape(
              shape(
                "name" => "\\Adapter1",
              )
            ),
            '\facebook\thrift\annotation\cpp\Adapter' => \facebook\thrift\annotation\cpp\Adapter::fromShape(
              shape(
                "name" => "::my::Adapter",
              )
            ),
          ],
        ),
      ],
    );
  }

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

  public function __toShape()[]: self::TShape {
    return shape(
      'field1' => $this->field1,
      'field2' => $this->field2,
      'field3' => $this->field3,
    );
  }
  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, 'field1') !== null) {
      $_tmp0 = (int)HH\FIXME\UNSAFE_CAST<mixed, \Adapter1::THackType>($parsed['field1']);
      if ($_tmp0 > 0x7fffffff) {
        throw new \TProtocolException("number exceeds limit in field");
      } else {
        $this->field1 = (int)$_tmp0;
      }
    }
    if (idx($parsed, 'field2') !== null) {
      $_tmp1 = (int)HH\FIXME\UNSAFE_CAST<mixed, int>($parsed['field2']);
      if ($_tmp1 > 0x7fffffff) {
        throw new \TProtocolException("number exceeds limit in field");
      } else {
        $this->field2 = (int)$_tmp1;
      }
    }
    if (idx($parsed, 'field3') !== null) {
      $_tmp2 = (int)HH\FIXME\UNSAFE_CAST<mixed, \Adapter1::THackType>($parsed['field3']);
      if ($_tmp2 > 0x7fffffff) {
        throw new \TProtocolException("number exceeds limit in field");
      } else {
        $this->field3 = (int)$_tmp2;
      }
    }
  }

  private static function __hackAdapterTypeChecks()[]: void {
    \ThriftUtil::requireSameType<\Adapter1::TThriftType, int>();
  }

}

/**
 * Original thrift struct:-
 * WrappedFields
 */
<<\ThriftTypeInfo(shape('uri' => 'facebook.com/thrift/test/terse_write/WrappedFields'))>>
class WrappedFields implements \IThriftAsyncStruct, \IThriftStructMetadata, \IThriftShapishAsyncStruct {
  use \ThriftSerializationTrait;

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

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

  const type TShape = shape(
    'field1' => int,
    ...
  );
  const int STRUCTURAL_ID = 3788696854924653147;
  /**
   * Original thrift field:-
   * 1: i32 field1
   */
  private ?\MyFieldWrapper<int, \facebook\thrift\test\terse_write\WrappedFields> $field1;

  public function get_field1()[]: \MyFieldWrapper<int, \facebook\thrift\test\terse_write\WrappedFields> {
    return $this->field1 as nonnull;
  }

  public function __construct()[] {
    $this->field1 = \MyFieldWrapper::fromThrift_DO_NOT_USE_THRIFT_INTERNAL<int, \facebook\thrift\test\terse_write\WrappedFields>(7, 1, $this);
  }

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

  public static async function genFromShape(self::TConstructorShape $shape)[zoned_shallow]: Awaitable<this> {
    $obj = new static();
    $field1 = Shapes::idx($shape, 'field1');
    if ($field1 !== null) {
      await $obj->get_field1()->genWrap($field1);
    }
    return $obj;
  }

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

  public function clearTerseFields()[write_props]: void {
    $this->field1 = \MyFieldWrapper::fromThrift_DO_NOT_USE_THRIFT_INTERNAL<int, \facebook\thrift\test\terse_write\WrappedFields>(0, 1, $this);
  }

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

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

  public static async function __genFromShape(self::TShape $shape): Awaitable<this> {
    $obj = new static();
    await $obj->get_field1()->genWrap($shape['field1']);
    return $obj;
  }

  public async function __genToShape(): Awaitable<self::TShape> {
    $field1 = await ($this->field1 as nonnull)->genUnwrap();
    return shape(
      'field1' => $field1,
    );
  }
  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, 'field1') !== null) {
      $_tmp0 = (int)HH\FIXME\UNSAFE_CAST<mixed, int>($parsed['field1']);
      if ($_tmp0 > 0x7fffffff) {
        throw new \TProtocolException("number exceeds limit in field");
      } else {
        $this->field1 = (int)$_tmp0;
      }
    }
  }

}

/**
 * Original thrift exception:-
 * TerseException
 */
<<\ThriftTypeInfo(shape('uri' => 'facebook.com/thrift/test/terse_write/TerseException'))>>
class TerseException extends \TException implements \IThriftSyncStruct, \IThriftExceptionMetadata {
  use \ThriftSerializationTrait;

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

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

  const int STRUCTURAL_ID = 1537019148371217773;
  /**
   * Original thrift field:-
   * 1: string msg
   */
  public string $msg;

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

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

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

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

  <<__Override>>
  public function getMessage()[]: string {
    return $this->msg ?? '';
  }

  public function clearTerseFields()[write_props]: void {
    $this->msg = '';
  }

  public static function getExceptionMetadata()[]: \tmeta_ThriftException {
    return \tmeta_ThriftException::fromShape(
      shape(
        "name" => "terse_write.TerseException",
        "fields" => vec[
          \tmeta_ThriftField::fromShape(
            shape(
              "id" => 1,
              "type" => \tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => \tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                )
              ),
              "name" => "msg",
            )
          ),
        ],
      )
    );
  }

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

  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, 'msg') !== null) {
      $this->msg = HH\FIXME\UNSAFE_CAST<mixed, string>($parsed['msg']);
    }
  }

}