/***************************************************************************
* Copyright (c) 2012-2013 VMware, Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/
/**
* Autogenerated by Thrift Compiler (0.9.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package com.vmware.bdd.software.mgmt.thrift;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.Collections;
import java.util.EnumMap;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.thrift.protocol.TTupleProtocol;
import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;
import org.apache.thrift.scheme.TupleScheme;
public class GroupData implements org.apache.thrift.TBase<GroupData, GroupData._Fields>, java.io.Serializable, Cloneable {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("GroupData");
private static final org.apache.thrift.protocol.TField GROUP_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("groupName", org.apache.thrift.protocol.TType.STRING, (short)1);
private static final org.apache.thrift.protocol.TField INSTANCES_FIELD_DESC = new org.apache.thrift.protocol.TField("instances", org.apache.thrift.protocol.TType.LIST, (short)2);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
schemes.put(StandardScheme.class, new GroupDataStandardSchemeFactory());
schemes.put(TupleScheme.class, new GroupDataTupleSchemeFactory());
}
public String groupName; // optional
public List<ServerData> instances; // optional
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
GROUP_NAME((short)1, "groupName"),
INSTANCES((short)2, "instances");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // GROUP_NAME
return GROUP_NAME;
case 2: // INSTANCES
return INSTANCES;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
// isset id assignments
private _Fields optionals[] = {_Fields.GROUP_NAME,_Fields.INSTANCES};
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.GROUP_NAME, new org.apache.thrift.meta_data.FieldMetaData("groupName", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
tmpMap.put(_Fields.INSTANCES, new org.apache.thrift.meta_data.FieldMetaData("instances", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST,
new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, ServerData.class))));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(GroupData.class, metaDataMap);
}
public GroupData() {
}
/**
* Performs a deep copy on <i>other</i>.
*/
public GroupData(GroupData other) {
if (other.isSetGroupName()) {
this.groupName = other.groupName;
}
if (other.isSetInstances()) {
List<ServerData> __this__instances = new ArrayList<ServerData>();
for (ServerData other_element : other.instances) {
__this__instances.add(new ServerData(other_element));
}
this.instances = __this__instances;
}
}
public GroupData deepCopy() {
return new GroupData(this);
}
@Override
public void clear() {
this.groupName = null;
this.instances = null;
}
public String getGroupName() {
return this.groupName;
}
public GroupData setGroupName(String groupName) {
this.groupName = groupName;
return this;
}
public void unsetGroupName() {
this.groupName = null;
}
/** Returns true if field groupName is set (has been assigned a value) and false otherwise */
public boolean isSetGroupName() {
return this.groupName != null;
}
public void setGroupNameIsSet(boolean value) {
if (!value) {
this.groupName = null;
}
}
public int getInstancesSize() {
return (this.instances == null) ? 0 : this.instances.size();
}
public java.util.Iterator<ServerData> getInstancesIterator() {
return (this.instances == null) ? null : this.instances.iterator();
}
public void addToInstances(ServerData elem) {
if (this.instances == null) {
this.instances = new ArrayList<ServerData>();
}
this.instances.add(elem);
}
public List<ServerData> getInstances() {
return this.instances;
}
public GroupData setInstances(List<ServerData> instances) {
this.instances = instances;
return this;
}
public void unsetInstances() {
this.instances = null;
}
/** Returns true if field instances is set (has been assigned a value) and false otherwise */
public boolean isSetInstances() {
return this.instances != null;
}
public void setInstancesIsSet(boolean value) {
if (!value) {
this.instances = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case GROUP_NAME:
if (value == null) {
unsetGroupName();
} else {
setGroupName((String)value);
}
break;
case INSTANCES:
if (value == null) {
unsetInstances();
} else {
setInstances((List<ServerData>)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case GROUP_NAME:
return getGroupName();
case INSTANCES:
return getInstances();
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case GROUP_NAME:
return isSetGroupName();
case INSTANCES:
return isSetInstances();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof GroupData)
return this.equals((GroupData)that);
return false;
}
public boolean equals(GroupData that) {
if (that == null)
return false;
boolean this_present_groupName = true && this.isSetGroupName();
boolean that_present_groupName = true && that.isSetGroupName();
if (this_present_groupName || that_present_groupName) {
if (!(this_present_groupName && that_present_groupName))
return false;
if (!this.groupName.equals(that.groupName))
return false;
}
boolean this_present_instances = true && this.isSetInstances();
boolean that_present_instances = true && that.isSetInstances();
if (this_present_instances || that_present_instances) {
if (!(this_present_instances && that_present_instances))
return false;
if (!this.instances.equals(that.instances))
return false;
}
return true;
}
@Override
public int hashCode() {
return 0;
}
public int compareTo(GroupData other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
GroupData typedOther = (GroupData)other;
lastComparison = Boolean.valueOf(isSetGroupName()).compareTo(typedOther.isSetGroupName());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetGroupName()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.groupName, typedOther.groupName);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetInstances()).compareTo(typedOther.isSetInstances());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetInstances()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.instances, typedOther.instances);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("GroupData(");
boolean first = true;
if (isSetGroupName()) {
sb.append("groupName:");
if (this.groupName == null) {
sb.append("null");
} else {
sb.append(this.groupName);
}
first = false;
}
if (isSetInstances()) {
if (!first) sb.append(", ");
sb.append("instances:");
if (this.instances == null) {
sb.append("null");
} else {
sb.append(this.instances);
}
first = false;
}
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
// check for sub-struct validity
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private static class GroupDataStandardSchemeFactory implements SchemeFactory {
public GroupDataStandardScheme getScheme() {
return new GroupDataStandardScheme();
}
}
private static class GroupDataStandardScheme extends StandardScheme<GroupData> {
public void read(org.apache.thrift.protocol.TProtocol iprot, GroupData 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: // GROUP_NAME
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.groupName = iprot.readString();
struct.setGroupNameIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 2: // INSTANCES
if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
{
org.apache.thrift.protocol.TList _list0 = iprot.readListBegin();
struct.instances = new ArrayList<ServerData>(_list0.size);
for (int _i1 = 0; _i1 < _list0.size; ++_i1)
{
ServerData _elem2; // required
_elem2 = new ServerData();
_elem2.read(iprot);
struct.instances.add(_elem2);
}
iprot.readListEnd();
}
struct.setInstancesIsSet(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();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, GroupData struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
if (struct.groupName != null) {
if (struct.isSetGroupName()) {
oprot.writeFieldBegin(GROUP_NAME_FIELD_DESC);
oprot.writeString(struct.groupName);
oprot.writeFieldEnd();
}
}
if (struct.instances != null) {
if (struct.isSetInstances()) {
oprot.writeFieldBegin(INSTANCES_FIELD_DESC);
{
oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.instances.size()));
for (ServerData _iter3 : struct.instances)
{
_iter3.write(oprot);
}
oprot.writeListEnd();
}
oprot.writeFieldEnd();
}
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class GroupDataTupleSchemeFactory implements SchemeFactory {
public GroupDataTupleScheme getScheme() {
return new GroupDataTupleScheme();
}
}
private static class GroupDataTupleScheme extends TupleScheme<GroupData> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, GroupData struct) throws org.apache.thrift.TException {
TTupleProtocol oprot = (TTupleProtocol) prot;
BitSet optionals = new BitSet();
if (struct.isSetGroupName()) {
optionals.set(0);
}
if (struct.isSetInstances()) {
optionals.set(1);
}
oprot.writeBitSet(optionals, 2);
if (struct.isSetGroupName()) {
oprot.writeString(struct.groupName);
}
if (struct.isSetInstances()) {
{
oprot.writeI32(struct.instances.size());
for (ServerData _iter4 : struct.instances)
{
_iter4.write(oprot);
}
}
}
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, GroupData struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
BitSet incoming = iprot.readBitSet(2);
if (incoming.get(0)) {
struct.groupName = iprot.readString();
struct.setGroupNameIsSet(true);
}
if (incoming.get(1)) {
{
org.apache.thrift.protocol.TList _list5 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
struct.instances = new ArrayList<ServerData>(_list5.size);
for (int _i6 = 0; _i6 < _list5.size; ++_i6)
{
ServerData _elem7; // required
_elem7 = new ServerData();
_elem7.read(iprot);
struct.instances.add(_elem7);
}
}
struct.setInstancesIsSet(true);
}
}
}
}