package com.ganji.as.thrift.protocol.client.test;
/**
* Autogenerated by Thrift Compiler (0.8.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;
import org.apache.thrift.scheme.TupleScheme;
import org.apache.thrift.protocol.TTupleProtocol;
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;
public class AchieveResult implements org.apache.thrift.TBase<AchieveResult, AchieveResult._Fields>, java.io.Serializable, Cloneable {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("AchieveResult");
private static final org.apache.thrift.protocol.TField SCORE_FIELD_DESC = new org.apache.thrift.protocol.TField("score", org.apache.thrift.protocol.TType.I32, (short)1);
private static final org.apache.thrift.protocol.TField IS_SHOT_FIELD_DESC = new org.apache.thrift.protocol.TField("isShot", org.apache.thrift.protocol.TType.BOOL, (short)2);
private static final org.apache.thrift.protocol.TField DETAIL_FIELD_DESC = new org.apache.thrift.protocol.TField("detail", org.apache.thrift.protocol.TType.STRING, (short)3);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
schemes.put(StandardScheme.class, new AchieveResultStandardSchemeFactory());
schemes.put(TupleScheme.class, new AchieveResultTupleSchemeFactory());
}
/**
*
* @see ResultScore
*/
public ResultScore score; // required
public boolean isShot; // required
public String detail; // optional
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
/**
*
* @see ResultScore
*/
SCORE((short)1, "score"),
IS_SHOT((short)2, "isShot"),
DETAIL((short)3, "detail");
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: // SCORE
return SCORE;
case 2: // IS_SHOT
return IS_SHOT;
case 3: // DETAIL
return DETAIL;
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 __ISSHOT_ISSET_ID = 0;
private BitSet __isset_bit_vector = new BitSet(1);
private _Fields optionals[] = {_Fields.DETAIL};
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.SCORE, new org.apache.thrift.meta_data.FieldMetaData("score", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, ResultScore.class)));
tmpMap.put(_Fields.IS_SHOT, new org.apache.thrift.meta_data.FieldMetaData("isShot", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
tmpMap.put(_Fields.DETAIL, new org.apache.thrift.meta_data.FieldMetaData("detail", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(AchieveResult.class, metaDataMap);
}
public AchieveResult() {
}
public AchieveResult(
ResultScore score,
boolean isShot)
{
this();
this.score = score;
this.isShot = isShot;
setIsShotIsSet(true);
}
/**
* Performs a deep copy on <i>other</i>.
*/
public AchieveResult(AchieveResult other) {
__isset_bit_vector.clear();
__isset_bit_vector.or(other.__isset_bit_vector);
if (other.isSetScore()) {
this.score = other.score;
}
this.isShot = other.isShot;
if (other.isSetDetail()) {
this.detail = other.detail;
}
}
public AchieveResult deepCopy() {
return new AchieveResult(this);
}
@Override
public void clear() {
this.score = null;
setIsShotIsSet(false);
this.isShot = false;
this.detail = null;
}
/**
*
* @see ResultScore
*/
public ResultScore getScore() {
return this.score;
}
/**
*
* @see ResultScore
*/
public AchieveResult setScore(ResultScore score) {
this.score = score;
return this;
}
public void unsetScore() {
this.score = null;
}
/** Returns true if field score is set (has been assigned a value) and false otherwise */
public boolean isSetScore() {
return this.score != null;
}
public void setScoreIsSet(boolean value) {
if (!value) {
this.score = null;
}
}
public boolean isIsShot() {
return this.isShot;
}
public AchieveResult setIsShot(boolean isShot) {
this.isShot = isShot;
setIsShotIsSet(true);
return this;
}
public void unsetIsShot() {
__isset_bit_vector.clear(__ISSHOT_ISSET_ID);
}
/** Returns true if field isShot is set (has been assigned a value) and false otherwise */
public boolean isSetIsShot() {
return __isset_bit_vector.get(__ISSHOT_ISSET_ID);
}
public void setIsShotIsSet(boolean value) {
__isset_bit_vector.set(__ISSHOT_ISSET_ID, value);
}
public String getDetail() {
return this.detail;
}
public AchieveResult setDetail(String detail) {
this.detail = detail;
return this;
}
public void unsetDetail() {
this.detail = null;
}
/** Returns true if field detail is set (has been assigned a value) and false otherwise */
public boolean isSetDetail() {
return this.detail != null;
}
public void setDetailIsSet(boolean value) {
if (!value) {
this.detail = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case SCORE:
if (value == null) {
unsetScore();
} else {
setScore((ResultScore)value);
}
break;
case IS_SHOT:
if (value == null) {
unsetIsShot();
} else {
setIsShot((Boolean)value);
}
break;
case DETAIL:
if (value == null) {
unsetDetail();
} else {
setDetail((String)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case SCORE:
return getScore();
case IS_SHOT:
return Boolean.valueOf(isIsShot());
case DETAIL:
return getDetail();
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case SCORE:
return isSetScore();
case IS_SHOT:
return isSetIsShot();
case DETAIL:
return isSetDetail();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof AchieveResult)
return this.equals((AchieveResult)that);
return false;
}
public boolean equals(AchieveResult that) {
if (that == null)
return false;
boolean this_present_score = true && this.isSetScore();
boolean that_present_score = true && that.isSetScore();
if (this_present_score || that_present_score) {
if (!(this_present_score && that_present_score))
return false;
if (!this.score.equals(that.score))
return false;
}
boolean this_present_isShot = true;
boolean that_present_isShot = true;
if (this_present_isShot || that_present_isShot) {
if (!(this_present_isShot && that_present_isShot))
return false;
if (this.isShot != that.isShot)
return false;
}
boolean this_present_detail = true && this.isSetDetail();
boolean that_present_detail = true && that.isSetDetail();
if (this_present_detail || that_present_detail) {
if (!(this_present_detail && that_present_detail))
return false;
if (!this.detail.equals(that.detail))
return false;
}
return true;
}
@Override
public int hashCode() {
return 0;
}
public int compareTo(AchieveResult other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
AchieveResult typedOther = (AchieveResult)other;
lastComparison = Boolean.valueOf(isSetScore()).compareTo(typedOther.isSetScore());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetScore()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.score, typedOther.score);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetIsShot()).compareTo(typedOther.isSetIsShot());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetIsShot()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.isShot, typedOther.isShot);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetDetail()).compareTo(typedOther.isSetDetail());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetDetail()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.detail, typedOther.detail);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("AchieveResult(");
boolean first = true;
sb.append("score:");
if (this.score == null) {
sb.append("null");
} else {
sb.append(this.score);
}
first = false;
if (!first) sb.append(", ");
sb.append("isShot:");
sb.append(this.isShot);
first = false;
if (isSetDetail()) {
if (!first) sb.append(", ");
sb.append("detail:");
if (this.detail == null) {
sb.append("null");
} else {
sb.append(this.detail);
}
first = false;
}
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
if (score == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'score' was not present! Struct: " + toString());
}
// alas, we cannot check 'isShot' because it's a primitive and you chose the non-beans generator.
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
// it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
__isset_bit_vector = new BitSet(1);
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private static class AchieveResultStandardSchemeFactory implements SchemeFactory {
public AchieveResultStandardScheme getScheme() {
return new AchieveResultStandardScheme();
}
}
private static class AchieveResultStandardScheme extends StandardScheme<AchieveResult> {
public void read(org.apache.thrift.protocol.TProtocol iprot, AchieveResult struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField schemeField;
iprot.readStructBegin();
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
case 1: // SCORE
if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
struct.score = ResultScore.findByValue(iprot.readI32());
struct.setScoreIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 2: // IS_SHOT
if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
struct.isShot = iprot.readBool();
struct.setIsShotIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 3: // DETAIL
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.detail = iprot.readString();
struct.setDetailIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
if (!struct.isSetIsShot()) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'isShot' was not found in serialized data! Struct: " + toString());
}
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, AchieveResult struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
if (struct.score != null) {
oprot.writeFieldBegin(SCORE_FIELD_DESC);
oprot.writeI32(struct.score.getValue());
oprot.writeFieldEnd();
}
oprot.writeFieldBegin(IS_SHOT_FIELD_DESC);
oprot.writeBool(struct.isShot);
oprot.writeFieldEnd();
if (struct.detail != null) {
if (struct.isSetDetail()) {
oprot.writeFieldBegin(DETAIL_FIELD_DESC);
oprot.writeString(struct.detail);
oprot.writeFieldEnd();
}
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class AchieveResultTupleSchemeFactory implements SchemeFactory {
public AchieveResultTupleScheme getScheme() {
return new AchieveResultTupleScheme();
}
}
private static class AchieveResultTupleScheme extends TupleScheme<AchieveResult> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, AchieveResult struct) throws org.apache.thrift.TException {
TTupleProtocol oprot = (TTupleProtocol) prot;
oprot.writeI32(struct.score.getValue());
oprot.writeBool(struct.isShot);
BitSet optionals = new BitSet();
if (struct.isSetDetail()) {
optionals.set(0);
}
oprot.writeBitSet(optionals, 1);
if (struct.isSetDetail()) {
oprot.writeString(struct.detail);
}
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, AchieveResult struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
struct.score = ResultScore.findByValue(iprot.readI32());
struct.setScoreIsSet(true);
struct.isShot = iprot.readBool();
struct.setIsShotIsSet(true);
BitSet incoming = iprot.readBitSet(1);
if (incoming.get(0)) {
struct.detail = iprot.readString();
struct.setDetailIsSet(true);
}
}
}
}