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

enum ComplexUnionEnum: int {
  _EMPTY_ = 0;
  intValue = 1;
  stringValue = 5;
  intListValue = 2;
  stringListValue = 3;
  typedefValue = 9;
  stringRef = 14;
}

/**
 * Original thrift union:-
 * ComplexUnion
 */
class ComplexUnion implements \IThriftSyncStruct, \IThriftStructMetadata, \IThriftUnion<ComplexUnionEnum> {
  use \ThriftUnionSerializationTrait;

  const \ThriftStructTypes::TSpec SPEC = dict[
    1 => shape(
      'var' => 'intValue',
      'union' => true,
      'type' => \TType::I64,
    ),
    5 => shape(
      'var' => 'stringValue',
      'union' => true,
      'type' => \TType::STRING,
    ),
    2 => shape(
      'var' => 'intListValue',
      'union' => true,
      'type' => \TType::LST,
      'etype' => \TType::I64,
      'elem' => shape(
        'type' => \TType::I64,
      ),
      'format' => 'collection',
    ),
    3 => shape(
      'var' => 'stringListValue',
      'union' => true,
      'type' => \TType::LST,
      'etype' => \TType::STRING,
      'elem' => shape(
        'type' => \TType::STRING,
      ),
      'format' => 'collection',
    ),
    9 => shape(
      'var' => 'typedefValue',
      'union' => true,
      'type' => \TType::MAP,
      'ktype' => \TType::I16,
      'vtype' => \TType::STRING,
      'key' => shape(
        'type' => \TType::I16,
      ),
      'val' => shape(
        'type' => \TType::STRING,
      ),
      'format' => 'collection',
    ),
    14 => shape(
      'var' => 'stringRef',
      'union' => true,
      'type' => \TType::STRING,
    ),
  ];
  const dict<string, int> FIELDMAP = dict[
    'intValue' => 1,
    'stringValue' => 5,
    'intListValue' => 2,
    'stringListValue' => 3,
    'typedefValue' => 9,
    'stringRef' => 14,
  ];

  const type TConstructorShape = shape(
    ?'intValue' => ?int,
    ?'stringValue' => ?string,
    ?'intListValue' => ?Vector<int>,
    ?'stringListValue' => ?Vector<string>,
    ?'typedefValue' => ?Map<int, string>,
    ?'stringRef' => ?string,
  );

  const int STRUCTURAL_ID = 1260275021738383280;
  /**
   * Original thrift field:-
   * 1: i64 intValue
   */
  protected ?int $intValue;
  /**
   * Original thrift field:-
   * 5: string stringValue
   */
  protected ?string $stringValue;
  /**
   * Original thrift field:-
   * 2: list<i64> intListValue
   */
  protected ?Vector<int> $intListValue;
  /**
   * Original thrift field:-
   * 3: list<string> stringListValue
   */
  protected ?Vector<string> $stringListValue;
  /**
   * Original thrift field:-
   * 9: module.containerTypedef typedefValue
   */
  protected ?Map<int, string> $typedefValue;
  /**
   * Original thrift field:-
   * 14: string stringRef
   */
  protected ?string $stringRef;
  protected ComplexUnionEnum $_type = ComplexUnionEnum::_EMPTY_;

  public function __construct(?int $intValue = null, ?string $stringValue = null, ?Vector<int> $intListValue = null, ?Vector<string> $stringListValue = null, ?Map<int, string> $typedefValue = null, ?string $stringRef = null)[] {
    $this->_type = ComplexUnionEnum::_EMPTY_;
    if ($intValue !== null) {
      $this->intValue = $intValue;
      $this->_type = ComplexUnionEnum::intValue;
    }
    if ($stringValue !== null) {
      $this->stringValue = $stringValue;
      $this->_type = ComplexUnionEnum::stringValue;
    }
    if ($intListValue !== null) {
      $this->intListValue = $intListValue;
      $this->_type = ComplexUnionEnum::intListValue;
    }
    if ($stringListValue !== null) {
      $this->stringListValue = $stringListValue;
      $this->_type = ComplexUnionEnum::stringListValue;
    }
    if ($typedefValue !== null) {
      $this->typedefValue = $typedefValue;
      $this->_type = ComplexUnionEnum::typedefValue;
    }
    if ($stringRef !== null) {
      $this->stringRef = $stringRef;
      $this->_type = ComplexUnionEnum::stringRef;
    }
  }

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

  public static function fromShape(self::TConstructorShape $shape)[]: this {
    return new static(
      Shapes::idx($shape, 'intValue'),
      Shapes::idx($shape, 'stringValue'),
      Shapes::idx($shape, 'intListValue'),
      Shapes::idx($shape, 'stringListValue'),
      Shapes::idx($shape, 'typedefValue'),
      Shapes::idx($shape, 'stringRef'),
    );
  }

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

