/** * Autogenerated by Thrift * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING */ package hip.ch3.thrift; import org.apache.thrift.*; import org.apache.thrift.meta_data.*; import org.apache.thrift.protocol.*; import java.util.*; public class StockAvg implements TBase<StockAvg, StockAvg._Fields>, java.io.Serializable, Cloneable { private static final TStruct STRUCT_DESC = new TStruct("StockAvg"); private static final TField SYMBOL_FIELD_DESC = new TField("symbol", TType.STRING, (short)1); private static final TField AVG_FIELD_DESC = new TField("avg", TType.DOUBLE, (short)2); private String symbol; private double avg; /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements TFieldIdEnum { SYMBOL((short)1, "symbol"), AVG((short)2, "avg"); 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: // SYMBOL return SYMBOL; case 2: // AVG return AVG; 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 static final int __AVG_ISSET_ID = 0; private BitSet __isset_bit_vector = new BitSet(1); public static final Map<_Fields, FieldMetaData> metaDataMap; static { Map<_Fields, FieldMetaData> tmpMap = new EnumMap<_Fields, FieldMetaData>(_Fields.class); tmpMap.put(_Fields.SYMBOL, new FieldMetaData("symbol", TFieldRequirementType.DEFAULT, new FieldValueMetaData(TType.STRING))); tmpMap.put(_Fields.AVG, new FieldMetaData("avg", TFieldRequirementType.DEFAULT, new FieldValueMetaData(TType.DOUBLE))); metaDataMap = Collections.unmodifiableMap(tmpMap); FieldMetaData.addStructMetaDataMap(StockAvg.class, metaDataMap); } public StockAvg() { } public StockAvg( String symbol, double avg) { this(); this.symbol = symbol; this.avg = avg; setAvgIsSet(true); } /** * Performs a deep copy on <i>other</i>. */ public StockAvg(StockAvg other) { __isset_bit_vector.clear(); __isset_bit_vector.or(other.__isset_bit_vector); if (other.isSetSymbol()) { this.symbol = other.symbol; } this.avg = other.avg; } public StockAvg deepCopy() { return new StockAvg(this); } @Override public void clear() { this.symbol = null; setAvgIsSet(false); this.avg = 0.0; } public String getSymbol() { return this.symbol; } public StockAvg setSymbol(String symbol) { this.symbol = symbol; return this; } public void unsetSymbol() { this.symbol = null; } /** Returns true if field symbol is set (has been asigned a value) and false otherwise */ public boolean isSetSymbol() { return this.symbol != null; } public void setSymbolIsSet(boolean value) { if (!value) { this.symbol = null; } } public double getAvg() { return this.avg; } public StockAvg setAvg(double avg) { this.avg = avg; setAvgIsSet(true); return this; } public void unsetAvg() { __isset_bit_vector.clear(__AVG_ISSET_ID); } /** Returns true if field avg is set (has been asigned a value) and false otherwise */ public boolean isSetAvg() { return __isset_bit_vector.get(__AVG_ISSET_ID); } public void setAvgIsSet(boolean value) { __isset_bit_vector.set(__AVG_ISSET_ID, value); } public void setFieldValue(_Fields field, Object value) { switch (field) { case SYMBOL: if (value == null) { unsetSymbol(); } else { setSymbol((String)value); } break; case AVG: if (value == null) { unsetAvg(); } else { setAvg((Double)value); } break; } } public Object getFieldValue(_Fields field) { switch (field) { case SYMBOL: return getSymbol(); case AVG: return new Double(getAvg()); } throw new IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new IllegalArgumentException(); } switch (field) { case SYMBOL: return isSetSymbol(); case AVG: return isSetAvg(); } throw new IllegalStateException(); } @Override public boolean equals(Object that) { if (that == null) return false; if (that instanceof StockAvg) return this.equals((StockAvg)that); return false; } public boolean equals(StockAvg that) { if (that == null) return false; boolean this_present_symbol = true && this.isSetSymbol(); boolean that_present_symbol = true && that.isSetSymbol(); if (this_present_symbol || that_present_symbol) { if (!(this_present_symbol && that_present_symbol)) return false; if (!this.symbol.equals(that.symbol)) return false; } boolean this_present_avg = true; boolean that_present_avg = true; if (this_present_avg || that_present_avg) { if (!(this_present_avg && that_present_avg)) return false; if (this.avg != that.avg) return false; } return true; } @Override public int hashCode() { return 0; } public int compareTo(StockAvg other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; StockAvg typedOther = (StockAvg)other; lastComparison = Boolean.valueOf(isSetSymbol()).compareTo(typedOther.isSetSymbol()); if (lastComparison != 0) { return lastComparison; } if (isSetSymbol()) { lastComparison = TBaseHelper.compareTo(this.symbol, typedOther.symbol); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetAvg()).compareTo(typedOther.isSetAvg()); if (lastComparison != 0) { return lastComparison; } if (isSetAvg()) { lastComparison = TBaseHelper.compareTo(this.avg, typedOther.avg); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } 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 1: // SYMBOL if (field.type == TType.STRING) { this.symbol = iprot.readString(); } else { TProtocolUtil.skip(iprot, field.type); } break; case 2: // AVG if (field.type == TType.DOUBLE) { this.avg = iprot.readDouble(); setAvgIsSet(true); } else { TProtocolUtil.skip(iprot, field.type); } break; default: TProtocolUtil.skip(iprot, field.type); } 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.symbol != null) { oprot.writeFieldBegin(SYMBOL_FIELD_DESC); oprot.writeString(this.symbol); oprot.writeFieldEnd(); } oprot.writeFieldBegin(AVG_FIELD_DESC); oprot.writeDouble(this.avg); oprot.writeFieldEnd(); oprot.writeFieldStop(); oprot.writeStructEnd(); } @Override public String toString() { StringBuilder sb = new StringBuilder("StockAvg("); boolean first = true; sb.append("symbol:"); if (this.symbol == null) { sb.append("null"); } else { sb.append(this.symbol); } first = false; if (!first) sb.append(", "); sb.append("avg:"); sb.append(this.avg); first = false; sb.append(")"); return sb.toString(); } public void validate() throws TException { // check for required fields } }