/** * Autogenerated by Thrift * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING */ package com.ganji.as.thrift.protocol.client.test; import org.apache.commons.lang.builder.HashCodeBuilder; 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.*; import com.twitter.util.Future; import com.twitter.util.Function; import com.twitter.util.Function2; import com.twitter.util.Try; import com.twitter.util.Return; import com.twitter.util.Throw; import com.twitter.finagle.thrift.ThriftClientRequest; public class AntiSpamProcess { public interface Iface { public com.ganji.as.thrift.protocol.client.test.AchieveResult get( String param, String token) throws com.ganji.as.thrift.protocol.client.test.ParamterException, com.ganji.as.thrift.protocol.client.test.OperationException, TException; } public interface AsyncIface { public void get(String param, String token, AsyncMethodCallback<AsyncClient.get_call> resultHandler) throws TException; } public interface ServiceIface { public Future<com.ganji.as.thrift.protocol.client.test.AchieveResult> get( String param, String token); } abstract static public class AbstractService implements ServiceIface { @Override public Future<AchieveResult> get(String param, String token) { // TODO Auto-generated method stub return null; } abstract public com.ganji.as.thrift.protocol.client.future.Future<com.ganji.as.thrift.protocol.client.test.AchieveResult> get_( String param, String token); } public static class Client extends TServiceClient implements Iface { public static class Factory implements TServiceClientFactory<Client> { public Factory() { } public Client getClient(TProtocol prot) { return new Client(prot); } public Client getClient(TProtocol iprot, TProtocol oprot) { return new Client(iprot, oprot); } } public Client(TProtocol prot) { this(prot, prot); } public Client(TProtocol iprot, TProtocol oprot) { super(iprot, oprot); iprot_ = iprot; oprot_ = oprot; } protected TProtocol iprot_; protected TProtocol oprot_; protected int seqid_; public TProtocol getInputProtocol() { return this.iprot_; } public TProtocol getOutputProtocol() { return this.oprot_; } public com.ganji.as.thrift.protocol.client.test.AchieveResult get( String param, String token) throws com.ganji.as.thrift.protocol.client.test.ParamterException, com.ganji.as.thrift.protocol.client.test.OperationException, TException { send_get(param, token); return recv_get(); } public void send_get(String param, String token) throws TException { oprot_.writeMessageBegin(new TMessage("get", TMessageType.CALL, ++seqid_)); get_args args = new get_args(); args.setParam(param); args.setToken(token); args.write(oprot_); oprot_.writeMessageEnd(); oprot_.getTransport().flush(); } public com.ganji.as.thrift.protocol.client.test.AchieveResult recv_get() throws com.ganji.as.thrift.protocol.client.test.ParamterException, com.ganji.as.thrift.protocol.client.test.OperationException, TException { TMessage msg = iprot_.readMessageBegin(); if (msg.type == TMessageType.EXCEPTION) { TApplicationException x = TApplicationException.read(iprot_); iprot_.readMessageEnd(); throw x; } if (msg.seqid != seqid_) { throw new TApplicationException( TApplicationException.BAD_SEQUENCE_ID, "get failed: out of sequence response"); } get_result result = new get_result(); result.read(iprot_); iprot_.readMessageEnd(); if (result.isSetSuccess()) { return result.success; } if (result.ex1 != null) { throw result.ex1; } if (result.ex2 != null) { throw result.ex2; } throw new TApplicationException( TApplicationException.MISSING_RESULT, "get failed: unknown result"); } } public static class AsyncClient extends TAsyncClient implements AsyncIface { public static class Factory implements TAsyncClientFactory<AsyncClient> { private TAsyncClientManager clientManager; private TProtocolFactory protocolFactory; public Factory(TAsyncClientManager clientManager, TProtocolFactory protocolFactory) { this.clientManager = clientManager; this.protocolFactory = protocolFactory; } public AsyncClient getAsyncClient(TNonblockingTransport transport) { return new AsyncClient(protocolFactory, clientManager, transport); } } public AsyncClient(TProtocolFactory protocolFactory, TAsyncClientManager clientManager, TNonblockingTransport transport) { super(protocolFactory, clientManager, transport); } public void get(String param, String token, AsyncMethodCallback<get_call> resultHandler) throws TException { checkReady(); get_call method_call = new get_call(param, token, resultHandler, this, ___protocolFactory, ___transport); ___manager.call(method_call); } public static class get_call extends TAsyncMethodCall { private String param; private String token; public get_call(String param, String token, AsyncMethodCallback<get_call> resultHandler, TAsyncClient client, TProtocolFactory protocolFactory, TNonblockingTransport transport) throws TException { super(client, protocolFactory, transport, resultHandler, false); this.param = param; this.token = token; } public void write_args(TProtocol prot) throws TException { prot.writeMessageBegin(new TMessage("get", TMessageType.CALL, 0)); get_args args = new get_args(); args.setParam(param); args.setToken(token); args.write(prot); prot.writeMessageEnd(); } public com.ganji.as.thrift.protocol.client.test.AchieveResult getResult() throws com.ganji.as.thrift.protocol.client.test.ParamterException, com.ganji.as.thrift.protocol.client.test.OperationException, TException { if (getState() != State.RESPONSE_READ) { throw new IllegalStateException("Method call not finished!"); } TMemoryInputTransport memoryTransport = new TMemoryInputTransport( getFrameBuffer().array()); TProtocol prot = client.getProtocolFactory().getProtocol( memoryTransport); return (new Client(prot)).recv_get(); } } } public static class ServiceToClient implements ServiceIface { private com.twitter.finagle.Service<ThriftClientRequest, byte[]> service; private TProtocolFactory protocolFactory; public ServiceToClient( com.twitter.finagle.Service<ThriftClientRequest, byte[]> service, TProtocolFactory protocolFactory) { this.service = service; this.protocolFactory = protocolFactory; } public Future<com.ganji.as.thrift.protocol.client.test.AchieveResult> get( String param, String token) { try { // TODO: size TMemoryBuffer __memoryTransport__ = new TMemoryBuffer(512); TProtocol __prot__ = this.protocolFactory .getProtocol(__memoryTransport__); __prot__.writeMessageBegin(new TMessage("get", TMessageType.CALL, 0)); get_args __args__ = new get_args(); __args__.setParam(param); __args__.setToken(token); __args__.write(__prot__); __prot__.writeMessageEnd(); byte[] __buffer__ = Arrays.copyOfRange( __memoryTransport__.getArray(), 0, __memoryTransport__.length()); ThriftClientRequest __request__ = new ThriftClientRequest( __buffer__, false); Future<byte[]> __done__ = this.service.apply(__request__); return __done__ .flatMap(new Function<byte[], Future<com.ganji.as.thrift.protocol.client.test.AchieveResult>>() { public Future<com.ganji.as.thrift.protocol.client.test.AchieveResult> apply( byte[] __buffer__) { TMemoryInputTransport __memoryTransport__ = new TMemoryInputTransport( __buffer__); TProtocol __prot__ = ServiceToClient.this.protocolFactory .getProtocol(__memoryTransport__); try { return Future.value((new Client(__prot__)) .recv_get()); } catch (Exception e) { return Future.exception(e); } } }); } catch (TException e) { return Future.exception(e); } } } /* added by yikangfeng. */ static public class ServiceToFinagleClient extends AbstractService { private com.ganji.as.thrift.protocol.service.intf.ThriftProtocolService<com.ganji.as.thrift.protocol.client.request.ThriftClientRequest, byte[]> service; private TProtocolFactory protocolFactory; public ServiceToFinagleClient( com.ganji.as.thrift.protocol.service.intf.ThriftProtocolService<com.ganji.as.thrift.protocol.client.request.ThriftClientRequest, byte[]> service, TProtocolFactory protocolFactory) { this.service = service; this.protocolFactory = protocolFactory; } public com.ganji.as.thrift.protocol.client.future.Future<com.ganji.as.thrift.protocol.client.test.AchieveResult> get_( String param, String token) { try { // TODO: size TMemoryBuffer __memoryTransport__ = new TMemoryBuffer(512); TProtocol __prot__ = this.protocolFactory .getProtocol(__memoryTransport__); __prot__.writeMessageBegin(new TMessage("get", TMessageType.CALL, 0)); get_args __args__ = new get_args(); __args__.setParam(param); __args__.setToken(token); __args__.write(__prot__); __prot__.writeMessageEnd(); byte[] __buffer__ = Arrays.copyOfRange( __memoryTransport__.getArray(), 0, __memoryTransport__.length()); com.ganji.as.thrift.protocol.client.request.ThriftClientRequest __request__ = new com.ganji.as.thrift.protocol.client.request.ThriftClientRequest( __buffer__, false); com.ganji.as.thrift.protocol.client.future.Future<byte[]> __done__ = this.service .apply(__request__); return __done__ .flatMap(new com.ganji.as.thrift.protocol.service.intf.ThriftProtocolFunction<byte[], com.ganji.as.thrift.protocol.client.future.Future<com.ganji.as.thrift.protocol.client.test.AchieveResult>>() { public com.ganji.as.thrift.protocol.client.future.Future<com.ganji.as.thrift.protocol.client.test.AchieveResult> apply( byte[] __buffer__) { TMemoryInputTransport __memoryTransport__ = new TMemoryInputTransport( __buffer__); TProtocol __prot__ = ServiceToFinagleClient.this.protocolFactory .getProtocol(__memoryTransport__); try { return com.ganji.as.thrift.protocol.client.future.Future .value((new Client(__prot__)) .recv_get()); } catch (Exception e) { return com.ganji.as.thrift.protocol.client.future.Future .exception(e); } } }); } catch (TException e) { return com.ganji.as.thrift.protocol.client.future.Future .exception(e); } } } public static class Processor implements TProcessor { private static final Logger LOGGER = LoggerFactory .getLogger(Processor.class.getName()); public Processor(Iface iface) { iface_ = iface; processMap_.put("get", new get()); } protected static interface ProcessFunction { public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException; } private Iface iface_; protected final HashMap<String, ProcessFunction> processMap_ = new HashMap<String, ProcessFunction>(); public boolean process(TProtocol iprot, TProtocol oprot) throws TException { TMessage msg = iprot.readMessageBegin(); ProcessFunction fn = processMap_.get(msg.name); if (fn == null) { TProtocolUtil.skip(iprot, TType.STRUCT); iprot.readMessageEnd(); TApplicationException x = new TApplicationException( TApplicationException.UNKNOWN_METHOD, "Invalid method name: '" + msg.name + "'"); oprot.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid)); x.write(oprot); oprot.writeMessageEnd(); oprot.getTransport().flush(); return true; } fn.process(msg.seqid, iprot, oprot); return true; } private class get implements ProcessFunction { public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException { get_args args = new get_args(); try { args.read(iprot); } catch (TProtocolException e) { iprot.readMessageEnd(); TApplicationException x = new TApplicationException( TApplicationException.PROTOCOL_ERROR, e.getMessage()); oprot.writeMessageBegin(new TMessage("get", TMessageType.EXCEPTION, seqid)); x.write(oprot); oprot.writeMessageEnd(); oprot.getTransport().flush(); return; } iprot.readMessageEnd(); get_result result = new get_result(); try { result.success = iface_.get(args.param, args.token); } catch (com.ganji.as.thrift.protocol.client.test.ParamterException ex1) { result.ex1 = ex1; } catch (com.ganji.as.thrift.protocol.client.test.OperationException ex2) { result.ex2 = ex2; } catch (Throwable th) { LOGGER.error("Internal error processing get", th); TApplicationException x = new TApplicationException( TApplicationException.INTERNAL_ERROR, "Internal error processing get"); oprot.writeMessageBegin(new TMessage("get", TMessageType.EXCEPTION, seqid)); x.write(oprot); oprot.writeMessageEnd(); oprot.getTransport().flush(); return; } oprot.writeMessageBegin(new TMessage("get", TMessageType.REPLY, seqid)); result.write(oprot); oprot.writeMessageEnd(); oprot.getTransport().flush(); } } } public static class Service extends com.twitter.finagle.Service<byte[], byte[]> { private final ServiceIface iface; private final TProtocolFactory protocolFactory; protected HashMap<String, Function2<TProtocol, Integer, Future<byte[]>>> functionMap = new HashMap<String, Function2<TProtocol, Integer, Future<byte[]>>>(); public Service(final ServiceIface iface, final TProtocolFactory protocolFactory) { this.iface = iface; this.protocolFactory = protocolFactory; functionMap.put("get", new Function2<TProtocol, Integer, Future<byte[]>>() { public Future<byte[]> apply(final TProtocol iprot, final Integer seqid) { get_args args = new get_args(); try { args.read(iprot); } catch (TProtocolException e) { try { iprot.readMessageEnd(); TApplicationException x = new TApplicationException( TApplicationException.PROTOCOL_ERROR, e.getMessage()); TMemoryBuffer memoryBuffer = new TMemoryBuffer( 512); TProtocol oprot = protocolFactory .getProtocol(memoryBuffer); oprot.writeMessageBegin(new TMessage("get", TMessageType.EXCEPTION, seqid)); x.write(oprot); oprot.writeMessageEnd(); oprot.getTransport().flush(); byte[] buffer = Arrays.copyOfRange( memoryBuffer.getArray(), 0, memoryBuffer.length()); return Future.value(buffer); } catch (Exception e1) { return Future.exception(e1); } } catch (Exception e) { return Future.exception(e); } try { iprot.readMessageEnd(); } catch (Exception e) { return Future.exception(e); } Future<com.ganji.as.thrift.protocol.client.test.AchieveResult> future; try { future = iface.get(args.param, args.token); } catch (Exception e) { future = Future.exception(e); } try { return future .flatMap( new Function<com.ganji.as.thrift.protocol.client.test.AchieveResult, Future<byte[]>>() { public Future<byte[]> apply( com.ganji.as.thrift.protocol.client.test.AchieveResult value) { get_result result = new get_result(); result.success = value; result.setSuccessIsSet(true); try { TMemoryBuffer memoryBuffer = new TMemoryBuffer( 512); TProtocol oprot = protocolFactory .getProtocol(memoryBuffer); oprot.writeMessageBegin(new TMessage( "get", TMessageType.REPLY, seqid)); result.write(oprot); oprot.writeMessageEnd(); return Future .value(Arrays .copyOfRange( memoryBuffer .getArray(), 0, memoryBuffer .length())); } catch (Exception e) { return Future .exception(e); } } }) .rescue(new Function<Throwable, Future<byte[]>>() { public Future<byte[]> apply( Throwable t) { try { get_result result = new get_result(); if (t instanceof com.ganji.as.thrift.protocol.client.test.ParamterException) { result.ex1 = (com.ganji.as.thrift.protocol.client.test.ParamterException) t; } else if (t instanceof com.ganji.as.thrift.protocol.client.test.OperationException) { result.ex2 = (com.ganji.as.thrift.protocol.client.test.OperationException) t; } else { return Future .exception(t); } TMemoryBuffer memoryBuffer = new TMemoryBuffer( 512); TProtocol oprot = protocolFactory .getProtocol(memoryBuffer); oprot.writeMessageBegin(new TMessage( "get", TMessageType.REPLY, seqid)); result.write(oprot); oprot.writeMessageEnd(); oprot.getTransport() .flush(); return Future.value(Arrays.copyOfRange( memoryBuffer .getArray(), 0, memoryBuffer .length())); } catch (Exception e) { return Future.exception(e); } } }); } catch (Exception e) { return Future.exception(e); } } }); } public Future<byte[]> apply(byte[] request) { TTransport inputTransport = new TMemoryInputTransport(request); TProtocol iprot = protocolFactory.getProtocol(inputTransport); TMessage msg; try { msg = iprot.readMessageBegin(); } catch (Exception e) { return Future.exception(e); } Function2<TProtocol, Integer, Future<byte[]>> fn = functionMap .get(msg.name); if (fn == null) { try { TProtocolUtil.skip(iprot, TType.STRUCT); iprot.readMessageEnd(); TApplicationException x = new TApplicationException( TApplicationException.UNKNOWN_METHOD, "Invalid method name: '" + msg.name + "'"); TMemoryBuffer memoryBuffer = new TMemoryBuffer(512); TProtocol oprot = protocolFactory.getProtocol(memoryBuffer); oprot.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid)); x.write(oprot); oprot.writeMessageEnd(); oprot.getTransport().flush(); return Future.value(Arrays.copyOfRange( memoryBuffer.getArray(), 0, memoryBuffer.length())); } catch (Exception e) { return Future.exception(e); } } return fn.apply(iprot, msg.seqid); } } public static class get_args implements TBase<get_args, get_args._Fields>, java.io.Serializable, Cloneable { private static final TStruct STRUCT_DESC = new TStruct("get_args"); private static final TField PARAM_FIELD_DESC = new TField("param", TType.STRING, (short) 1); private static final TField TOKEN_FIELD_DESC = new TField("token", TType.STRING, (short) 2); public String param; public String token; /** * The set of fields this struct contains, along with convenience * methods for finding and manipulating them. */ public enum _Fields implements TFieldIdEnum { PARAM((short) 1, "param"), TOKEN((short) 2, "token"); 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: // PARAM return PARAM; case 2: // TOKEN return TOKEN; 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.PARAM, new FieldMetaData("param", TFieldRequirementType.DEFAULT, new FieldValueMetaData( TType.STRING))); tmpMap.put(_Fields.TOKEN, new FieldMetaData("token", TFieldRequirementType.DEFAULT, new FieldValueMetaData( TType.STRING))); metaDataMap = Collections.unmodifiableMap(tmpMap); FieldMetaData.addStructMetaDataMap(get_args.class, metaDataMap); } public get_args() { } public get_args(String param, String token) { this(); this.param = param; this.token = token; } /** * Performs a deep copy on <i>other</i>. */ public get_args(get_args other) { if (other.isSetParam()) { this.param = other.param; } if (other.isSetToken()) { this.token = other.token; } } public get_args deepCopy() { return new get_args(this); } @Override public void clear() { this.param = null; this.token = null; } public String getParam() { return this.param; } public get_args setParam(String param) { this.param = param; return this; } public void unsetParam() { this.param = null; } /** * Returns true if field param is set (has been asigned a value) and * false otherwise */ public boolean isSetParam() { return this.param != null; } public void setParamIsSet(boolean value) { if (!value) { this.param = null; } } public String getToken() { return this.token; } public get_args setToken(String token) { this.token = token; return this; } public void unsetToken() { this.token = null; } /** * Returns true if field token is set (has been asigned a value) and * false otherwise */ public boolean isSetToken() { return this.token != null; } public void setTokenIsSet(boolean value) { if (!value) { this.token = null; } } public void setFieldValue(_Fields field, Object value) { switch (field) { case PARAM: if (value == null) { unsetParam(); } else { setParam((String) value); } break; case TOKEN: if (value == null) { unsetToken(); } else { setToken((String) value); } break; } } public Object getFieldValue(_Fields field) { switch (field) { case PARAM: return getParam(); case TOKEN: return getToken(); } 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 PARAM: return isSetParam(); case TOKEN: return isSetToken(); } throw new IllegalStateException(); } @Override public boolean equals(Object that) { if (that == null) return false; if (that instanceof get_args) return this.equals((get_args) that); return false; } public boolean equals(get_args that) { if (that == null) return false; boolean this_present_param = true && this.isSetParam(); boolean that_present_param = true && that.isSetParam(); if (this_present_param || that_present_param) { if (!(this_present_param && that_present_param)) return false; if (!this.param.equals(that.param)) return false; } boolean this_present_token = true && this.isSetToken(); boolean that_present_token = true && that.isSetToken(); if (this_present_token || that_present_token) { if (!(this_present_token && that_present_token)) return false; if (!this.token.equals(that.token)) return false; } return true; } @Override public int hashCode() { HashCodeBuilder builder = new HashCodeBuilder(); boolean present_param = true && (isSetParam()); builder.append(present_param); if (present_param) builder.append(param); boolean present_token = true && (isSetToken()); builder.append(present_token); if (present_token) builder.append(token); return builder.toHashCode(); } public int compareTo(get_args other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo( other.getClass().getName()); } int lastComparison = 0; get_args typedOther = (get_args) other; lastComparison = Boolean.valueOf(isSetParam()).compareTo( typedOther.isSetParam()); if (lastComparison != 0) { return lastComparison; } if (isSetParam()) { lastComparison = TBaseHelper.compareTo(this.param, typedOther.param); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetToken()).compareTo( typedOther.isSetToken()); if (lastComparison != 0) { return lastComparison; } if (isSetToken()) { lastComparison = TBaseHelper.compareTo(this.token, typedOther.token); 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: // PARAM if (field.type == TType.STRING) { this.param = iprot.readString(); } else { TProtocolUtil.skip(iprot, field.type); } break; case 2: // TOKEN if (field.type == TType.STRING) { this.token = iprot.readString(); } 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.param != null) { oprot.writeFieldBegin(PARAM_FIELD_DESC); oprot.writeString(this.param); oprot.writeFieldEnd(); } if (this.token != null) { oprot.writeFieldBegin(TOKEN_FIELD_DESC); oprot.writeString(this.token); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } @Override public String toString() { StringBuilder sb = new StringBuilder("get_args("); boolean first = true; sb.append("param:"); if (this.param == null) { sb.append("null"); } else { sb.append(this.param); } first = false; if (!first) sb.append(", "); sb.append("token:"); if (this.token == null) { sb.append("null"); } else { sb.append(this.token); } first = false; sb.append(")"); return sb.toString(); } public void validate() throws TException { // check for required fields } } public static class get_result implements TBase<get_result, get_result._Fields>, java.io.Serializable, Cloneable { private static final TStruct STRUCT_DESC = new TStruct("get_result"); private static final TField SUCCESS_FIELD_DESC = new TField("success", TType.STRUCT, (short) 0); private static final TField EX1_FIELD_DESC = new TField("ex1", TType.STRUCT, (short) 1); private static final TField EX2_FIELD_DESC = new TField("ex2", TType.STRUCT, (short) 2); public com.ganji.as.thrift.protocol.client.test.AchieveResult success; public com.ganji.as.thrift.protocol.client.test.ParamterException ex1; public com.ganji.as.thrift.protocol.client.test.OperationException ex2; /** * The set of fields this struct contains, along with convenience * methods for finding and manipulating them. */ public enum _Fields implements TFieldIdEnum { SUCCESS((short) 0, "success"), EX1((short) 1, "ex1"), EX2( (short) 2, "ex2"); 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 0: // SUCCESS return SUCCESS; case 1: // EX1 return EX1; case 2: // EX2 return EX2; 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.SUCCESS, new FieldMetaData( "success", TFieldRequirementType.DEFAULT, new StructMetaData( TType.STRUCT, com.ganji.as.thrift.protocol.client.test.AchieveResult.class))); tmpMap.put(_Fields.EX1, new FieldMetaData("ex1", TFieldRequirementType.DEFAULT, new FieldValueMetaData( TType.STRUCT))); tmpMap.put(_Fields.EX2, new FieldMetaData("ex2", TFieldRequirementType.DEFAULT, new FieldValueMetaData( TType.STRUCT))); metaDataMap = Collections.unmodifiableMap(tmpMap); FieldMetaData.addStructMetaDataMap(get_result.class, metaDataMap); } public get_result() { } public get_result( com.ganji.as.thrift.protocol.client.test.AchieveResult success, com.ganji.as.thrift.protocol.client.test.ParamterException ex1, com.ganji.as.thrift.protocol.client.test.OperationException ex2) { this(); this.success = success; this.ex1 = ex1; this.ex2 = ex2; } /** * Performs a deep copy on <i>other</i>. */ public get_result(get_result other) { if (other.isSetSuccess()) { this.success = new com.ganji.as.thrift.protocol.client.test.AchieveResult( other.success); } if (other.isSetEx1()) { this.ex1 = new com.ganji.as.thrift.protocol.client.test.ParamterException( other.ex1); } if (other.isSetEx2()) { this.ex2 = new com.ganji.as.thrift.protocol.client.test.OperationException( other.ex2); } } public get_result deepCopy() { return new get_result(this); } @Override public void clear() { this.success = null; this.ex1 = null; this.ex2 = null; } public com.ganji.as.thrift.protocol.client.test.AchieveResult getSuccess() { return this.success; } public get_result setSuccess( com.ganji.as.thrift.protocol.client.test.AchieveResult success) { this.success = success; return this; } public void unsetSuccess() { this.success = null; } /** * Returns true if field success is set (has been asigned a value) and * false otherwise */ public boolean isSetSuccess() { return this.success != null; } public void setSuccessIsSet(boolean value) { if (!value) { this.success = null; } } public com.ganji.as.thrift.protocol.client.test.ParamterException getEx1() { return this.ex1; } public get_result setEx1( com.ganji.as.thrift.protocol.client.test.ParamterException ex1) { this.ex1 = ex1; return this; } public void unsetEx1() { this.ex1 = null; } /** * Returns true if field ex1 is set (has been asigned a value) and false * otherwise */ public boolean isSetEx1() { return this.ex1 != null; } public void setEx1IsSet(boolean value) { if (!value) { this.ex1 = null; } } public com.ganji.as.thrift.protocol.client.test.OperationException getEx2() { return this.ex2; } public get_result setEx2( com.ganji.as.thrift.protocol.client.test.OperationException ex2) { this.ex2 = ex2; return this; } public void unsetEx2() { this.ex2 = null; } /** * Returns true if field ex2 is set (has been asigned a value) and false * otherwise */ public boolean isSetEx2() { return this.ex2 != null; } public void setEx2IsSet(boolean value) { if (!value) { this.ex2 = null; } } public void setFieldValue(_Fields field, Object value) { switch (field) { case SUCCESS: if (value == null) { unsetSuccess(); } else { setSuccess((com.ganji.as.thrift.protocol.client.test.AchieveResult) value); } break; case EX1: if (value == null) { unsetEx1(); } else { setEx1((com.ganji.as.thrift.protocol.client.test.ParamterException) value); } break; case EX2: if (value == null) { unsetEx2(); } else { setEx2((com.ganji.as.thrift.protocol.client.test.OperationException) value); } break; } } public Object getFieldValue(_Fields field) { switch (field) { case SUCCESS: return getSuccess(); case EX1: return getEx1(); case EX2: return getEx2(); } 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 SUCCESS: return isSetSuccess(); case EX1: return isSetEx1(); case EX2: return isSetEx2(); } throw new IllegalStateException(); } @Override public boolean equals(Object that) { if (that == null) return false; if (that instanceof get_result) return this.equals((get_result) that); return false; } public boolean equals(get_result that) { if (that == null) return false; boolean this_present_success = true && this.isSetSuccess(); boolean that_present_success = true && that.isSetSuccess(); if (this_present_success || that_present_success) { if (!(this_present_success && that_present_success)) return false; if (!this.success.equals(that.success)) return false; } boolean this_present_ex1 = true && this.isSetEx1(); boolean that_present_ex1 = true && that.isSetEx1(); if (this_present_ex1 || that_present_ex1) { if (!(this_present_ex1 && that_present_ex1)) return false; if (!this.ex1.equals(that.ex1)) return false; } boolean this_present_ex2 = true && this.isSetEx2(); boolean that_present_ex2 = true && that.isSetEx2(); if (this_present_ex2 || that_present_ex2) { if (!(this_present_ex2 && that_present_ex2)) return false; if (!this.ex2.equals(that.ex2)) return false; } return true; } @Override public int hashCode() { HashCodeBuilder builder = new HashCodeBuilder(); boolean present_success = true && (isSetSuccess()); builder.append(present_success); if (present_success) builder.append(success); boolean present_ex1 = true && (isSetEx1()); builder.append(present_ex1); if (present_ex1) builder.append(ex1); boolean present_ex2 = true && (isSetEx2()); builder.append(present_ex2); if (present_ex2) builder.append(ex2); return builder.toHashCode(); } public int compareTo(get_result other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo( other.getClass().getName()); } int lastComparison = 0; get_result typedOther = (get_result) other; lastComparison = Boolean.valueOf(isSetSuccess()).compareTo( typedOther.isSetSuccess()); if (lastComparison != 0) { return lastComparison; } if (isSetSuccess()) { lastComparison = TBaseHelper.compareTo(this.success, typedOther.success); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetEx1()).compareTo( typedOther.isSetEx1()); if (lastComparison != 0) { return lastComparison; } if (isSetEx1()) { lastComparison = TBaseHelper .compareTo(this.ex1, typedOther.ex1); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetEx2()).compareTo( typedOther.isSetEx2()); if (lastComparison != 0) { return lastComparison; } if (isSetEx2()) { lastComparison = TBaseHelper .compareTo(this.ex2, typedOther.ex2); 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 0: // SUCCESS if (field.type == TType.STRUCT) { this.success = new com.ganji.as.thrift.protocol.client.test.AchieveResult(); this.success.read(iprot); } else { TProtocolUtil.skip(iprot, field.type); } break; case 1: // EX1 if (field.type == TType.STRUCT) { this.ex1 = new com.ganji.as.thrift.protocol.client.test.ParamterException(); this.ex1.read(iprot); } else { TProtocolUtil.skip(iprot, field.type); } break; case 2: // EX2 if (field.type == TType.STRUCT) { this.ex2 = new com.ganji.as.thrift.protocol.client.test.OperationException(); this.ex2.read(iprot); } 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 { oprot.writeStructBegin(STRUCT_DESC); if (this.isSetSuccess()) { oprot.writeFieldBegin(SUCCESS_FIELD_DESC); this.success.write(oprot); oprot.writeFieldEnd(); } else if (this.isSetEx1()) { oprot.writeFieldBegin(EX1_FIELD_DESC); this.ex1.write(oprot); oprot.writeFieldEnd(); } else if (this.isSetEx2()) { oprot.writeFieldBegin(EX2_FIELD_DESC); this.ex2.write(oprot); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } @Override public String toString() { StringBuilder sb = new StringBuilder("get_result("); boolean first = true; sb.append("success:"); if (this.success == null) { sb.append("null"); } else { sb.append(this.success); } first = false; if (!first) sb.append(", "); sb.append("ex1:"); if (this.ex1 == null) { sb.append("null"); } else { sb.append(this.ex1); } first = false; if (!first) sb.append(", "); sb.append("ex2:"); if (this.ex2 == null) { sb.append("null"); } else { sb.append(this.ex2); } first = false; sb.append(")"); return sb.toString(); } public void validate() throws TException { // check for required fields } } }