/** * Autogenerated by Thrift * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING */ package com.ganji.as.thrift.protocol.finagle.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 PostLimitServiceFinagle { public interface Iface { public com.ganji.as.thrift.protocol.client.test.OperateResult getPostLimit( String strJSONParam, 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 getPostLimit(String strJSONParam, String token, AsyncMethodCallback<AsyncClient.getPostLimit_call> resultHandler) throws TException; } public interface ServiceIface { public Future<com.ganji.as.thrift.protocol.client.test.OperateResult> getPostLimit( String strJSONParam, 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.OperateResult getPostLimit( String strJSONParam, String token) throws com.ganji.as.thrift.protocol.client.test.ParamterException, com.ganji.as.thrift.protocol.client.test.OperationException, TException { send_getPostLimit(strJSONParam, token); return recv_getPostLimit(); } public void send_getPostLimit(String strJSONParam, String token) throws TException { oprot_.writeMessageBegin(new TMessage("getPostLimit", TMessageType.CALL, ++seqid_)); getPostLimit_args args = new getPostLimit_args(); args.setStrJSONParam(strJSONParam); args.setToken(token); args.write(oprot_); oprot_.writeMessageEnd(); oprot_.getTransport().flush(); } public com.ganji.as.thrift.protocol.client.test.OperateResult recv_getPostLimit() 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, "getPostLimit failed: out of sequence response"); } getPostLimit_result result = new getPostLimit_result(); result.read(iprot_); iprot_.readMessageEnd(); if (result.isSetSuccess()) { return result.success; } if (result.pe != null) { throw result.pe; } if (result.oe != null) { throw result.oe; } throw new TApplicationException( TApplicationException.MISSING_RESULT, "getPostLimit 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 getPostLimit(String strJSONParam, String token, AsyncMethodCallback<getPostLimit_call> resultHandler) throws TException { checkReady(); getPostLimit_call method_call = new getPostLimit_call(strJSONParam, token, resultHandler, this, ___protocolFactory, ___transport); ___manager.call(method_call); } public static class getPostLimit_call extends TAsyncMethodCall { private String strJSONParam; private String token; public getPostLimit_call(String strJSONParam, String token, AsyncMethodCallback<getPostLimit_call> resultHandler, TAsyncClient client, TProtocolFactory protocolFactory, TNonblockingTransport transport) throws TException { super(client, protocolFactory, transport, resultHandler, false); this.strJSONParam = strJSONParam; this.token = token; } public void write_args(TProtocol prot) throws TException { prot.writeMessageBegin(new TMessage("getPostLimit", TMessageType.CALL, 0)); getPostLimit_args args = new getPostLimit_args(); args.setStrJSONParam(strJSONParam); args.setToken(token); args.write(prot); prot.writeMessageEnd(); } public com.ganji.as.thrift.protocol.client.test.OperateResult 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_getPostLimit(); } } } 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.OperateResult> getPostLimit( String strJSONParam, String token) { try { // TODO: size TMemoryBuffer __memoryTransport__ = new TMemoryBuffer(512); TProtocol __prot__ = this.protocolFactory .getProtocol(__memoryTransport__); __prot__.writeMessageBegin(new TMessage("getPostLimit", TMessageType.CALL, 0)); getPostLimit_args __args__ = new getPostLimit_args(); __args__.setStrJSONParam(strJSONParam); __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.OperateResult>>() { public Future<com.ganji.as.thrift.protocol.client.test.OperateResult> apply( byte[] __buffer__) { TMemoryInputTransport __memoryTransport__ = new TMemoryInputTransport( __buffer__); TProtocol __prot__ = ServiceToClient.this.protocolFactory .getProtocol(__memoryTransport__); try { return Future.value((new Client(__prot__)) .recv_getPostLimit()); } catch (Exception e) { return Future.exception(e); } } }); } catch (TException e) { return 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("getPostLimit", new getPostLimit()); } 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 getPostLimit implements ProcessFunction { public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException { getPostLimit_args args = new getPostLimit_args(); try { args.read(iprot); } catch (TProtocolException e) { iprot.readMessageEnd(); TApplicationException x = new TApplicationException( TApplicationException.PROTOCOL_ERROR, e.getMessage()); oprot.writeMessageBegin(new TMessage("getPostLimit", TMessageType.EXCEPTION, seqid)); x.write(oprot); oprot.writeMessageEnd(); oprot.getTransport().flush(); return; } iprot.readMessageEnd(); getPostLimit_result result = new getPostLimit_result(); try { result.success = iface_.getPostLimit(args.strJSONParam, args.token); } catch (com.ganji.as.thrift.protocol.client.test.ParamterException pe) { result.pe = pe; } catch (com.ganji.as.thrift.protocol.client.test.OperationException oe) { result.oe = oe; } catch (Throwable th) { LOGGER.error("Internal error processing getPostLimit", th); TApplicationException x = new TApplicationException( TApplicationException.INTERNAL_ERROR, "Internal error processing getPostLimit"); oprot.writeMessageBegin(new TMessage("getPostLimit", TMessageType.EXCEPTION, seqid)); x.write(oprot); oprot.writeMessageEnd(); oprot.getTransport().flush(); return; } oprot.writeMessageBegin(new TMessage("getPostLimit", 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("getPostLimit", new Function2<TProtocol, Integer, Future<byte[]>>() { public Future<byte[]> apply(final TProtocol iprot, final Integer seqid) { getPostLimit_args args = new getPostLimit_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( "getPostLimit", 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.OperateResult> future; try { future = iface.getPostLimit(args.strJSONParam, args.token); } catch (Exception e) { future = Future.exception(e); } try { return future .flatMap( new Function<com.ganji.as.thrift.protocol.client.test.OperateResult, Future<byte[]>>() { public Future<byte[]> apply( com.ganji.as.thrift.protocol.client.test.OperateResult value) { getPostLimit_result result = new getPostLimit_result(); result.success = value; result.setSuccessIsSet(true); try { TMemoryBuffer memoryBuffer = new TMemoryBuffer( 512); TProtocol oprot = protocolFactory .getProtocol(memoryBuffer); oprot.writeMessageBegin(new TMessage( "getPostLimit", 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 { getPostLimit_result result = new getPostLimit_result(); if (t instanceof com.ganji.as.thrift.protocol.client.test.ParamterException) { result.pe = (com.ganji.as.thrift.protocol.client.test.ParamterException) t; } else if (t instanceof com.ganji.as.thrift.protocol.client.test.OperationException) { result.oe = (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( "getPostLimit", 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 getPostLimit_args implements TBase<getPostLimit_args, getPostLimit_args._Fields>, java.io.Serializable, Cloneable { private static final TStruct STRUCT_DESC = new TStruct( "getPostLimit_args"); private static final TField STR_JSONPARAM_FIELD_DESC = new TField( "strJSONParam", TType.STRING, (short) 1); private static final TField TOKEN_FIELD_DESC = new TField("token", TType.STRING, (short) 2); public String strJSONParam; public String token; /** * The set of fields this struct contains, along with convenience * methods for finding and manipulating them. */ public enum _Fields implements TFieldIdEnum { STR_JSONPARAM((short) 1, "strJSONParam"), 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: // STR_JSONPARAM return STR_JSONPARAM; 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.STR_JSONPARAM, new FieldMetaData("strJSONParam", 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(getPostLimit_args.class, metaDataMap); } public getPostLimit_args() { } public getPostLimit_args(String strJSONParam, String token) { this(); this.strJSONParam = strJSONParam; this.token = token; } /** * Performs a deep copy on <i>other</i>. */ public getPostLimit_args(getPostLimit_args other) { if (other.isSetStrJSONParam()) { this.strJSONParam = other.strJSONParam; } if (other.isSetToken()) { this.token = other.token; } } public getPostLimit_args deepCopy() { return new getPostLimit_args(this); } @Override public void clear() { this.strJSONParam = null; this.token = null; } public String getStrJSONParam() { return this.strJSONParam; } public getPostLimit_args setStrJSONParam(String strJSONParam) { this.strJSONParam = strJSONParam; return this; } public void unsetStrJSONParam() { this.strJSONParam = null; } /** * Returns true if field strJSONParam is set (has been asigned a value) * and false otherwise */ public boolean isSetStrJSONParam() { return this.strJSONParam != null; } public void setStrJSONParamIsSet(boolean value) { if (!value) { this.strJSONParam = null; } } public String getToken() { return this.token; } public getPostLimit_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 STR_JSONPARAM: if (value == null) { unsetStrJSONParam(); } else { setStrJSONParam((String) value); } break; case TOKEN: if (value == null) { unsetToken(); } else { setToken((String) value); } break; } } public Object getFieldValue(_Fields field) { switch (field) { case STR_JSONPARAM: return getStrJSONParam(); 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 STR_JSONPARAM: return isSetStrJSONParam(); case TOKEN: return isSetToken(); } throw new IllegalStateException(); } @Override public boolean equals(Object that) { if (that == null) return false; if (that instanceof getPostLimit_args) return this.equals((getPostLimit_args) that); return false; } public boolean equals(getPostLimit_args that) { if (that == null) return false; boolean this_present_strJSONParam = true && this .isSetStrJSONParam(); boolean that_present_strJSONParam = true && that .isSetStrJSONParam(); if (this_present_strJSONParam || that_present_strJSONParam) { if (!(this_present_strJSONParam && that_present_strJSONParam)) return false; if (!this.strJSONParam.equals(that.strJSONParam)) 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_strJSONParam = true && (isSetStrJSONParam()); builder.append(present_strJSONParam); if (present_strJSONParam) builder.append(strJSONParam); boolean present_token = true && (isSetToken()); builder.append(present_token); if (present_token) builder.append(token); return builder.toHashCode(); } public int compareTo(getPostLimit_args other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo( other.getClass().getName()); } int lastComparison = 0; getPostLimit_args typedOther = (getPostLimit_args) other; lastComparison = Boolean.valueOf(isSetStrJSONParam()).compareTo( typedOther.isSetStrJSONParam()); if (lastComparison != 0) { return lastComparison; } if (isSetStrJSONParam()) { lastComparison = TBaseHelper.compareTo(this.strJSONParam, typedOther.strJSONParam); 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: // STR_JSONPARAM if (field.type == TType.STRING) { this.strJSONParam = 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.strJSONParam != null) { oprot.writeFieldBegin(STR_JSONPARAM_FIELD_DESC); oprot.writeString(this.strJSONParam); 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("getPostLimit_args("); boolean first = true; sb.append("strJSONParam:"); if (this.strJSONParam == null) { sb.append("null"); } else { sb.append(this.strJSONParam); } 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 getPostLimit_result implements TBase<getPostLimit_result, getPostLimit_result._Fields>, java.io.Serializable, Cloneable { private static final TStruct STRUCT_DESC = new TStruct( "getPostLimit_result"); private static final TField SUCCESS_FIELD_DESC = new TField("success", TType.STRUCT, (short) 0); private static final TField PE_FIELD_DESC = new TField("pe", TType.STRUCT, (short) 1); private static final TField OE_FIELD_DESC = new TField("oe", TType.STRUCT, (short) 2); public com.ganji.as.thrift.protocol.client.test.OperateResult success; public com.ganji.as.thrift.protocol.client.test.ParamterException pe; public com.ganji.as.thrift.protocol.client.test.OperationException oe; /** * 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"), PE((short) 1, "pe"), OE((short) 2, "oe"); 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: // PE return PE; case 2: // OE return OE; 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.OperateResult.class))); tmpMap.put(_Fields.PE, new FieldMetaData("pe", TFieldRequirementType.DEFAULT, new FieldValueMetaData( TType.STRUCT))); tmpMap.put(_Fields.OE, new FieldMetaData("oe", TFieldRequirementType.DEFAULT, new FieldValueMetaData( TType.STRUCT))); metaDataMap = Collections.unmodifiableMap(tmpMap); FieldMetaData.addStructMetaDataMap(getPostLimit_result.class, metaDataMap); } public getPostLimit_result() { } public getPostLimit_result( com.ganji.as.thrift.protocol.client.test.OperateResult success, com.ganji.as.thrift.protocol.client.test.ParamterException pe, com.ganji.as.thrift.protocol.client.test.OperationException oe) { this(); this.success = success; this.pe = pe; this.oe = oe; } /** * Performs a deep copy on <i>other</i>. */ public getPostLimit_result(getPostLimit_result other) { if (other.isSetSuccess()) { this.success = new com.ganji.as.thrift.protocol.client.test.OperateResult( other.success); } if (other.isSetPe()) { this.pe = new com.ganji.as.thrift.protocol.client.test.ParamterException( other.pe); } if (other.isSetOe()) { this.oe = new com.ganji.as.thrift.protocol.client.test.OperationException( other.oe); } } public getPostLimit_result deepCopy() { return new getPostLimit_result(this); } @Override public void clear() { this.success = null; this.pe = null; this.oe = null; } public com.ganji.as.thrift.protocol.client.test.OperateResult getSuccess() { return this.success; } public getPostLimit_result setSuccess( com.ganji.as.thrift.protocol.client.test.OperateResult 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 getPe() { return this.pe; } public getPostLimit_result setPe( com.ganji.as.thrift.protocol.client.test.ParamterException pe) { this.pe = pe; return this; } public void unsetPe() { this.pe = null; } /** * Returns true if field pe is set (has been asigned a value) and false * otherwise */ public boolean isSetPe() { return this.pe != null; } public void setPeIsSet(boolean value) { if (!value) { this.pe = null; } } public com.ganji.as.thrift.protocol.client.test.OperationException getOe() { return this.oe; } public getPostLimit_result setOe( com.ganji.as.thrift.protocol.client.test.OperationException oe) { this.oe = oe; return this; } public void unsetOe() { this.oe = null; } /** * Returns true if field oe is set (has been asigned a value) and false * otherwise */ public boolean isSetOe() { return this.oe != null; } public void setOeIsSet(boolean value) { if (!value) { this.oe = 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.OperateResult) value); } break; case PE: if (value == null) { unsetPe(); } else { setPe((com.ganji.as.thrift.protocol.client.test.ParamterException) value); } break; case OE: if (value == null) { unsetOe(); } else { setOe((com.ganji.as.thrift.protocol.client.test.OperationException) value); } break; } } public Object getFieldValue(_Fields field) { switch (field) { case SUCCESS: return getSuccess(); case PE: return getPe(); case OE: return getOe(); } 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 PE: return isSetPe(); case OE: return isSetOe(); } throw new IllegalStateException(); } @Override public boolean equals(Object that) { if (that == null) return false; if (that instanceof getPostLimit_result) return this.equals((getPostLimit_result) that); return false; } public boolean equals(getPostLimit_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_pe = true && this.isSetPe(); boolean that_present_pe = true && that.isSetPe(); if (this_present_pe || that_present_pe) { if (!(this_present_pe && that_present_pe)) return false; if (!this.pe.equals(that.pe)) return false; } boolean this_present_oe = true && this.isSetOe(); boolean that_present_oe = true && that.isSetOe(); if (this_present_oe || that_present_oe) { if (!(this_present_oe && that_present_oe)) return false; if (!this.oe.equals(that.oe)) 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_pe = true && (isSetPe()); builder.append(present_pe); if (present_pe) builder.append(pe); boolean present_oe = true && (isSetOe()); builder.append(present_oe); if (present_oe) builder.append(oe); return builder.toHashCode(); } public int compareTo(getPostLimit_result other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo( other.getClass().getName()); } int lastComparison = 0; getPostLimit_result typedOther = (getPostLimit_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(isSetPe()).compareTo( typedOther.isSetPe()); if (lastComparison != 0) { return lastComparison; } if (isSetPe()) { lastComparison = TBaseHelper.compareTo(this.pe, typedOther.pe); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetOe()).compareTo( typedOther.isSetOe()); if (lastComparison != 0) { return lastComparison; } if (isSetOe()) { lastComparison = TBaseHelper.compareTo(this.oe, typedOther.oe); 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.OperateResult(); this.success.read(iprot); } else { TProtocolUtil.skip(iprot, field.type); } break; case 1: // PE if (field.type == TType.STRUCT) { this.pe = new com.ganji.as.thrift.protocol.client.test.ParamterException(); this.pe.read(iprot); } else { TProtocolUtil.skip(iprot, field.type); } break; case 2: // OE if (field.type == TType.STRUCT) { this.oe = new com.ganji.as.thrift.protocol.client.test.OperationException(); this.oe.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.isSetPe()) { oprot.writeFieldBegin(PE_FIELD_DESC); this.pe.write(oprot); oprot.writeFieldEnd(); } else if (this.isSetOe()) { oprot.writeFieldBegin(OE_FIELD_DESC); this.oe.write(oprot); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } @Override public String toString() { StringBuilder sb = new StringBuilder("getPostLimit_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("pe:"); if (this.pe == null) { sb.append("null"); } else { sb.append(this.pe); } first = false; if (!first) sb.append(", "); sb.append("oe:"); if (this.oe == null) { sb.append("null"); } else { sb.append(this.oe); } first = false; sb.append(")"); return sb.toString(); } public void validate() throws TException { // check for required fields } } }