Example #1
0
    public void write(org.apache.thrift.protocol.TProtocol oprot, DomainVersionMetadata struct)
        throws org.apache.thrift.TException {
      struct.validate();

      oprot.writeStructBegin(STRUCT_DESC);
      if (struct.properties != null) {
        oprot.writeFieldBegin(PROPERTIES_FIELD_DESC);
        oprot.writeBinary(struct.properties);
        oprot.writeFieldEnd();
      }
      if (struct.partitions != null) {
        oprot.writeFieldBegin(PARTITIONS_FIELD_DESC);
        {
          oprot.writeMapBegin(
              new org.apache.thrift.protocol.TMap(
                  org.apache.thrift.protocol.TType.I32,
                  org.apache.thrift.protocol.TType.STRUCT,
                  struct.partitions.size()));
          for (Map.Entry<Integer, PartitionMetadata> _iter12 : struct.partitions.entrySet()) {
            oprot.writeI32(_iter12.getKey());
            _iter12.getValue().write(oprot);
          }
          oprot.writeMapEnd();
        }
        oprot.writeFieldEnd();
      }
      oprot.writeFieldBegin(DEFUNCT_FIELD_DESC);
      oprot.writeBool(struct.defunct);
      oprot.writeFieldEnd();
      oprot.writeFieldBegin(CLOSED_AT_FIELD_DESC);
      oprot.writeI64(struct.closed_at);
      oprot.writeFieldEnd();
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }
Example #2
0
    public void read(org.apache.thrift.protocol.TProtocol iprot, DomainVersionMetadata struct)
        throws org.apache.thrift.TException {
      org.apache.thrift.protocol.TField schemeField;
      iprot.readStructBegin();
      while (true) {
        schemeField = iprot.readFieldBegin();
        if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
          break;
        }
        switch (schemeField.id) {
          case 1: // PROPERTIES
            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
              struct.properties = iprot.readBinary();
              struct.set_properties_isSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 2: // PARTITIONS
            if (schemeField.type == org.apache.thrift.protocol.TType.MAP) {
              {
                org.apache.thrift.protocol.TMap _map8 = iprot.readMapBegin();
                struct.partitions = new HashMap<Integer, PartitionMetadata>(2 * _map8.size);
                for (int _i9 = 0; _i9 < _map8.size; ++_i9) {
                  int _key10; // required
                  PartitionMetadata _val11; // optional
                  _key10 = iprot.readI32();
                  _val11 = new PartitionMetadata();
                  _val11.read(iprot);
                  struct.partitions.put(_key10, _val11);
                }
                iprot.readMapEnd();
              }
              struct.set_partitions_isSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 3: // DEFUNCT
            if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
              struct.defunct = iprot.readBool();
              struct.set_defunct_isSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 4: // CLOSED_AT
            if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
              struct.closed_at = iprot.readI64();
              struct.set_closed_at_isSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          default:
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
        }
        iprot.readFieldEnd();
      }
      iprot.readStructEnd();

      // check for required fields of primitive type, which can't be checked in the validate method
      if (!struct.is_set_defunct()) {
        throw new org.apache.thrift.protocol.TProtocolException(
            "Required field 'defunct' was not found in serialized data! Struct: " + toString());
      }
      if (!struct.is_set_closed_at()) {
        throw new org.apache.thrift.protocol.TProtocolException(
            "Required field 'closed_at' was not found in serialized data! Struct: " + toString());
      }
      struct.validate();
    }