  public function getType()[]: ComplexUnionEnum {
    return $this->_type;
  }

  public function reset()[write_props]: void {
    switch ($this->_type) {
      case ComplexUnionEnum::intValue:
        $this->intValue = null;
        break;
      case ComplexUnionEnum::stringValue:
        $this->stringValue = null;
        break;
      case ComplexUnionEnum::intListValue:
        $this->intListValue = null;
        break;
      case ComplexUnionEnum::stringListValue:
        $this->stringListValue = null;
        break;
      case ComplexUnionEnum::typedefValue:
        $this->typedefValue = null;
        break;
      case ComplexUnionEnum::stringRef:
        $this->stringRef = null;
        break;
      case ComplexUnionEnum::_EMPTY_:
        break;
    }
    $this->_type = ComplexUnionEnum::_EMPTY_;
  }

  public function set_intValue(int $intValue)[write_props]: this {
    $this->reset();
    $this->_type = ComplexUnionEnum::intValue;
    $this->intValue = $intValue;
    return $this;
  }

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

  public function getx_intValue()[]: int {
    invariant(
      $this->_type === ComplexUnionEnum::intValue,
      'get_intValue called on an instance of ComplexUnion whose current type is %s',
      (string)$this->_type,
    );
    return $this->intValue as nonnull;
  }

  public function set_stringValue(string $stringValue)[write_props]: this {
    $this->reset();
    $this->_type = ComplexUnionEnum::stringValue;
    $this->stringValue = $stringValue;
    return $this;
  }

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

  public function getx_stringValue()[]: string {
    invariant(
      $this->_type === ComplexUnionEnum::stringValue,
      'get_stringValue called on an instance of ComplexUnion whose current type is %s',
      (string)$this->_type,
    );
    return $this->stringValue as nonnull;
  }

  public function set_intListValue(Vector<int> $intListValue)[write_props]: this {
    $this->reset();
    $this->_type = ComplexUnionEnum::intListValue;
    $this->intListValue = $intListValue;
    return $this;
  }

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

  public function getx_intListValue()[]: Vector<int> {
    invariant(
      $this->_type === ComplexUnionEnum::intListValue,
      'get_intListValue called on an instance of ComplexUnion whose current type is %s',
      (string)$this->_type,
    );
    return $this->intListValue as nonnull;
  }

  public function set_stringListValue(Vector<string> $stringListValue)[write_props]: this {
    $this->reset();
    $this->_type = ComplexUnionEnum::stringListValue;
    $this->stringListValue = $stringListValue;
    return $this;
  }

  public function get_stringListValue()[]: ?Vector<string> {
    return $this->stringListValue;
  }

  public function getx_stringListValue()[]: Vector<string> {
    invariant(
      $this->_type === ComplexUnionEnum::stringListValue,
      'get_stringListValue called on an instance of ComplexUnion whose current type is %s',
      (string)$this->_type,
    );
    return $this->stringListValue as nonnull;
  }

  public function set_typedefValue(Map<int, string> $typedefValue)[write_props]: this {
    $this->reset();
    $this->_type = ComplexUnionEnum::typedefValue;
    $this->typedefValue = $typedefValue;
    return $this;
  }

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

  public function getx_typedefValue()[]: Map<int, string> {
    invariant(
      $this->_type === ComplexUnionEnum::typedefValue,
      'get_typedefValue called on an instance of ComplexUnion whose current type is %s',
      (string)$this->_type,
    );
    return $this->typedefValue as nonnull;
  }

  public function set_stringRef(string $stringRef)[write_props]: this {
    $this->reset();
    $this->_type = ComplexUnionEnum::stringRef;
    $this->stringRef = $stringRef;
    return $this;
  }

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

  public function getx_stringRef()[]: string {
    invariant(
      $this->_type === ComplexUnionEnum::stringRef,
      'get_stringRef called on an instance of ComplexUnion whose current type is %s',
      (string)$this->_type,
    );
    return $this->stringRef as nonnull;
  }

  public static function getStructMetadata()[]: \tmeta_ThriftStruct {
    return tmeta_ThriftStruct::fromShape(
      shape(
        "name" => "module.ComplexUnion",
        "fields" => vec[
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 1,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_I64_TYPE,
                )
              ),
              "name" => "intValue",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 5,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                )
              ),
              "name" => "stringValue",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 2,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_list" => tmeta_ThriftListType::fromShape(
                    shape(
                      "valueType" => tmeta_ThriftType::fromShape(
                        shape(
                          "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_I64_TYPE,
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "intListValue",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 3,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_list" => tmeta_ThriftListType::fromShape(
                    shape(
                      "valueType" => tmeta_ThriftType::fromShape(
                        shape(
                          "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "stringListValue",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 9,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_typedef" => tmeta_ThriftTypedefType::fromShape(
                    shape(
                      "name" => "module.containerTypedef",
                      "underlyingType" => 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_STRING_TYPE,
                                )
                              ),
                            )
                          ),
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "typedefValue",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 14,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                )
              ),
              "name" => "stringRef",
            )
          ),
        ],
        "is_union" => true,
      )
    );
  }

  public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations {
    return shape(
      'struct' => dict[],
      'fields' => dict[
        'stringRef' => shape(
          'field' => dict[
            '\facebook\thrift\annotation\cpp\Ref' => \facebook\thrift\annotation\cpp\Ref::fromShape(
              shape(
                "type" => \facebook\thrift\annotation\cpp\RefType::Unique,
              )
            ),
          ],
          'type' => dict[],
        ),
      ],
    );
  }

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

  public function readFromJson(string $jsonText): void {
    $this->_type = ComplexUnionEnum::_EMPTY_;
    $parsed = json_decode($jsonText, true);

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

    if (idx($parsed, 'intValue') !== null) {
      $this->intValue = HH\FIXME\UNSAFE_CAST<mixed, int>($parsed['intValue']);
      $this->_type = ComplexUnionEnum::intValue;
    }
    if (idx($parsed, 'stringValue') !== null) {
      $this->stringValue = HH\FIXME\UNSAFE_CAST<mixed, string>($parsed['stringValue']);
      $this->_type = ComplexUnionEnum::stringValue;
    }
    if (idx($parsed, 'intListValue') !== null) {
      $_json3 = HH\FIXME\UNSAFE_CAST<mixed, Vector<int>>($parsed['intListValue']);
      $_container4 = Vector {};
      foreach($_json3 as $_key1 => $_value2) {
        $_elem5 = 0;
        $_elem5 = $_value2;
        $_container4 []= $_elem5;
      }
      $this->intListValue = $_container4;
      $this->_type = ComplexUnionEnum::intListValue;
    }
    if (idx($parsed, 'stringListValue') !== null) {
      $_json9 = HH\FIXME\UNSAFE_CAST<mixed, Vector<string>>($parsed['stringListValue']);
      $_container10 = Vector {};
      foreach($_json9 as $_key7 => $_value8) {
        $_elem11 = '';
        $_elem11 = $_value8;
        $_container10 []= $_elem11;
      }
      $this->stringListValue = $_container10;
      $this->_type = ComplexUnionEnum::stringListValue;
    }
    if (idx($parsed, 'typedefValue') !== null) {
      $_json15 = HH\FIXME\UNSAFE_CAST<mixed, Map<int, string>>($parsed['typedefValue']);
      $_container16 = Map {};
      foreach($_json15 as $_key13 => $_value14) {
        $_value17 = '';
        $_value17 = $_value14;
        $_container16[$_key13] = $_value17;
      }
      $this->typedefValue = $_container16;
      $this->_type = ComplexUnionEnum::typedefValue;
    }
    if (idx($parsed, 'stringRef') !== null) {
      $this->stringRef = HH\FIXME\UNSAFE_CAST<mixed, string>($parsed['stringRef']);
      $this->_type = ComplexUnionEnum::stringRef;
    }
  }

}

enum ListUnionEnum: int {
  _EMPTY_ = 0;
  intListValue = 2;
  stringListValue = 3;
}

/**
 * Original thrift union:-
 * ListUnion
 */
class ListUnion implements \IThriftSyncStruct, \IThriftStructMetadata, \IThriftUnion<ListUnionEnum> {
  use \ThriftUnionSerializationTrait;

  const \ThriftStructTypes::TSpec SPEC = dict[
    2 => shape(
      'var' => 'intListValue',
      'union' => true,
      'type' => \TType::LST,
      'etype' => \TType::I64,
      'elem' => shape(
        'type' => \TType::I64,
      ),
      'format' => 'collection',
    ),
    3 => shape(
      'var' => 'stringListValue',
      'union' => true,
      'type' => \TType::LST,
      'etype' => \TType::STRING,
      'elem' => shape(
        'type' => \TType::STRING,
      ),
      'format' => 'collection',
    ),
  ];
  const dict<string, int> FIELDMAP = dict[
    'intListValue' => 2,
    'stringListValue' => 3,
  ];

  const type TConstructorShape = shape(
    ?'intListValue' => ?Vector<int>,
    ?'stringListValue' => ?Vector<string>,
  );

