/**
* 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 Stock implements TBase<Stock, Stock._Fields>, java.io.Serializable, Cloneable {
private static final TStruct STRUCT_DESC = new TStruct("Stock");
private static final TField SYMBOL_FIELD_DESC = new TField("symbol", TType.STRING, (short)1);
private static final TField DATE_FIELD_DESC = new TField("date", TType.STRING, (short)2);
private static final TField OPEN_FIELD_DESC = new TField("open", TType.DOUBLE, (short)3);
private static final TField HIGH_FIELD_DESC = new TField("high", TType.DOUBLE, (short)4);
private static final TField LOW_FIELD_DESC = new TField("low", TType.DOUBLE, (short)5);
private static final TField CLOSE_FIELD_DESC = new TField("close", TType.DOUBLE, (short)6);
private static final TField VOLUME_FIELD_DESC = new TField("volume", TType.I32, (short)7);
private static final TField ADJ_CLOSE_FIELD_DESC = new TField("adjClose", TType.DOUBLE, (short)8);
private String symbol;
private String date;
private double open;
private double high;
private double low;
private double close;
private int volume;
private double adjClose;
/** 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"),
DATE((short)2, "date"),
OPEN((short)3, "open"),
HIGH((short)4, "high"),
LOW((short)5, "low"),
CLOSE((short)6, "close"),
VOLUME((short)7, "volume"),
ADJ_CLOSE((short)8, "adjClose");
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: // DATE
return DATE;
case 3: // OPEN
return OPEN;
case 4: // HIGH
return HIGH;
case 5: // LOW
return LOW;
case 6: // CLOSE
return CLOSE;
case 7: // VOLUME
return VOLUME;
case 8: // ADJ_CLOSE
return ADJ_CLOSE;
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 __OPEN_ISSET_ID = 0;
private static final int __HIGH_ISSET_ID = 1;
private static final int __LOW_ISSET_ID = 2;
private static final int __CLOSE_ISSET_ID = 3;
private static final int __VOLUME_ISSET_ID = 4;
private static final int __ADJCLOSE_ISSET_ID = 5;
private BitSet __isset_bit_vector = new BitSet(6);
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.DATE, new FieldMetaData("date", TFieldRequirementType.DEFAULT,
new FieldValueMetaData(TType.STRING)));
tmpMap.put(_Fields.OPEN, new FieldMetaData("open", TFieldRequirementType.DEFAULT,
new FieldValueMetaData(TType.DOUBLE)));
tmpMap.put(_Fields.HIGH, new FieldMetaData("high", TFieldRequirementType.DEFAULT,
new FieldValueMetaData(TType.DOUBLE)));
tmpMap.put(_Fields.LOW, new FieldMetaData("low", TFieldRequirementType.DEFAULT,
new FieldValueMetaData(TType.DOUBLE)));
tmpMap.put(_Fields.CLOSE, new FieldMetaData("close", TFieldRequirementType.DEFAULT,
new FieldValueMetaData(TType.DOUBLE)));
tmpMap.put(_Fields.VOLUME, new FieldMetaData("volume", TFieldRequirementType.DEFAULT,
new FieldValueMetaData(TType.I32)));
tmpMap.put(_Fields.ADJ_CLOSE, new FieldMetaData("adjClose", TFieldRequirementType.DEFAULT,
new FieldValueMetaData(TType.DOUBLE)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
FieldMetaData.addStructMetaDataMap(Stock.class, metaDataMap);
}
public Stock() {
}
public Stock(
String symbol,
String date,
double open,
double high,
double low,
double close,
int volume,
double adjClose)
{
this();
this.symbol = symbol;
this.date = date;
this.open = open;
setOpenIsSet(true);
this.high = high;
setHighIsSet(true);
this.low = low;
setLowIsSet(true);
this.close = close;
setCloseIsSet(true);
this.volume = volume;
setVolumeIsSet(true);
this.adjClose = adjClose;
setAdjCloseIsSet(true);
}
/**
* Performs a deep copy on <i>other</i>.
*/
public Stock(Stock other) {
__isset_bit_vector.clear();
__isset_bit_vector.or(other.__isset_bit_vector);
if (other.isSetSymbol()) {
this.symbol = other.symbol;
}
if (other.isSetDate()) {
this.date = other.date;
}
this.open = other.open;
this.high = other.high;
this.low = other.low;
this.close = other.close;
this.volume = other.volume;
this.adjClose = other.adjClose;
}
public Stock deepCopy() {
return new Stock(this);
}
@Override
public void clear() {
this.symbol = null;
this.date = null;
setOpenIsSet(false);
this.open = 0.0;
setHighIsSet(false);
this.high = 0.0;
setLowIsSet(false);
this.low = 0.0;
setCloseIsSet(false);
this.close = 0.0;
setVolumeIsSet(false);
this.volume = 0;
setAdjCloseIsSet(false);
this.adjClose = 0.0;
}
public String getSymbol() {
return this.symbol;
}
public Stock 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 String getDate() {
return this.date;
}
public Stock setDate(String date) {
this.date = date;
return this;
}
public void unsetDate() {
this.date = null;
}
/** Returns true if field date is set (has been asigned a value) and false otherwise */
public boolean isSetDate() {
return this.date != null;
}
public void setDateIsSet(boolean value) {
if (!value) {
this.date = null;
}
}
public double getOpen() {
return this.open;
}
public Stock setOpen(double open) {
this.open = open;
setOpenIsSet(true);
return this;
}
public void unsetOpen() {
__isset_bit_vector.clear(__OPEN_ISSET_ID);
}
/** Returns true if field open is set (has been asigned a value) and false otherwise */
public boolean isSetOpen() {
return __isset_bit_vector.get(__OPEN_ISSET_ID);
}
public void setOpenIsSet(boolean value) {
__isset_bit_vector.set(__OPEN_ISSET_ID, value);
}
public double getHigh() {
return this.high;
}
public Stock setHigh(double high) {
this.high = high;
setHighIsSet(true);
return this;
}
public void unsetHigh() {
__isset_bit_vector.clear(__HIGH_ISSET_ID);
}
/** Returns true if field high is set (has been asigned a value) and false otherwise */
public boolean isSetHigh() {
return __isset_bit_vector.get(__HIGH_ISSET_ID);
}
public void setHighIsSet(boolean value) {
__isset_bit_vector.set(__HIGH_ISSET_ID, value);
}
public double getLow() {
return this.low;
}
public Stock setLow(double low) {
this.low = low;
setLowIsSet(true);
return this;
}
public void unsetLow() {
__isset_bit_vector.clear(__LOW_ISSET_ID);
}
/** Returns true if field low is set (has been asigned a value) and false otherwise */
public boolean isSetLow() {
return __isset_bit_vector.get(__LOW_ISSET_ID);
}
public void setLowIsSet(boolean value) {
__isset_bit_vector.set(__LOW_ISSET_ID, value);
}
public double getClose() {
return this.close;
}
public Stock setClose(double close) {
this.close = close;
setCloseIsSet(true);
return this;
}
public void unsetClose() {
__isset_bit_vector.clear(__CLOSE_ISSET_ID);
}
/** Returns true if field close is set (has been asigned a value) and false otherwise */
public boolean isSetClose() {
return __isset_bit_vector.get(__CLOSE_ISSET_ID);
}
public void setCloseIsSet(boolean value) {
__isset_bit_vector.set(__CLOSE_ISSET_ID, value);
}
public int getVolume() {
return this.volume;
}
public Stock setVolume(int volume) {
this.volume = volume;
setVolumeIsSet(true);
return this;
}
public void unsetVolume() {
__isset_bit_vector.clear(__VOLUME_ISSET_ID);
}
/** Returns true if field volume is set (has been asigned a value) and false otherwise */
public boolean isSetVolume() {
return __isset_bit_vector.get(__VOLUME_ISSET_ID);
}
public void setVolumeIsSet(boolean value) {
__isset_bit_vector.set(__VOLUME_ISSET_ID, value);
}
public double getAdjClose() {
return this.adjClose;
}
public Stock setAdjClose(double adjClose) {
this.adjClose = adjClose;
setAdjCloseIsSet(true);
return this;
}
public void unsetAdjClose() {
__isset_bit_vector.clear(__ADJCLOSE_ISSET_ID);
}
/** Returns true if field adjClose is set (has been asigned a value) and false otherwise */
public boolean isSetAdjClose() {
return __isset_bit_vector.get(__ADJCLOSE_ISSET_ID);
}
public void setAdjCloseIsSet(boolean value) {
__isset_bit_vector.set(__ADJCLOSE_ISSET_ID, value);
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case SYMBOL:
if (value == null) {
unsetSymbol();
} else {
setSymbol((String)value);
}
break;
case DATE:
if (value == null) {
unsetDate();
} else {
setDate((String)value);
}
break;
case OPEN:
if (value == null) {
unsetOpen();
} else {
setOpen((Double)value);
}
break;
case HIGH:
if (value == null) {
unsetHigh();
} else {
setHigh((Double)value);
}
break;
case LOW:
if (value == null) {
unsetLow();
} else {
setLow((Double)value);
}
break;
case CLOSE:
if (value == null) {
unsetClose();
} else {
setClose((Double)value);
}
break;
case VOLUME:
if (value == null) {
unsetVolume();
} else {
setVolume((Integer)value);
}
break;
case ADJ_CLOSE:
if (value == null) {
unsetAdjClose();
} else {
setAdjClose((Double)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case SYMBOL:
return getSymbol();
case DATE:
return getDate();
case OPEN:
return new Double(getOpen());
case HIGH:
return new Double(getHigh());
case LOW:
return new Double(getLow());
case CLOSE:
return new Double(getClose());
case VOLUME:
return new Integer(getVolume());
case ADJ_CLOSE:
return new Double(getAdjClose());
}
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 DATE:
return isSetDate();
case OPEN:
return isSetOpen();
case HIGH:
return isSetHigh();
case LOW:
return isSetLow();
case CLOSE:
return isSetClose();
case VOLUME:
return isSetVolume();
case ADJ_CLOSE:
return isSetAdjClose();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof Stock)
return this.equals((Stock)that);
return false;
}
public boolean equals(Stock 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_date = true && this.isSetDate();
boolean that_present_date = true && that.isSetDate();
if (this_present_date || that_present_date) {
if (!(this_present_date && that_present_date))
return false;
if (!this.date.equals(that.date))
return false;
}
boolean this_present_open = true;
boolean that_present_open = true;
if (this_present_open || that_present_open) {
if (!(this_present_open && that_present_open))
return false;
if (this.open != that.open)
return false;
}
boolean this_present_high = true;
boolean that_present_high = true;
if (this_present_high || that_present_high) {
if (!(this_present_high && that_present_high))
return false;
if (this.high != that.high)
return false;
}
boolean this_present_low = true;
boolean that_present_low = true;
if (this_present_low || that_present_low) {
if (!(this_present_low && that_present_low))
return false;
if (this.low != that.low)
return false;
}
boolean this_present_close = true;
boolean that_present_close = true;
if (this_present_close || that_present_close) {
if (!(this_present_close && that_present_close))
return false;
if (this.close != that.close)
return false;
}
boolean this_present_volume = true;
boolean that_present_volume = true;
if (this_present_volume || that_present_volume) {
if (!(this_present_volume && that_present_volume))
return false;
if (this.volume != that.volume)
return false;
}
boolean this_present_adjClose = true;
boolean that_present_adjClose = true;
if (this_present_adjClose || that_present_adjClose) {
if (!(this_present_adjClose && that_present_adjClose))
return false;
if (this.adjClose != that.adjClose)
return false;
}
return true;
}
@Override
public int hashCode() {
return 0;
}
public int compareTo(Stock other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
Stock typedOther = (Stock)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(isSetDate()).compareTo(typedOther.isSetDate());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetDate()) {
lastComparison = TBaseHelper.compareTo(this.date, typedOther.date);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetOpen()).compareTo(typedOther.isSetOpen());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetOpen()) {
lastComparison = TBaseHelper.compareTo(this.open, typedOther.open);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetHigh()).compareTo(typedOther.isSetHigh());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetHigh()) {
lastComparison = TBaseHelper.compareTo(this.high, typedOther.high);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetLow()).compareTo(typedOther.isSetLow());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetLow()) {
lastComparison = TBaseHelper.compareTo(this.low, typedOther.low);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetClose()).compareTo(typedOther.isSetClose());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetClose()) {
lastComparison = TBaseHelper.compareTo(this.close, typedOther.close);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetVolume()).compareTo(typedOther.isSetVolume());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetVolume()) {
lastComparison = TBaseHelper.compareTo(this.volume, typedOther.volume);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetAdjClose()).compareTo(typedOther.isSetAdjClose());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetAdjClose()) {
lastComparison = TBaseHelper.compareTo(this.adjClose, typedOther.adjClose);
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: // DATE
if (field.type == TType.STRING) {
this.date = iprot.readString();
} else {
TProtocolUtil.skip(iprot, field.type);
}
break;
case 3: // OPEN
if (field.type == TType.DOUBLE) {
this.open = iprot.readDouble();
setOpenIsSet(true);
} else {
TProtocolUtil.skip(iprot, field.type);
}
break;
case 4: // HIGH
if (field.type == TType.DOUBLE) {
this.high = iprot.readDouble();
setHighIsSet(true);
} else {
TProtocolUtil.skip(iprot, field.type);
}
break;
case 5: // LOW
if (field.type == TType.DOUBLE) {
this.low = iprot.readDouble();
setLowIsSet(true);
} else {
TProtocolUtil.skip(iprot, field.type);
}
break;
case 6: // CLOSE
if (field.type == TType.DOUBLE) {
this.close = iprot.readDouble();
setCloseIsSet(true);
} else {
TProtocolUtil.skip(iprot, field.type);
}
break;
case 7: // VOLUME
if (field.type == TType.I32) {
this.volume = iprot.readI32();
setVolumeIsSet(true);
} else {
TProtocolUtil.skip(iprot, field.type);
}
break;
case 8: // ADJ_CLOSE
if (field.type == TType.DOUBLE) {
this.adjClose = iprot.readDouble();
setAdjCloseIsSet(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();
}
if (this.date != null) {
oprot.writeFieldBegin(DATE_FIELD_DESC);
oprot.writeString(this.date);
oprot.writeFieldEnd();
}
oprot.writeFieldBegin(OPEN_FIELD_DESC);
oprot.writeDouble(this.open);
oprot.writeFieldEnd();
oprot.writeFieldBegin(HIGH_FIELD_DESC);
oprot.writeDouble(this.high);
oprot.writeFieldEnd();
oprot.writeFieldBegin(LOW_FIELD_DESC);
oprot.writeDouble(this.low);
oprot.writeFieldEnd();
oprot.writeFieldBegin(CLOSE_FIELD_DESC);
oprot.writeDouble(this.close);
oprot.writeFieldEnd();
oprot.writeFieldBegin(VOLUME_FIELD_DESC);
oprot.writeI32(this.volume);
oprot.writeFieldEnd();
oprot.writeFieldBegin(ADJ_CLOSE_FIELD_DESC);
oprot.writeDouble(this.adjClose);
oprot.writeFieldEnd();
oprot.writeFieldStop();
oprot.writeStructEnd();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("Stock(");
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("date:");
if (this.date == null) {
sb.append("null");
} else {
sb.append(this.date);
}
first = false;
if (!first) sb.append(", ");
sb.append("open:");
sb.append(this.open);
first = false;
if (!first) sb.append(", ");
sb.append("high:");
sb.append(this.high);
first = false;
if (!first) sb.append(", ");
sb.append("low:");
sb.append(this.low);
first = false;
if (!first) sb.append(", ");
sb.append("close:");
sb.append(this.close);
first = false;
if (!first) sb.append(", ");
sb.append("volume:");
sb.append(this.volume);
first = false;
if (!first) sb.append(", ");
sb.append("adjClose:");
sb.append(this.adjClose);
first = false;
sb.append(")");
return sb.toString();
}
public void validate() throws TException {
// check for required fields
}
}