/** * Autogenerated by Thrift * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING */ package com.flaptor.indextank.rpc; import java.util.List; import java.util.ArrayList; import java.util.Map; import java.util.HashMap; import java.util.EnumMap; import java.util.Set; import java.util.HashSet; import java.util.EnumSet; import java.util.Collections; import java.util.BitSet; import java.nio.ByteBuffer; import java.util.Arrays; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.apache.thrift.*; import org.apache.thrift.async.*; import org.apache.thrift.meta_data.*; import org.apache.thrift.transport.*; import org.apache.thrift.protocol.*; @SuppressWarnings("all") public class LogBatch implements TBase<LogBatch, LogBatch._Fields>, java.io.Serializable, Cloneable { private static final TStruct STRUCT_DESC = new TStruct("LogBatch"); private static final TField RECORDS_FIELD_DESC = new TField("records", TType.LIST, (short)1); private List<LogRecord> records; /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements TFieldIdEnum { RECORDS((short)1, "records"); 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: // RECORDS return RECORDS; 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 public static final Map<_Fields, FieldMetaData> metaDataMap; static { Map<_Fields, FieldMetaData> tmpMap = new EnumMap<_Fields, FieldMetaData>(_Fields.class); tmpMap.put(_Fields.RECORDS, new FieldMetaData("records", TFieldRequirementType.DEFAULT, new ListMetaData(TType.LIST, new StructMetaData(TType.STRUCT, LogRecord.class)))); metaDataMap = Collections.unmodifiableMap(tmpMap); FieldMetaData.addStructMetaDataMap(LogBatch.class, metaDataMap); } public LogBatch() { } public LogBatch( List<LogRecord> records) { this(); this.records = records; } /** * Performs a deep copy on <i>other</i>. */ public LogBatch(LogBatch other) { if (other.is_set_records()) { List<LogRecord> __this__records = new ArrayList<LogRecord>(); for (LogRecord other_element : other.records) { __this__records.add(new LogRecord(other_element)); } this.records = __this__records; } } public LogBatch deepCopy() { return new LogBatch(this); } @Override public void clear() { this.records = null; } public int get_records_size() { return (this.records == null) ? 0 : this.records.size(); } public java.util.Iterator<LogRecord> get_records_iterator() { return (this.records == null) ? null : this.records.iterator(); } public void add_to_records(LogRecord elem) { if (this.records == null) { this.records = new ArrayList<LogRecord>(); } this.records.add(elem); } public List<LogRecord> get_records() { return this.records; } public LogBatch set_records(List<LogRecord> records) { this.records = records; return this; } public void unset_records() { this.records = null; } /** Returns true if field records is set (has been asigned a value) and false otherwise */ public boolean is_set_records() { return this.records != null; } public void set_records_isSet(boolean value) { if (!value) { this.records = null; } } public void setFieldValue(_Fields field, Object value) { switch (field) { case RECORDS: if (value == null) { unset_records(); } else { set_records((List<LogRecord>)value); } break; } } public Object getFieldValue(_Fields field) { switch (field) { case RECORDS: return get_records(); } 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 RECORDS: return is_set_records(); } throw new IllegalStateException(); } @Override public boolean equals(Object that) { if (that == null) return false; if (that instanceof LogBatch) return this.equals((LogBatch)that); return false; } public boolean equals(LogBatch that) { if (that == null) return false; boolean this_present_records = true && this.is_set_records(); boolean that_present_records = true && that.is_set_records(); if (this_present_records || that_present_records) { if (!(this_present_records && that_present_records)) return false; if (!this.records.equals(that.records)) return false; } return true; } @Override public int hashCode() { return 0; } public int compareTo(LogBatch other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; LogBatch typedOther = (LogBatch)other; lastComparison = Boolean.valueOf(is_set_records()).compareTo(typedOther.is_set_records()); if (lastComparison != 0) { return lastComparison; } if (is_set_records()) { lastComparison = TBaseHelper.compareTo(this.records, typedOther.records); 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: // RECORDS if (field.type == TType.LIST) { { TList _list74 = iprot.readListBegin(); this.records = new ArrayList<LogRecord>(_list74.size); for (int _i75 = 0; _i75 < _list74.size; ++_i75) { LogRecord _elem76; _elem76 = new LogRecord(); _elem76.read(iprot); this.records.add(_elem76); } iprot.readListEnd(); } } 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.records != null) { oprot.writeFieldBegin(RECORDS_FIELD_DESC); { oprot.writeListBegin(new TList(TType.STRUCT, this.records.size())); for (LogRecord _iter77 : this.records) { _iter77.write(oprot); } oprot.writeListEnd(); } oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } @Override public String toString() { StringBuilder sb = new StringBuilder("LogBatch("); boolean first = true; sb.append("records:"); if (this.records == null) { sb.append("null"); } else { sb.append(this.records); } first = false; sb.append(")"); return sb.toString(); } public void validate() throws TException { // check for required fields } }