  const int STRUCTURAL_ID = 3965946011249022525;
  /**
   * Original thrift field:-
   * 2: list<i64> intListValue
   */
  protected ?Vector<int> $intListValue;
  /**
   * Original thrift field:-
   * 3: list<string> stringListValue
   */
  protected ?Vector<string> $stringListValue;
  protected ListUnionEnum $_type = ListUnionEnum::_EMPTY_;

  public function __construct(?Vector<int> $intListValue = null, ?Vector<string> $stringListValue = null)[] {
    $this->_type = ListUnionEnum::_EMPTY_;
    if ($intListValue !== null) {
      $this->intListValue = $intListValue;
      $this->_type = ListUnionEnum::intListValue;
    }
    if ($stringListValue !== null) {
      $this->stringListValue = $stringListValue;
      $this->_type = ListUnionEnum::stringListValue;
    }
  }

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

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

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

  public function getType()[]: ListUnionEnum {
    return $this->_type;
  }

  public function reset()[write_props]: void {
    switch ($this->_type) {
      case ListUnionEnum::intListValue:
        $this->intListValue = null;
        break;
      case ListUnionEnum::stringListValue:
        $this->stringListValue = null;
        break;
      case ListUnionEnum::_EMPTY_:
        break;
    }
    $this->_type = ListUnionEnum::_EMPTY_;
  }

  public function set_intListValue(Vector<int> $intListValue)[write_props]: this {
    $this->reset();
    $this->_type = ListUnionEnum::intListValue;
    $this->intListValue = $intListValue;
    return $this;
  }

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

  public function getx_intListValue()[]: Vector<int> {
    invariant(
      $this->_type === ListUnionEnum::intListValue,
      'get_intListValue called on an instance of ListUnion whose current type is %s',
      (string)$this->_type,
    );
    return $this->intListValue as nonnull;
  }

  public function set_stringListValue(Vector<string> $stringListValue)[write_props]: this {
    $this->reset();
    $this->_type = ListUnionEnum::stringListValue;
    $this->stringListValue = $stringListValue;
    return $this;
  }

  public function get_stringListValue()[]: ?Vector<string> {
    return $this->stringListValue;
  }

  public function getx_stringListValue()[]: Vector<string> {
    invariant(
      $this->_type === ListUnionEnum::stringListValue,
      'get_stringListValue called on an instance of ListUnion whose current type is %s',
      (string)$this->_type,
    );
    return $this->stringListValue as nonnull;
  }

