
com.twitter.elephantbird.examples.thrift.Name Maven / Gradle / Ivy
/**
* Autogenerated by Thrift Compiler (0.9.1)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package com.twitter.elephantbird.examples.thrift;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;
import org.apache.thrift.scheme.TupleScheme;
import org.apache.thrift.protocol.TTupleProtocol;
import org.apache.thrift.protocol.TProtocolException;
import org.apache.thrift.EncodingUtils;
import org.apache.thrift.TException;
import org.apache.thrift.async.AsyncMethodCallback;
import org.apache.thrift.server.AbstractNonblockingServer.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Name implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Name");
private static final org.apache.thrift.protocol.TField FIRST_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("first_name", org.apache.thrift.protocol.TType.STRING, (short)1);
private static final org.apache.thrift.protocol.TField LAST_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("last_name", org.apache.thrift.protocol.TType.STRING, (short)2);
private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>();
static {
schemes.put(StandardScheme.class, new NameStandardSchemeFactory());
schemes.put(TupleScheme.class, new NameTupleSchemeFactory());
}
public String first_name; // required
public String last_name; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
FIRST_NAME((short)1, "first_name"),
LAST_NAME((short)2, "last_name");
private static final Map byName = new HashMap();
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: // FIRST_NAME
return FIRST_NAME;
case 2: // LAST_NAME
return LAST_NAME;
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, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.FIRST_NAME, new org.apache.thrift.meta_data.FieldMetaData("first_name", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
tmpMap.put(_Fields.LAST_NAME, new org.apache.thrift.meta_data.FieldMetaData("last_name", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Name.class, metaDataMap);
}
public Name() {
}
public Name(
String first_name,
String last_name)
{
this();
this.first_name = first_name;
this.last_name = last_name;
}
/**
* Performs a deep copy on other.
*/
public Name(Name other) {
if (other.isSetFirst_name()) {
this.first_name = other.first_name;
}
if (other.isSetLast_name()) {
this.last_name = other.last_name;
}
}
public Name deepCopy() {
return new Name(this);
}
@Override
public void clear() {
this.first_name = null;
this.last_name = null;
}
public String getFirst_name() {
return this.first_name;
}
public Name setFirst_name(String first_name) {
this.first_name = first_name;
return this;
}
public void unsetFirst_name() {
this.first_name = null;
}
/** Returns true if field first_name is set (has been assigned a value) and false otherwise */
public boolean isSetFirst_name() {
return this.first_name != null;
}
public void setFirst_nameIsSet(boolean value) {
if (!value) {
this.first_name = null;
}
}
public String getLast_name() {
return this.last_name;
}
public Name setLast_name(String last_name) {
this.last_name = last_name;
return this;
}
public void unsetLast_name() {
this.last_name = null;
}
/** Returns true if field last_name is set (has been assigned a value) and false otherwise */
public boolean isSetLast_name() {
return this.last_name != null;
}
public void setLast_nameIsSet(boolean value) {
if (!value) {
this.last_name = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case FIRST_NAME:
if (value == null) {
unsetFirst_name();
} else {
setFirst_name((String)value);
}
break;
case LAST_NAME:
if (value == null) {
unsetLast_name();
} else {
setLast_name((String)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case FIRST_NAME:
return getFirst_name();
case LAST_NAME:
return getLast_name();
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case FIRST_NAME:
return isSetFirst_name();
case LAST_NAME:
return isSetLast_name();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof Name)
return this.equals((Name)that);
return false;
}
public boolean equals(Name that) {
if (that == null)
return false;
boolean this_present_first_name = true && this.isSetFirst_name();
boolean that_present_first_name = true && that.isSetFirst_name();
if (this_present_first_name || that_present_first_name) {
if (!(this_present_first_name && that_present_first_name))
return false;
if (!this.first_name.equals(that.first_name))
return false;
}
boolean this_present_last_name = true && this.isSetLast_name();
boolean that_present_last_name = true && that.isSetLast_name();
if (this_present_last_name || that_present_last_name) {
if (!(this_present_last_name && that_present_last_name))
return false;
if (!this.last_name.equals(that.last_name))
return false;
}
return true;
}
@Override
public int hashCode() {
HashCodeBuilder builder = new HashCodeBuilder();
boolean present_first_name = true && (isSetFirst_name());
builder.append(present_first_name);
if (present_first_name)
builder.append(first_name);
boolean present_last_name = true && (isSetLast_name());
builder.append(present_last_name);
if (present_last_name)
builder.append(last_name);
return builder.toHashCode();
}
@Override
public int compareTo(Name other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
lastComparison = Boolean.valueOf(isSetFirst_name()).compareTo(other.isSetFirst_name());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetFirst_name()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.first_name, other.first_name);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetLast_name()).compareTo(other.isSetLast_name());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetLast_name()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.last_name, other.last_name);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("Name(");
boolean first = true;
sb.append("first_name:");
if (this.first_name == null) {
sb.append("null");
} else {
sb.append(this.first_name);
}
first = false;
if (!first) sb.append(", ");
sb.append("last_name:");
if (this.last_name == null) {
sb.append("null");
} else {
sb.append(this.last_name);
}
first = false;
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
// check for sub-struct validity
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private static class NameStandardSchemeFactory implements SchemeFactory {
public NameStandardScheme getScheme() {
return new NameStandardScheme();
}
}
private static class NameStandardScheme extends StandardScheme {
public void read(org.apache.thrift.protocol.TProtocol iprot, Name struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField schemeField;
iprot.readStructBegin();
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
case 1: // FIRST_NAME
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.first_name = iprot.readString();
struct.setFirst_nameIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 2: // LAST_NAME
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.last_name = iprot.readString();
struct.setLast_nameIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, Name struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
if (struct.first_name != null) {
oprot.writeFieldBegin(FIRST_NAME_FIELD_DESC);
oprot.writeString(struct.first_name);
oprot.writeFieldEnd();
}
if (struct.last_name != null) {
oprot.writeFieldBegin(LAST_NAME_FIELD_DESC);
oprot.writeString(struct.last_name);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class NameTupleSchemeFactory implements SchemeFactory {
public NameTupleScheme getScheme() {
return new NameTupleScheme();
}
}
private static class NameTupleScheme extends TupleScheme {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, Name struct) throws org.apache.thrift.TException {
TTupleProtocol oprot = (TTupleProtocol) prot;
BitSet optionals = new BitSet();
if (struct.isSetFirst_name()) {
optionals.set(0);
}
if (struct.isSetLast_name()) {
optionals.set(1);
}
oprot.writeBitSet(optionals, 2);
if (struct.isSetFirst_name()) {
oprot.writeString(struct.first_name);
}
if (struct.isSetLast_name()) {
oprot.writeString(struct.last_name);
}
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, Name struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
BitSet incoming = iprot.readBitSet(2);
if (incoming.get(0)) {
struct.first_name = iprot.readString();
struct.setFirst_nameIsSet(true);
}
if (incoming.get(1)) {
struct.last_name = iprot.readString();
struct.setLast_nameIsSet(true);
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy