Created
November 30, 2011 19:45
-
-
Save mccv/1410485 to your computer and use it in GitHub Desktop.
TestServer.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Autogenerated by Thrift | |
* | |
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING | |
*/ | |
package com.twitter.gizzard.testserver.thrift; | |
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.*; | |
public class TestServer { | |
public interface Iface { | |
public void put(int key, String value) throws TException; | |
public List<TestResult> get(int key) throws TException; | |
} | |
public interface AsyncIface { | |
public void put(int key, String value, AsyncMethodCallback<AsyncClient.put_call> resultHandler) throws TException; | |
public void get(int key, AsyncMethodCallback<AsyncClient.get_call> resultHandler) throws TException; | |
} | |
public static class Client implements TServiceClient, 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) | |
{ | |
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 void put(int key, String value) throws TException | |
{ | |
send_put(key, value); | |
recv_put(); | |
} | |
public void send_put(int key, String value) throws TException | |
{ | |
oprot_.writeMessageBegin(new TMessage("put", TMessageType.CALL, ++seqid_)); | |
put_args args = new put_args(); | |
args.setKey(key); | |
args.setValue(value); | |
args.write(oprot_); | |
oprot_.writeMessageEnd(); | |
oprot_.getTransport().flush(); | |
} | |
public void recv_put() throws 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, "put failed: out of sequence response"); | |
} | |
put_result result = new put_result(); | |
result.read(iprot_); | |
iprot_.readMessageEnd(); | |
return; | |
} | |
public List<TestResult> get(int key) throws TException | |
{ | |
send_get(key); | |
return recv_get(); | |
} | |
public void send_get(int key) throws TException | |
{ | |
oprot_.writeMessageBegin(new TMessage("get", TMessageType.CALL, ++seqid_)); | |
get_args args = new get_args(); | |
args.setKey(key); | |
args.write(oprot_); | |
oprot_.writeMessageEnd(); | |
oprot_.getTransport().flush(); | |
} | |
public List<TestResult> recv_get() throws 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; | |
} | |
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 put(int key, String value, AsyncMethodCallback<put_call> resultHandler) throws TException { | |
checkReady(); | |
put_call method_call = new put_call(key, value, resultHandler, this, protocolFactory, transport); | |
manager.call(method_call); | |
} | |
public static class put_call extends TAsyncMethodCall { | |
private int key; | |
private String value; | |
public put_call(int key, String value, AsyncMethodCallback<put_call> resultHandler, TAsyncClient client, TProtocolFactory protocolFactory, TNonblockingTransport transport) throws TException { | |
super(client, protocolFactory, transport, resultHandler, false); | |
this.key = key; | |
this.value = value; | |
} | |
public void write_args(TProtocol prot) throws TException { | |
prot.writeMessageBegin(new TMessage("put", TMessageType.CALL, 0)); | |
put_args args = new put_args(); | |
args.setKey(key); | |
args.setValue(value); | |
args.write(prot); | |
prot.writeMessageEnd(); | |
} | |
public void getResult() throws 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); | |
(new Client(prot)).recv_put(); | |
} | |
} | |
public void get(int key, AsyncMethodCallback<get_call> resultHandler) throws TException { | |
checkReady(); | |
get_call method_call = new get_call(key, resultHandler, this, protocolFactory, transport); | |
manager.call(method_call); | |
} | |
public static class get_call extends TAsyncMethodCall { | |
private int key; | |
public get_call(int key, AsyncMethodCallback<get_call> resultHandler, TAsyncClient client, TProtocolFactory protocolFactory, TNonblockingTransport transport) throws TException { | |
super(client, protocolFactory, transport, resultHandler, false); | |
this.key = key; | |
} | |
public void write_args(TProtocol prot) throws TException { | |
prot.writeMessageBegin(new TMessage("get", TMessageType.CALL, 0)); | |
get_args args = new get_args(); | |
args.setKey(key); | |
args.write(prot); | |
prot.writeMessageEnd(); | |
} | |
public List<TestResult> getResult() throws 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 Processor implements TProcessor { | |
private static final Logger LOGGER = LoggerFactory.getLogger(Processor.class.getName()); | |
public Processor(Iface iface) | |
{ | |
iface_ = iface; | |
processMap_.put("put", new put()); | |
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 put implements ProcessFunction { | |
public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException | |
{ | |
put_args args = new put_args(); | |
try { | |
args.read(iprot); | |
} catch (TProtocolException e) { | |
iprot.readMessageEnd(); | |
TApplicationException x = new TApplicationException(TApplicationException.PROTOCOL_ERROR, e.getMessage()); | |
oprot.writeMessageBegin(new TMessage("put", TMessageType.EXCEPTION, seqid)); | |
x.write(oprot); | |
oprot.writeMessageEnd(); | |
oprot.getTransport().flush(); | |
return; | |
} | |
iprot.readMessageEnd(); | |
put_result result = new put_result(); | |
iface_.put(args.key, args.value); | |
oprot.writeMessageBegin(new TMessage("put", TMessageType.REPLY, seqid)); | |
result.write(oprot); | |
oprot.writeMessageEnd(); | |
oprot.getTransport().flush(); | |
} | |
} | |
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(); | |
result.success = iface_.get(args.key); | |
oprot.writeMessageBegin(new TMessage("get", TMessageType.REPLY, seqid)); | |
result.write(oprot); | |
oprot.writeMessageEnd(); | |
oprot.getTransport().flush(); | |
} | |
} | |
} | |
public static class put_args implements TBase<put_args, put_args._Fields>, java.io.Serializable, Cloneable { | |
private static final TStruct STRUCT_DESC = new TStruct("put_args"); | |
private static final TField KEY_FIELD_DESC = new TField("key", TType.I32, (short)1); | |
private static final TField VALUE_FIELD_DESC = new TField("value", TType.STRING, (short)2); | |
public int key; | |
public String value; | |
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ | |
public enum _Fields implements TFieldIdEnum { | |
KEY((short)1, "key"), | |
VALUE((short)2, "value"); | |
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: // KEY | |
return KEY; | |
case 2: // VALUE | |
return VALUE; | |
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 __KEY_ISSET_ID = 0; | |
private BitSet __isset_bit_vector = new BitSet(1); | |
public static final Map<_Fields, FieldMetaData> metaDataMap; | |
static { | |
Map<_Fields, FieldMetaData> tmpMap = new EnumMap<_Fields, FieldMetaData>(_Fields.class); | |
tmpMap.put(_Fields.KEY, new FieldMetaData("key", TFieldRequirementType.DEFAULT, | |
new FieldValueMetaData(TType.I32))); | |
tmpMap.put(_Fields.VALUE, new FieldMetaData("value", TFieldRequirementType.DEFAULT, | |
new FieldValueMetaData(TType.STRING))); | |
metaDataMap = Collections.unmodifiableMap(tmpMap); | |
FieldMetaData.addStructMetaDataMap(put_args.class, metaDataMap); | |
} | |
public put_args() { | |
} | |
public put_args( | |
int key, | |
String value) | |
{ | |
this(); | |
this.key = key; | |
setKeyIsSet(true); | |
this.value = value; | |
} | |
/** | |
* Performs a deep copy on <i>other</i>. | |
*/ | |
public put_args(put_args other) { | |
__isset_bit_vector.clear(); | |
__isset_bit_vector.or(other.__isset_bit_vector); | |
this.key = other.key; | |
if (other.isSetValue()) { | |
this.value = other.value; | |
} | |
} | |
public put_args deepCopy() { | |
return new put_args(this); | |
} | |
@Override | |
public void clear() { | |
setKeyIsSet(false); | |
this.key = 0; | |
this.value = null; | |
} | |
public int getKey() { | |
return this.key; | |
} | |
public put_args setKey(int key) { | |
this.key = key; | |
setKeyIsSet(true); | |
return this; | |
} | |
public void unsetKey() { | |
__isset_bit_vector.clear(__KEY_ISSET_ID); | |
} | |
/** Returns true if field key is set (has been asigned a value) and false otherwise */ | |
public boolean isSetKey() { | |
return __isset_bit_vector.get(__KEY_ISSET_ID); | |
} | |
public void setKeyIsSet(boolean value) { | |
__isset_bit_vector.set(__KEY_ISSET_ID, value); | |
} | |
public String getValue() { | |
return this.value; | |
} | |
public put_args setValue(String value) { | |
this.value = value; | |
return this; | |
} | |
public void unsetValue() { | |
this.value = null; | |
} | |
/** Returns true if field value is set (has been asigned a value) and false otherwise */ | |
public boolean isSetValue() { | |
return this.value != null; | |
} | |
public void setValueIsSet(boolean value) { | |
if (!value) { | |
this.value = null; | |
} | |
} | |
public void setFieldValue(_Fields field, Object value) { | |
switch (field) { | |
case KEY: | |
if (value == null) { | |
unsetKey(); | |
} else { | |
setKey((Integer)value); | |
} | |
break; | |
case VALUE: | |
if (value == null) { | |
unsetValue(); | |
} else { | |
setValue((String)value); | |
} | |
break; | |
} | |
} | |
public Object getFieldValue(_Fields field) { | |
switch (field) { | |
case KEY: | |
return new Integer(getKey()); | |
case VALUE: | |
return getValue(); | |
} | |
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 KEY: | |
return isSetKey(); | |
case VALUE: | |
return isSetValue(); | |
} | |
throw new IllegalStateException(); | |
} | |
@Override | |
public boolean equals(Object that) { | |
if (that == null) | |
return false; | |
if (that instanceof put_args) | |
return this.equals((put_args)that); | |
return false; | |
} | |
public boolean equals(put_args that) { | |
if (that == null) | |
return false; | |
boolean this_present_key = true; | |
boolean that_present_key = true; | |
if (this_present_key || that_present_key) { | |
if (!(this_present_key && that_present_key)) | |
return false; | |
if (this.key != that.key) | |
return false; | |
} | |
boolean this_present_value = true && this.isSetValue(); | |
boolean that_present_value = true && that.isSetValue(); | |
if (this_present_value || that_present_value) { | |
if (!(this_present_value && that_present_value)) | |
return false; | |
if (!this.value.equals(that.value)) | |
return false; | |
} | |
return true; | |
} | |
@Override | |
public int hashCode() { | |
return 0; | |
} | |
public int compareTo(put_args other) { | |
if (!getClass().equals(other.getClass())) { | |
return getClass().getName().compareTo(other.getClass().getName()); | |
} | |
int lastComparison = 0; | |
put_args typedOther = (put_args)other; | |
lastComparison = Boolean.valueOf(isSetKey()).compareTo(typedOther.isSetKey()); | |
if (lastComparison != 0) { | |
return lastComparison; | |
} | |
if (isSetKey()) { | |
lastComparison = TBaseHelper.compareTo(this.key, typedOther.key); | |
if (lastComparison != 0) { | |
return lastComparison; | |
} | |
} | |
lastComparison = Boolean.valueOf(isSetValue()).compareTo(typedOther.isSetValue()); | |
if (lastComparison != 0) { | |
return lastComparison; | |
} | |
if (isSetValue()) { | |
lastComparison = TBaseHelper.compareTo(this.value, typedOther.value); | |
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: // KEY | |
if (field.type == TType.I32) { | |
this.key = iprot.readI32(); | |
setKeyIsSet(true); | |
} else { | |
TProtocolUtil.skip(iprot, field.type); | |
} | |
break; | |
case 2: // VALUE | |
if (field.type == TType.STRING) { | |
this.value = 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); | |
oprot.writeFieldBegin(KEY_FIELD_DESC); | |
oprot.writeI32(this.key); | |
oprot.writeFieldEnd(); | |
if (this.value != null) { | |
oprot.writeFieldBegin(VALUE_FIELD_DESC); | |
oprot.writeString(this.value); | |
oprot.writeFieldEnd(); | |
} | |
oprot.writeFieldStop(); | |
oprot.writeStructEnd(); | |
} | |
@Override | |
public String toString() { | |
StringBuilder sb = new StringBuilder("put_args("); | |
boolean first = true; | |
sb.append("key:"); | |
sb.append(this.key); | |
first = false; | |
if (!first) sb.append(", "); | |
sb.append("value:"); | |
if (this.value == null) { | |
sb.append("null"); | |
} else { | |
sb.append(this.value); | |
} | |
first = false; | |
sb.append(")"); | |
return sb.toString(); | |
} | |
public void validate() throws TException { | |
// check for required fields | |
} | |
} | |
public static class put_result implements TBase<put_result, put_result._Fields>, java.io.Serializable, Cloneable { | |
private static final TStruct STRUCT_DESC = new TStruct("put_result"); | |
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ | |
public enum _Fields implements TFieldIdEnum { | |
; | |
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) { | |
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; | |
} | |
} | |
public static final Map<_Fields, FieldMetaData> metaDataMap; | |
static { | |
Map<_Fields, FieldMetaData> tmpMap = new EnumMap<_Fields, FieldMetaData>(_Fields.class); | |
metaDataMap = Collections.unmodifiableMap(tmpMap); | |
FieldMetaData.addStructMetaDataMap(put_result.class, metaDataMap); | |
} | |
public put_result() { | |
} | |
/** | |
* Performs a deep copy on <i>other</i>. | |
*/ | |
public put_result(put_result other) { | |
} | |
public put_result deepCopy() { | |
return new put_result(this); | |
} | |
@Override | |
public void clear() { | |
} | |
public void setFieldValue(_Fields field, Object value) { | |
switch (field) { | |
} | |
} | |
public Object getFieldValue(_Fields field) { | |
switch (field) { | |
} | |
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) { | |
} | |
throw new IllegalStateException(); | |
} | |
@Override | |
public boolean equals(Object that) { | |
if (that == null) | |
return false; | |
if (that instanceof put_result) | |
return this.equals((put_result)that); | |
return false; | |
} | |
public boolean equals(put_result that) { | |
if (that == null) | |
return false; | |
return true; | |
} | |
@Override | |
public int hashCode() { | |
return 0; | |
} | |
public int compareTo(put_result other) { | |
if (!getClass().equals(other.getClass())) { | |
return getClass().getName().compareTo(other.getClass().getName()); | |
} | |
int lastComparison = 0; | |
put_result typedOther = (put_result)other; | |
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) { | |
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); | |
oprot.writeFieldStop(); | |
oprot.writeStructEnd(); | |
} | |
@Override | |
public String toString() { | |
StringBuilder sb = new StringBuilder("put_result("); | |
boolean first = true; | |
sb.append(")"); | |
return sb.toString(); | |
} | |
public void validate() throws TException { | |
// check for required fields | |
} | |
} | |
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 KEY_FIELD_DESC = new TField("key", TType.I32, (short)1); | |
public int key; | |
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ | |
public enum _Fields implements TFieldIdEnum { | |
KEY((short)1, "key"); | |
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: // KEY | |
return KEY; | |
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 __KEY_ISSET_ID = 0; | |
private BitSet __isset_bit_vector = new BitSet(1); | |
public static final Map<_Fields, FieldMetaData> metaDataMap; | |
static { | |
Map<_Fields, FieldMetaData> tmpMap = new EnumMap<_Fields, FieldMetaData>(_Fields.class); | |
tmpMap.put(_Fields.KEY, new FieldMetaData("key", TFieldRequirementType.DEFAULT, | |
new FieldValueMetaData(TType.I32))); | |
metaDataMap = Collections.unmodifiableMap(tmpMap); | |
FieldMetaData.addStructMetaDataMap(get_args.class, metaDataMap); | |
} | |
public get_args() { | |
} | |
public get_args( | |
int key) | |
{ | |
this(); | |
this.key = key; | |
setKeyIsSet(true); | |
} | |
/** | |
* Performs a deep copy on <i>other</i>. | |
*/ | |
public get_args(get_args other) { | |
__isset_bit_vector.clear(); | |
__isset_bit_vector.or(other.__isset_bit_vector); | |
this.key = other.key; | |
} | |
public get_args deepCopy() { | |
return new get_args(this); | |
} | |
@Override | |
public void clear() { | |
setKeyIsSet(false); | |
this.key = 0; | |
} | |
public int getKey() { | |
return this.key; | |
} | |
public get_args setKey(int key) { | |
this.key = key; | |
setKeyIsSet(true); | |
return this; | |
} | |
public void unsetKey() { | |
__isset_bit_vector.clear(__KEY_ISSET_ID); | |
} | |
/** Returns true if field key is set (has been asigned a value) and false otherwise */ | |
public boolean isSetKey() { | |
return __isset_bit_vector.get(__KEY_ISSET_ID); | |
} | |
public void setKeyIsSet(boolean value) { | |
__isset_bit_vector.set(__KEY_ISSET_ID, value); | |
} | |
public void setFieldValue(_Fields field, Object value) { | |
switch (field) { | |
case KEY: | |
if (value == null) { | |
unsetKey(); | |
} else { | |
setKey((Integer)value); | |
} | |
break; | |
} | |
} | |
public Object getFieldValue(_Fields field) { | |
switch (field) { | |
case KEY: | |
return new Integer(getKey()); | |
} | |
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 KEY: | |
return isSetKey(); | |
} | |
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_key = true; | |
boolean that_present_key = true; | |
if (this_present_key || that_present_key) { | |
if (!(this_present_key && that_present_key)) | |
return false; | |
if (this.key != that.key) | |
return false; | |
} | |
return true; | |
} | |
@Override | |
public int hashCode() { | |
return 0; | |
} | |
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(isSetKey()).compareTo(typedOther.isSetKey()); | |
if (lastComparison != 0) { | |
return lastComparison; | |
} | |
if (isSetKey()) { | |
lastComparison = TBaseHelper.compareTo(this.key, typedOther.key); | |
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: // KEY | |
if (field.type == TType.I32) { | |
this.key = iprot.readI32(); | |
setKeyIsSet(true); | |
} 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); | |
oprot.writeFieldBegin(KEY_FIELD_DESC); | |
oprot.writeI32(this.key); | |
oprot.writeFieldEnd(); | |
oprot.writeFieldStop(); | |
oprot.writeStructEnd(); | |
} | |
@Override | |
public String toString() { | |
StringBuilder sb = new StringBuilder("get_args("); | |
boolean first = true; | |
sb.append("key:"); | |
sb.append(this.key); | |
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.LIST, (short)0); | |
public List<TestResult> success; | |
/** 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"); | |
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; | |
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 ListMetaData(TType.LIST, | |
new StructMetaData(TType.STRUCT, TestResult.class)))); | |
metaDataMap = Collections.unmodifiableMap(tmpMap); | |
FieldMetaData.addStructMetaDataMap(get_result.class, metaDataMap); | |
} | |
public get_result() { | |
} | |
public get_result( | |
List<TestResult> success) | |
{ | |
this(); | |
this.success = success; | |
} | |
/** | |
* Performs a deep copy on <i>other</i>. | |
*/ | |
public get_result(get_result other) { | |
if (other.isSetSuccess()) { | |
List<TestResult> __this__success = new ArrayList<TestResult>(); | |
for (TestResult other_element : other.success) { | |
__this__success.add(new TestResult(other_element)); | |
} | |
this.success = __this__success; | |
} | |
} | |
public get_result deepCopy() { | |
return new get_result(this); | |
} | |
@Override | |
public void clear() { | |
this.success = null; | |
} | |
public int getSuccessSize() { | |
return (this.success == null) ? 0 : this.success.size(); | |
} | |
public java.util.Iterator<TestResult> getSuccessIterator() { | |
return (this.success == null) ? null : this.success.iterator(); | |
} | |
public void addToSuccess(TestResult elem) { | |
if (this.success == null) { | |
this.success = new ArrayList<TestResult>(); | |
} | |
this.success.add(elem); | |
} | |
public List<TestResult> getSuccess() { | |
return this.success; | |
} | |
public get_result setSuccess(List<TestResult> 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 void setFieldValue(_Fields field, Object value) { | |
switch (field) { | |
case SUCCESS: | |
if (value == null) { | |
unsetSuccess(); | |
} else { | |
setSuccess((List<TestResult>)value); | |
} | |
break; | |
} | |
} | |
public Object getFieldValue(_Fields field) { | |
switch (field) { | |
case SUCCESS: | |
return getSuccess(); | |
} | |
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(); | |
} | |
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; | |
} | |
return true; | |
} | |
@Override | |
public int hashCode() { | |
return 0; | |
} | |
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; | |
} | |
} | |
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.LIST) { | |
{ | |
TList _list0 = iprot.readListBegin(); | |
this.success = new ArrayList<TestResult>(_list0.size); | |
for (int _i1 = 0; _i1 < _list0.size; ++_i1) | |
{ | |
TestResult _elem2; | |
_elem2 = new TestResult(); | |
_elem2.read(iprot); | |
this.success.add(_elem2); | |
} | |
iprot.readListEnd(); | |
} | |
} else { | |
TProtocolUtil.skip(iprot, field.type); | |
} | |
break; | |
default: | |
TProtocolUtil.skip(iprot, field.type); | |
} | |
iprot.readFieldEnd(); | |
} | |
iprot.readStructEnd(); | |
// check for required fields of primitive type, which can't be checked in the validate method | |
validate(); | |
} | |
public void write(TProtocol oprot) throws TException { | |
oprot.writeStructBegin(STRUCT_DESC); | |
if (this.isSetSuccess()) { | |
oprot.writeFieldBegin(SUCCESS_FIELD_DESC); | |
{ | |
oprot.writeListBegin(new TList(TType.STRUCT, this.success.size())); | |
for (TestResult _iter3 : this.success) | |
{ | |
_iter3.write(oprot); | |
} | |
oprot.writeListEnd(); | |
} | |
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; | |
sb.append(")"); | |
return sb.toString(); | |
} | |
public void validate() throws TException { | |
// check for required fields | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment