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

      oprot.writeStructBegin(STRUCT_DESC);
      if (struct.clusterName != null) {
        if (struct.isSetClusterName()) {
          oprot.writeFieldBegin(CLUSTER_NAME_FIELD_DESC);
          oprot.writeString(struct.clusterName);
          oprot.writeFieldEnd();
        }
      }
      if (struct.groups != null) {
        if (struct.isSetGroups()) {
          oprot.writeFieldBegin(GROUPS_FIELD_DESC);
          {
            oprot.writeMapBegin(
                new org.apache.thrift.protocol.TMap(
                    org.apache.thrift.protocol.TType.STRING,
                    org.apache.thrift.protocol.TType.STRUCT,
                    struct.groups.size()));
            for (Map.Entry<String, GroupData> _iter12 : struct.groups.entrySet()) {
              oprot.writeString(_iter12.getKey());
              _iter12.getValue().write(oprot);
            }
            oprot.writeMapEnd();
          }
          oprot.writeFieldEnd();
        }
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }
示例#2
0
    public void read(org.apache.thrift.protocol.TProtocol iprot, ClusterData 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: // CLUSTER_NAME
            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
              struct.clusterName = iprot.readString();
              struct.setClusterNameIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 2: // GROUPS
            if (schemeField.type == org.apache.thrift.protocol.TType.MAP) {
              {
                org.apache.thrift.protocol.TMap _map8 = iprot.readMapBegin();
                struct.groups = new HashMap<String, GroupData>(2 * _map8.size);
                for (int _i9 = 0; _i9 < _map8.size; ++_i9) {
                  String _key10; // required
                  GroupData _val11; // required
                  _key10 = iprot.readString();
                  _val11 = new GroupData();
                  _val11.read(iprot);
                  struct.groups.put(_key10, _val11);
                }
                iprot.readMapEnd();
              }
              struct.setGroupsIsSet(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
      struct.validate();
    }