  public static function getStructMetadata()[]: \tmeta_ThriftStruct {
    return tmeta_ThriftStruct::fromShape(
      shape(
        "name" => "module.ListUnion",
        "fields" => vec[
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 2,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_list" => tmeta_ThriftListType::fromShape(
                    shape(
                      "valueType" => tmeta_ThriftType::fromShape(
                        shape(
                          "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_I64_TYPE,
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "intListValue",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 3,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_list" => tmeta_ThriftListType::fromShape(
                    shape(
                      "valueType" => tmeta_ThriftType::fromShape(
                        shape(
                          "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "stringListValue",
            )
          ),
        ],
        "is_union" => true,
      )
    );
  }

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

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

  public function readFromJson(string $jsonText): void {
    $this->_type = ListUnionEnum::_EMPTY_;
    $parsed = json_decode($jsonText, true);

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

    if (idx($parsed, 'intListValue') !== null) {
      $_json3 = HH\FIXME\UNSAFE_CAST<mixed, Vector<int>>($parsed['intListValue']);
      $_container4 = Vector {};
      foreach($_json3 as $_key1 => $_value2) {
        $_elem5 = 0;
        $_elem5 = $_value2;
        $_container4 []= $_elem5;
      }
      $this->intListValue = $_container4;
      $this->_type = ListUnionEnum::intListValue;
    }
    if (idx($parsed, 'stringListValue') !== null) {
      $_json9 = HH\FIXME\UNSAFE_CAST<mixed, Vector<string>>($parsed['stringListValue']);
      $_container10 = Vector {};
      foreach($_json9 as $_key7 => $_value8) {
        $_elem11 = '';
        $_elem11 = $_value8;
        $_container10 []= $_elem11;
      }
      $this->stringListValue = $_container10;
      $this->_type = ListUnionEnum::stringListValue;
    }
  }

}

enum DataUnionEnum: int {
  _EMPTY_ = 0;
  binaryData = 1;
  stringData = 2;
}

/**
 * Original thrift union:-
 * DataUnion
 */
class DataUnion implements \IThriftSyncStruct, \IThriftStructMetadata, \IThriftUnion<DataUnionEnum> {
  use \ThriftUnionSerializationTrait;

  const \ThriftStructTypes::TSpec SPEC = dict[
    1 => shape(
      'var' => 'binaryData',
      'union' => true,
      'type' => \TType::STRING,
      'is_binary' => true,
    ),
    2 => shape(
      'var' => 'stringData',
      'union' => true,
      'type' => \TType::STRING,
    ),
  ];
  const dict<string, int> FIELDMAP = dict[
    'binaryData' => 1,
    'stringData' => 2,
  ];

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

  const int STRUCTURAL_ID = 5914600782954619153;
  /**
   * Original thrift field:-
   * 1: binary binaryData
   */
  protected ?string $binaryData;
  /**
   * Original thrift field:-
   * 2: string stringData
   */
  protected ?string $stringData;
  protected DataUnionEnum $_type = DataUnionEnum::_EMPTY_;

  public function __construct(?string $binaryData = null, ?string $stringData = null)[] {
    $this->_type = DataUnionEnum::_EMPTY_;
    if ($binaryData !== null) {
      $this->binaryData = $binaryData;
      $this->_type = DataUnionEnum::binaryData;
    }
    if ($stringData !== null) {
      $this->stringData = $stringData;
      $this->_type = DataUnionEnum::stringData;
    }
  }

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

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

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

  public function getType()[]: DataUnionEnum {
    return $this->_type;
  }

  public function reset()[write_props]: void {
    switch ($this->_type) {
      case DataUnionEnum::binaryData:
        $this->binaryData = null;
        break;
      case DataUnionEnum::stringData:
        $this->stringData = null;
        break;
      case DataUnionEnum::_EMPTY_:
        break;
    }
    $this->_type = DataUnionEnum::_EMPTY_;
  }

  public function set_binaryData(string $binaryData)[write_props]: this {
    $this->reset();
    $this->_type = DataUnionEnum::binaryData;
    $this->binaryData = $binaryData;
    return $this;
  }

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

  public function getx_binaryData()[]: string {
    invariant(
      $this->_type === DataUnionEnum::binaryData,
      'get_binaryData called on an instance of DataUnion whose current type is %s',
      (string)$this->_type,
    );
    return $this->binaryData as nonnull;
  }

  public function set_stringData(string $stringData)[write_props]: this {
    $this->reset();
    $this->_type = DataUnionEnum::stringData;
    $this->stringData = $stringData;
    return $this;
  }

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

  public function getx_stringData()[]: string {
    invariant(
      $this->_type === DataUnionEnum::stringData,
      'get_stringData called on an instance of DataUnion whose current type is %s',
      (string)$this->_type,
    );
    return $this->stringData as nonnull;
  }

  public static function getStructMetadata()[]: \tmeta_ThriftStruct {
    return tmeta_ThriftStruct::fromShape(
      shape(
        "name" => "module.DataUnion",
        "fields" => vec[
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 1,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_BINARY_TYPE,
                )
              ),
              "name" => "binaryData",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 2,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                )
              ),
              "name" => "stringData",
            )
          ),
        ],
        "is_union" => true,
      )
    );
  }

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

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

  public function readFromJson(string $jsonText): void {
    $this->_type = DataUnionEnum::_EMPTY_;
    $parsed = json_decode($jsonText, true);

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

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

}

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

  const \ThriftStructTypes::TSpec SPEC = dict[
    1 => shape(
      'var' => 'strVal',
      'type' => \TType::STRING,
    ),
    2 => shape(
      'var' => 'intVal',
      'type' => \TType::I32,
    ),
    9 => shape(
      'var' => 'typedefValue',
      'type' => \TType::MAP,
      'ktype' => \TType::I16,
      'vtype' => \TType::STRING,
      'key' => shape(
        'type' => \TType::I16,
      ),
      'val' => shape(
        'type' => \TType::STRING,
      ),
      'format' => 'collection',
    ),
  ];
  const dict<string, int> FIELDMAP = dict[
    'strVal' => 1,
    'intVal' => 2,
    'typedefValue' => 9,
  ];

  const type TConstructorShape = shape(
    ?'strVal' => ?string,
    ?'intVal' => ?int,
    ?'typedefValue' => ?Map<int, string>,
  );

  const int STRUCTURAL_ID = 7250696402099336501;
  /**
   * Original thrift field:-
   * 1: string strVal
   */
  public string $strVal;
  /**
   * Original thrift field:-
   * 2: i32 intVal
   */
  public int $intVal;
  /**
   * Original thrift field:-
   * 9: module.containerTypedef typedefValue
   */
  public Map<int, string> $typedefValue;

  public function __construct(?string $strVal = null, ?int $intVal = null, ?Map<int, string> $typedefValue = null)[] {
    $this->strVal = $strVal ?? '';
    $this->intVal = $intVal ?? 0;
    $this->typedefValue = $typedefValue ?? Map {};
  }

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

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

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

  public static function getStructMetadata()[]: \tmeta_ThriftStruct {
    return tmeta_ThriftStruct::fromShape(
      shape(
        "name" => "module.Val",
        "fields" => vec[
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 1,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                )
              ),
              "name" => "strVal",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 2,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_I32_TYPE,
                )
              ),
              "name" => "intVal",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 9,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_typedef" => tmeta_ThriftTypedefType::fromShape(
                    shape(
                      "name" => "module.containerTypedef",
                      "underlyingType" => 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_STRING_TYPE,
                                )
                              ),
                            )
                          ),
                        )
                      ),
                    )
                  ),
                )
              ),
              "name" => "typedefValue",
            )
          ),
        ],
        "is_union" => false,
      )
    );
  }

  public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations {
    return shape(
      'struct' => dict[],
      '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, 'strVal') !== null) {
      $this->strVal = HH\FIXME\UNSAFE_CAST<mixed, string>($parsed['strVal']);
    }
    if (idx($parsed, 'intVal') !== null) {
      $_tmp0 = (int)HH\FIXME\UNSAFE_CAST<mixed, int>($parsed['intVal']);
      if ($_tmp0 > 0x7fffffff) {
        throw new \TProtocolException("number exceeds limit in field");
      } else {
        $this->intVal = (int)$_tmp0;
      }
    }
    if (idx($parsed, 'typedefValue') !== null) {
      $_json4 = HH\FIXME\UNSAFE_CAST<mixed, Map<int, string>>($parsed['typedefValue']);
      $_container5 = Map {};
      foreach($_json4 as $_key2 => $_value3) {
        $_value6 = '';
        $_value6 = $_value3;
        $_container5[$_key2] = $_value6;
      }
      $this->typedefValue = $_container5;
    }
  }

}

