/** * Autogenerated by Thrift * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING */ package org.thrudb.thrudoc; import java.util.List; import java.util.ArrayList; import java.util.Map; import java.util.HashMap; import java.util.Set; import java.util.HashSet; import java.util.Collections; import org.apache.thrift.*; import org.apache.thrift.meta_data.*; import org.apache.thrift.protocol.*; public class Entity implements TBase, java.io.Serializable, Cloneable { private static final TStruct STRUCT_DESC = new TStruct("Entity"); private static final TField BUCKET_FIELD_DESC = new TField("bucket", TType.STRING, (short)1); private static final TField KEY_FIELD_DESC = new TField("key", TType.STRING, (short)2); private static final TField VALUE_FIELD_DESC = new TField("value", TType.STRING, (short)3); public String bucket; public static final int BUCKET = 1; public String key; public static final int KEY = 2; public byte[] value; public static final int VALUE = 3; private final Isset __isset = new Isset(); private static final class Isset implements java.io.Serializable { } public static final Map<Integer, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new HashMap<Integer, FieldMetaData>() {{ put(BUCKET, new FieldMetaData("bucket", TFieldRequirementType.DEFAULT, new FieldValueMetaData(TType.STRING))); put(KEY, new FieldMetaData("key", TFieldRequirementType.DEFAULT, new FieldValueMetaData(TType.STRING))); put(VALUE, new FieldMetaData("value", TFieldRequirementType.OPTIONAL, new FieldValueMetaData(TType.STRING))); }}); static { FieldMetaData.addStructMetaDataMap(Entity.class, metaDataMap); } public Entity() { } public Entity( String bucket, String key, byte[] value) { this(); this.bucket = bucket; this.key = key; this.value = value; } /** * Performs a deep copy on <i>other</i>. */ public Entity(Entity other) { if (other.isSetBucket()) { this.bucket = other.bucket; } if (other.isSetKey()) { this.key = other.key; } if (other.isSetValue()) { this.value = new byte[other.value.length]; System.arraycopy(other.value, 0, value, 0, other.value.length); } } @Override public Entity clone() { return new Entity(this); } public String getBucket() { return this.bucket; } public void setBucket(String bucket) { this.bucket = bucket; } public void unsetBucket() { this.bucket = null; } // Returns true if field bucket is set (has been asigned a value) and false otherwise public boolean isSetBucket() { return this.bucket != null; } public void setBucketIsSet(boolean value) { if (!value) { this.bucket = null; } } public String getKey() { return this.key; } public void setKey(String key) { this.key = key; } public void unsetKey() { this.key = null; } // Returns true if field key is set (has been asigned a value) and false otherwise public boolean isSetKey() { return this.key != null; } public void setKeyIsSet(boolean value) { if (!value) { this.key = null; } } public byte[] getValue() { return this.value; } public void setValue(byte[] value) { this.value = value; } public void unsetValue() { this.value = null; } // Returns true if field value is set (has been asigned a value) and false otherwise public boolean isSetValue() { return this.value != null; } public void setValueIsSet(boolean value) { if (!value) { this.value = null; } } public void setFieldValue(int fieldID, Object value) { switch (fieldID) { case BUCKET: if (value == null) { unsetBucket(); } else { setBucket((String)value); } break; case KEY: if (value == null) { unsetKey(); } else { setKey((String)value); } break; case VALUE: if (value == null) { unsetValue(); } else { setValue((byte[])value); } break; default: throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!"); } } public Object getFieldValue(int fieldID) { switch (fieldID) { case BUCKET: return getBucket(); case KEY: return getKey(); case VALUE: return getValue(); default: throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!"); } } // Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise public boolean isSet(int fieldID) { switch (fieldID) { case BUCKET: return isSetBucket(); case KEY: return isSetKey(); case VALUE: return isSetValue(); default: throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!"); } } @Override public boolean equals(Object that) { if (that == null) return false; if (that instanceof Entity) return this.equals((Entity)that); return false; } public boolean equals(Entity that) { if (that == null) return false; boolean this_present_bucket = true && this.isSetBucket(); boolean that_present_bucket = true && that.isSetBucket(); if (this_present_bucket || that_present_bucket) { if (!(this_present_bucket && that_present_bucket)) return false; if (!this.bucket.equals(that.bucket)) return false; } boolean this_present_key = true && this.isSetKey(); boolean that_present_key = true && that.isSetKey(); if (this_present_key || that_present_key) { if (!(this_present_key && that_present_key)) return false; if (!this.key.equals(that.key)) return false; } boolean this_present_value = true && this.isSetValue(); boolean that_present_value = true && that.isSetValue(); if (this_present_value || that_present_value) { if (!(this_present_value && that_present_value)) return false; if (!java.util.Arrays.equals(this.value, that.value)) return false; } return true; } @Override public int hashCode() { return 0; } public void read(TProtocol iprot) throws TException { TField field; iprot.readStructBegin(); while (true) { field = iprot.readFieldBegin(); if (field.type == TType.STOP) { break; } switch (field.id) { case BUCKET: if (field.type == TType.STRING) { this.bucket = iprot.readString(); } else { TProtocolUtil.skip(iprot, field.type); } break; case KEY: if (field.type == TType.STRING) { this.key = iprot.readString(); } else { TProtocolUtil.skip(iprot, field.type); } break; case VALUE: if (field.type == TType.STRING) { this.value = iprot.readBinary(); } else { TProtocolUtil.skip(iprot, field.type); } break; default: TProtocolUtil.skip(iprot, field.type); break; } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method validate(); } public void write(TProtocol oprot) throws TException { validate(); oprot.writeStructBegin(STRUCT_DESC); if (this.bucket != null) { oprot.writeFieldBegin(BUCKET_FIELD_DESC); oprot.writeString(this.bucket); oprot.writeFieldEnd(); } if (this.key != null) { oprot.writeFieldBegin(KEY_FIELD_DESC); oprot.writeString(this.key); oprot.writeFieldEnd(); } if (this.value != null) { oprot.writeFieldBegin(VALUE_FIELD_DESC); oprot.writeBinary(this.value); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } @Override public String toString() { StringBuilder sb = new StringBuilder("Entity("); boolean first = true; sb.append("bucket:"); if (this.bucket == null) { sb.append("null"); } else { sb.append(this.bucket); } first = false; if (!first) sb.append(", "); sb.append("key:"); if (this.key == null) { sb.append("null"); } else { sb.append(this.key); } first = false; if (isSetValue()) { if (!first) sb.append(", "); sb.append("value:"); if (this.value == null) { sb.append("null"); } else { int __value_size = Math.min(this.value.length, 128); for (int i = 0; i < __value_size; i++) { if (i != 0) sb.append(" "); sb.append(Integer.toHexString(this.value[i]).length() > 1 ? Integer.toHexString(this.value[i]).substring(Integer.toHexString(this.value[i]).length() - 2).toUpperCase() : "0" + Integer.toHexString(this.value[i]).toUpperCase()); } if (this.value.length > 128) sb.append(" ..."); } first = false; } sb.append(")"); return sb.toString(); } public void validate() throws TException { // check for required fields // check that fields of type enum have valid values } }