Rev 571 | Blame | Last modification | View Log | RSS feed
/*** Autogenerated by Thrift** DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING*/package in.shop2020.model.v1.user;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.util.Arrays;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import org.apache.thrift.*;import org.apache.thrift.meta_data.*;import org.apache.thrift.protocol.*;public class RatingsWidget implements TBase<RatingsWidget._Fields>, java.io.Serializable, Cloneable {private static final TStruct STRUCT_DESC = new TStruct("RatingsWidget");private static final TField CATALOG_ITEM_ID_FIELD_DESC = new TField("catalog_item_id", TType.I64, (short)1);private static final TField RATINGS_FIELD_DESC = new TField("ratings", TType.MAP, (short)2);private static final TField USER_ID_FIELD_DESC = new TField("user_id", TType.I64, (short)3);private long catalog_item_id;private Map<RatingType,Double> ratings;private long user_id;/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */public enum _Fields implements TFieldIdEnum {CATALOG_ITEM_ID((short)1, "catalog_item_id"),RATINGS((short)2, "ratings"),USER_ID((short)3, "user_id");private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();static {for (_Fields field : EnumSet.allOf(_Fields.class)) {byId.put((int)field._thriftId, field);byName.put(field.getFieldName(), field);}}/*** Find the _Fields constant that matches fieldId, or null if its not found.*/public static _Fields findByThriftId(int fieldId) {return byId.get(fieldId);}/*** 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 assignmentsprivate static final int __CATALOG_ITEM_ID_ISSET_ID = 0;private static final int __USER_ID_ISSET_ID = 1;private BitSet __isset_bit_vector = new BitSet(2);public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{put(_Fields.CATALOG_ITEM_ID, new FieldMetaData("catalog_item_id", TFieldRequirementType.DEFAULT,new FieldValueMetaData(TType.I64)));put(_Fields.RATINGS, new FieldMetaData("ratings", TFieldRequirementType.DEFAULT,new MapMetaData(TType.MAP,new EnumMetaData(TType.ENUM, RatingType.class),new FieldValueMetaData(TType.DOUBLE))));put(_Fields.USER_ID, new FieldMetaData("user_id", TFieldRequirementType.DEFAULT,new FieldValueMetaData(TType.I64)));}});static {FieldMetaData.addStructMetaDataMap(RatingsWidget.class, metaDataMap);}public RatingsWidget() {}public RatingsWidget(long catalog_item_id,Map<RatingType,Double> ratings,long user_id){this();this.catalog_item_id = catalog_item_id;setCatalog_item_idIsSet(true);this.ratings = ratings;this.user_id = user_id;setUser_idIsSet(true);}/*** Performs a deep copy on <i>other</i>.*/public RatingsWidget(RatingsWidget other) {__isset_bit_vector.clear();__isset_bit_vector.or(other.__isset_bit_vector);this.catalog_item_id = other.catalog_item_id;if (other.isSetRatings()) {Map<RatingType,Double> __this__ratings = new HashMap<RatingType,Double>();for (Map.Entry<RatingType, Double> other_element : other.ratings.entrySet()) {RatingType other_element_key = other_element.getKey();Double other_element_value = other_element.getValue();RatingType __this__ratings_copy_key = other_element_key;Double __this__ratings_copy_value = other_element_value;__this__ratings.put(__this__ratings_copy_key, __this__ratings_copy_value);}this.ratings = __this__ratings;}this.user_id = other.user_id;}public RatingsWidget deepCopy() {return new RatingsWidget(this);}@Deprecatedpublic RatingsWidget clone() {return new RatingsWidget(this);}public long getCatalog_item_id() {return this.catalog_item_id;}public RatingsWidget setCatalog_item_id(long catalog_item_id) {this.catalog_item_id = catalog_item_id;setCatalog_item_idIsSet(true);return this;}public void unsetCatalog_item_id() {__isset_bit_vector.clear(__CATALOG_ITEM_ID_ISSET_ID);}/** Returns true if field catalog_item_id is set (has been asigned a value) and false otherwise */public boolean isSetCatalog_item_id() {return __isset_bit_vector.get(__CATALOG_ITEM_ID_ISSET_ID);}public void setCatalog_item_idIsSet(boolean value) {__isset_bit_vector.set(__CATALOG_ITEM_ID_ISSET_ID, value);}public int getRatingsSize() {return (this.ratings == null) ? 0 : this.ratings.size();}public void putToRatings(RatingType key, double val) {if (this.ratings == null) {this.ratings = new HashMap<RatingType,Double>();}this.ratings.put(key, val);}public Map<RatingType,Double> getRatings() {return this.ratings;}public RatingsWidget setRatings(Map<RatingType,Double> ratings) {this.ratings = ratings;return this;}public void unsetRatings() {this.ratings = null;}/** Returns true if field ratings is set (has been asigned a value) and false otherwise */public boolean isSetRatings() {return this.ratings != null;}public void setRatingsIsSet(boolean value) {if (!value) {this.ratings = null;}}public long getUser_id() {return this.user_id;}public RatingsWidget setUser_id(long user_id) {this.user_id = user_id;setUser_idIsSet(true);return this;}public void unsetUser_id() {__isset_bit_vector.clear(__USER_ID_ISSET_ID);}/** Returns true if field user_id is set (has been asigned a value) and false otherwise */public boolean isSetUser_id() {return __isset_bit_vector.get(__USER_ID_ISSET_ID);}public void setUser_idIsSet(boolean value) {__isset_bit_vector.set(__USER_ID_ISSET_ID, value);}public void setFieldValue(_Fields field, Object value) {switch (field) {case CATALOG_ITEM_ID:if (value == null) {unsetCatalog_item_id();} else {setCatalog_item_id((Long)value);}break;case RATINGS:if (value == null) {unsetRatings();} else {setRatings((Map<RatingType,Double>)value);}break;case USER_ID:if (value == null) {unsetUser_id();} else {setUser_id((Long)value);}break;}}public void setFieldValue(int fieldID, Object value) {setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);}public Object getFieldValue(_Fields field) {switch (field) {case CATALOG_ITEM_ID:return new Long(getCatalog_item_id());case RATINGS:return getRatings();case USER_ID:return new Long(getUser_id());}throw new IllegalStateException();}public Object getFieldValue(int fieldId) {return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));}/** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */public boolean isSet(_Fields field) {switch (field) {case CATALOG_ITEM_ID:return isSetCatalog_item_id();case RATINGS:return isSetRatings();case USER_ID:return isSetUser_id();}throw new IllegalStateException();}public boolean isSet(int fieldID) {return isSet(_Fields.findByThriftIdOrThrow(fieldID));}@Overridepublic boolean equals(Object that) {if (that == null)return false;if (that instanceof RatingsWidget)return this.equals((RatingsWidget)that);return false;}public boolean equals(RatingsWidget that) {if (that == null)return false;boolean this_present_catalog_item_id = true;boolean that_present_catalog_item_id = true;if (this_present_catalog_item_id || that_present_catalog_item_id) {if (!(this_present_catalog_item_id && that_present_catalog_item_id))return false;if (this.catalog_item_id != that.catalog_item_id)return false;}boolean this_present_ratings = true && this.isSetRatings();boolean that_present_ratings = true && that.isSetRatings();if (this_present_ratings || that_present_ratings) {if (!(this_present_ratings && that_present_ratings))return false;if (!this.ratings.equals(that.ratings))return false;}boolean this_present_user_id = true;boolean that_present_user_id = true;if (this_present_user_id || that_present_user_id) {if (!(this_present_user_id && that_present_user_id))return false;if (this.user_id != that.user_id)return false;}return true;}@Overridepublic 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;}_Fields fieldId = _Fields.findByThriftId(field.id);if (fieldId == null) {TProtocolUtil.skip(iprot, field.type);} else {switch (fieldId) {case CATALOG_ITEM_ID:if (field.type == TType.I64) {this.catalog_item_id = iprot.readI64();setCatalog_item_idIsSet(true);} else {TProtocolUtil.skip(iprot, field.type);}break;case RATINGS:if (field.type == TType.MAP) {{TMap _map12 = iprot.readMapBegin();this.ratings = new HashMap<RatingType,Double>(2*_map12.size);for (int _i13 = 0; _i13 < _map12.size; ++_i13){RatingType _key14;double _val15;_key14 = RatingType.findByValue(iprot.readI32());_val15 = iprot.readDouble();this.ratings.put(_key14, _val15);}iprot.readMapEnd();}} else {TProtocolUtil.skip(iprot, field.type);}break;case USER_ID:if (field.type == TType.I64) {this.user_id = iprot.readI64();setUser_idIsSet(true);} else {TProtocolUtil.skip(iprot, field.type);}break;}iprot.readFieldEnd();}}iprot.readStructEnd();validate();}public void write(TProtocol oprot) throws TException {validate();oprot.writeStructBegin(STRUCT_DESC);oprot.writeFieldBegin(CATALOG_ITEM_ID_FIELD_DESC);oprot.writeI64(this.catalog_item_id);oprot.writeFieldEnd();if (this.ratings != null) {oprot.writeFieldBegin(RATINGS_FIELD_DESC);{oprot.writeMapBegin(new TMap(TType.I32, TType.DOUBLE, this.ratings.size()));for (Map.Entry<RatingType, Double> _iter16 : this.ratings.entrySet()){oprot.writeI32(_iter16.getKey().getValue());oprot.writeDouble(_iter16.getValue());}oprot.writeMapEnd();}oprot.writeFieldEnd();}oprot.writeFieldBegin(USER_ID_FIELD_DESC);oprot.writeI64(this.user_id);oprot.writeFieldEnd();oprot.writeFieldStop();oprot.writeStructEnd();}@Overridepublic String toString() {StringBuilder sb = new StringBuilder("RatingsWidget(");boolean first = true;sb.append("catalog_item_id:");sb.append(this.catalog_item_id);first = false;if (!first) sb.append(", ");sb.append("ratings:");if (this.ratings == null) {sb.append("null");} else {sb.append(this.ratings);}first = false;if (!first) sb.append(", ");sb.append("user_id:");sb.append(this.user_id);first = false;sb.append(")");return sb.toString();}public void validate() throws TException {// check for required fields}}