enum ValUnionEnum: int {
  _EMPTY_ = 0;
  v1 = 1;
  v2 = 2;
}

/**
 * Original thrift union:-
 * ValUnion
 */
class ValUnion implements \IThriftSyncStruct, \IThriftStructMetadata, \IThriftUnion<ValUnionEnum> {
  use \ThriftUnionSerializationTrait;

  const \ThriftStructTypes::TSpec SPEC = dict[
    1 => shape(
      'var' => 'v1',
      'union' => true,
      'type' => \TType::STRUCT,
      'class' => Val::class,
    ),
    2 => shape(
      'var' => 'v2',
      'union' => true,
      'type' => \TType::STRUCT,
      'class' => Val::class,
    ),
  ];
  const dict<string, int> FIELDMAP = dict[
    'v1' => 1,
    'v2' => 2,
  ];

  const type TConstructorShape = shape(
    ?'v1' => ?Val,
    ?'v2' => ?Val,
  );

  const int STRUCTURAL_ID = 7355268417298249876;
  /**
   * Original thrift field:-
   * 1: module.Val v1
   */
  protected ?Val $v1;
  /**
   * Original thrift field:-
   * 2: module.Val v2
   */
  protected ?Val $v2;
  protected ValUnionEnum $_type = ValUnionEnum::_EMPTY_;

  public function __construct(?Val $v1 = null, ?Val $v2 = null)[] {
    $this->_type = ValUnionEnum::_EMPTY_;
    if ($v1 !== null) {
      $this->v1 = $v1;
      $this->_type = ValUnionEnum::v1;
    }
    if ($v2 !== null) {
      $this->v2 = $v2;
      $this->_type = ValUnionEnum::v2;
    }
  }

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

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

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

  public function getType()[]: ValUnionEnum {
    return $this->_type;
  }

  public function reset()[write_props]: void {
    switch ($this->_type) {
      case ValUnionEnum::v1:
        $this->v1 = null;
        break;
      case ValUnionEnum::v2:
        $this->v2 = null;
        break;
      case ValUnionEnum::_EMPTY_:
        break;
    }
    $this->_type = ValUnionEnum::_EMPTY_;
  }

  public function set_v1(Val $v1)[write_props]: this {
    $this->reset();
    $this->_type = ValUnionEnum::v1;
    $this->v1 = $v1;
    return $this;
  }

  public function get_v1()[]: ?Val {
    return $this->v1;
  }

  public function getx_v1()[]: Val {
    invariant(
      $this->_type === ValUnionEnum::v1,
      'get_v1 called on an instance of ValUnion whose current type is %s',
      (string)$this->_type,
    );
    return $this->v1 as nonnull;
  }

  public function set_v2(Val $v2)[write_props]: this {
    $this->reset();
    $this->_type = ValUnionEnum::v2;
    $this->v2 = $v2;
    return $this;
  }

  public function get_v2()[]: ?Val {
    return $this->v2;
  }

  public function getx_v2()[]: Val {
    invariant(
      $this->_type === ValUnionEnum::v2,
      'get_v2 called on an instance of ValUnion whose current type is %s',
      (string)$this->_type,
    );
    return $this->v2 as nonnull;
  }

  public static function getStructMetadata()[]: \tmeta_ThriftStruct {
    return tmeta_ThriftStruct::fromShape(
      shape(
        "name" => "module.ValUnion",
        "fields" => vec[
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 1,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_struct" => tmeta_ThriftStructType::fromShape(
                    shape(
                      "name" => "module.Val",
                    )
                  ),
                )
              ),
              "name" => "v1",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 2,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_struct" => tmeta_ThriftStructType::fromShape(
                    shape(
                      "name" => "module.Val",
                    )
                  ),
                )
              ),
              "name" => "v2",
            )
          ),
        ],
        "is_union" => true,
      )
    );
  }

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

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

  public function readFromJson(string $jsonText): void {
    $this->_type = ValUnionEnum::_EMPTY_;
    $parsed = json_decode($jsonText, true);

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

    if (idx($parsed, 'v1') !== null) {
      $_tmp0 = \json_encode(HH\FIXME\UNSAFE_CAST<mixed, Val>($parsed['v1']));
      $_tmp1 = Val::withDefaultValues();
      $_tmp1->readFromJson($_tmp0);
      $this->v1 = $_tmp1;
      $this->_type = ValUnionEnum::v1;
    }
    if (idx($parsed, 'v2') !== null) {
      $_tmp2 = \json_encode(HH\FIXME\UNSAFE_CAST<mixed, Val>($parsed['v2']));
      $_tmp3 = Val::withDefaultValues();
      $_tmp3->readFromJson($_tmp2);
      $this->v2 = $_tmp3;
      $this->_type = ValUnionEnum::v2;
    }
  }

}

enum VirtualComplexUnionEnum: int {
  _EMPTY_ = 0;
  thingOne = 1;
  thingTwo = 2;
}

/**
 * Original thrift union:-
 * VirtualComplexUnion
 */
class VirtualComplexUnion implements \IThriftSyncStruct, \IThriftStructMetadata, \IThriftUnion<VirtualComplexUnionEnum> {
  use \ThriftUnionSerializationTrait;

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

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

  const int STRUCTURAL_ID = 8657642278595798833;
  /**
   * Original thrift field:-
   * 1: string thingOne
   */
  protected ?string $thingOne;
  /**
   * Original thrift field:-
   * 2: string thingTwo
   */
  protected ?string $thingTwo;
  protected VirtualComplexUnionEnum $_type = VirtualComplexUnionEnum::_EMPTY_;

  public function __construct(?string $thingOne = null, ?string $thingTwo = null)[] {
    $this->_type = VirtualComplexUnionEnum::_EMPTY_;
    if ($thingOne !== null) {
      $this->thingOne = $thingOne;
      $this->_type = VirtualComplexUnionEnum::thingOne;
    }
    if ($thingTwo !== null) {
      $this->thingTwo = $thingTwo;
      $this->_type = VirtualComplexUnionEnum::thingTwo;
    }
  }

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

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

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

  public function getType()[]: VirtualComplexUnionEnum {
    return $this->_type;
  }

  public function reset()[write_props]: void {
    switch ($this->_type) {
      case VirtualComplexUnionEnum::thingOne:
        $this->thingOne = null;
        break;
      case VirtualComplexUnionEnum::thingTwo:
        $this->thingTwo = null;
        break;
      case VirtualComplexUnionEnum::_EMPTY_:
        break;
    }
    $this->_type = VirtualComplexUnionEnum::_EMPTY_;
  }

  public function set_thingOne(string $thingOne)[write_props]: this {
    $this->reset();
    $this->_type = VirtualComplexUnionEnum::thingOne;
    $this->thingOne = $thingOne;
    return $this;
  }

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

  public function getx_thingOne()[]: string {
    invariant(
      $this->_type === VirtualComplexUnionEnum::thingOne,
      'get_thingOne called on an instance of VirtualComplexUnion whose current type is %s',
      (string)$this->_type,
    );
    return $this->thingOne as nonnull;
  }

  public function set_thingTwo(string $thingTwo)[write_props]: this {
    $this->reset();
    $this->_type = VirtualComplexUnionEnum::thingTwo;
    $this->thingTwo = $thingTwo;
    return $this;
  }

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

  public function getx_thingTwo()[]: string {
    invariant(
      $this->_type === VirtualComplexUnionEnum::thingTwo,
      'get_thingTwo called on an instance of VirtualComplexUnion whose current type is %s',
      (string)$this->_type,
    );
    return $this->thingTwo as nonnull;
  }

  public static function getStructMetadata()[]: \tmeta_ThriftStruct {
    return tmeta_ThriftStruct::fromShape(
      shape(
        "name" => "module.VirtualComplexUnion",
        "fields" => vec[
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 1,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                )
              ),
              "name" => "thingOne",
            )
          ),
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 2,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_primitive" => tmeta_ThriftPrimitiveType::THRIFT_STRING_TYPE,
                )
              ),
              "name" => "thingTwo",
            )
          ),
        ],
        "is_union" => true,
      )
    );
  }

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

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

  public function readFromJson(string $jsonText): void {
    $this->_type = VirtualComplexUnionEnum::_EMPTY_;
    $parsed = json_decode($jsonText, true);

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

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

}

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

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

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

  const int STRUCTURAL_ID = 7064950569513307469;
  /**
   * Original thrift field:-
   * 1: i64 num
   */
  public int $num;

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

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

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

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

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

  public static function getAllStructuredAnnotations()[write_props]: \TStructAnnotations {
    return shape(
      'struct' => dict[],
      '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, 'num') !== null) {
      $this->num = HH\FIXME\UNSAFE_CAST<mixed, int>($parsed['num']);
    }
  }

}

enum NonCopyableUnionEnum: int {
  _EMPTY_ = 0;
  s = 1;
}

/**
 * Original thrift union:-
 * NonCopyableUnion
 */
class NonCopyableUnion implements \IThriftSyncStruct, \IThriftStructMetadata, \IThriftUnion<NonCopyableUnionEnum> {
  use \ThriftUnionSerializationTrait;

  const \ThriftStructTypes::TSpec SPEC = dict[
    1 => shape(
      'var' => 's',
      'union' => true,
      'type' => \TType::STRUCT,
      'class' => NonCopyableStruct::class,
    ),
  ];
  const dict<string, int> FIELDMAP = dict[
    's' => 1,
  ];

  const type TConstructorShape = shape(
    ?'s' => ?NonCopyableStruct,
  );

  const int STRUCTURAL_ID = 5595426780316201025;
  /**
   * Original thrift field:-
   * 1: module.NonCopyableStruct s
   */
  protected ?NonCopyableStruct $s;
  protected NonCopyableUnionEnum $_type = NonCopyableUnionEnum::_EMPTY_;

  public function __construct(?NonCopyableStruct $s = null)[] {
    $this->_type = NonCopyableUnionEnum::_EMPTY_;
    if ($s !== null) {
      $this->s = $s;
      $this->_type = NonCopyableUnionEnum::s;
    }
  }

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

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

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

  public function getType()[]: NonCopyableUnionEnum {
    return $this->_type;
  }

  public function reset()[write_props]: void {
    switch ($this->_type) {
      case NonCopyableUnionEnum::s:
        $this->s = null;
        break;
      case NonCopyableUnionEnum::_EMPTY_:
        break;
    }
    $this->_type = NonCopyableUnionEnum::_EMPTY_;
  }

  public function set_s(NonCopyableStruct $s)[write_props]: this {
    $this->reset();
    $this->_type = NonCopyableUnionEnum::s;
    $this->s = $s;
    return $this;
  }

  public function get_s()[]: ?NonCopyableStruct {
    return $this->s;
  }

  public function getx_s()[]: NonCopyableStruct {
    invariant(
      $this->_type === NonCopyableUnionEnum::s,
      'get_s called on an instance of NonCopyableUnion whose current type is %s',
      (string)$this->_type,
    );
    return $this->s as nonnull;
  }

  public static function getStructMetadata()[]: \tmeta_ThriftStruct {
    return tmeta_ThriftStruct::fromShape(
      shape(
        "name" => "module.NonCopyableUnion",
        "fields" => vec[
          tmeta_ThriftField::fromShape(
            shape(
              "id" => 1,
              "type" => tmeta_ThriftType::fromShape(
                shape(
                  "t_struct" => tmeta_ThriftStructType::fromShape(
                    shape(
                      "name" => "module.NonCopyableStruct",
                    )
                  ),
                )
              ),
              "name" => "s",
            )
          ),
        ],
        "is_union" => true,
      )
    );
  }

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

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

  public function readFromJson(string $jsonText): void {
    $this->_type = NonCopyableUnionEnum::_EMPTY_;
    $parsed = json_decode($jsonText, true);

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

    if (idx($parsed, 's') !== null) {
      $_tmp0 = \json_encode(HH\FIXME\UNSAFE_CAST<mixed, NonCopyableStruct>($parsed['s']));
      $_tmp1 = NonCopyableStruct::withDefaultValues();
      $_tmp1->readFromJson($_tmp0);
      $this->s = $_tmp1;
      $this->_type = NonCopyableUnionEnum::s;
    }
  }

}

