/**
* Autogenerated by Thrift Compiler (0.8.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package org.opentripplanner.api.thrift.definition;
import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;
import org.apache.thrift.scheme.TupleScheme;
import org.apache.thrift.protocol.TTupleProtocol;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class GraphEdge implements org.apache.thrift.TBase<GraphEdge, GraphEdge._Fields>, java.io.Serializable, Cloneable {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("GraphEdge");
private static final org.apache.thrift.protocol.TField ID_FIELD_DESC = new org.apache.thrift.protocol.TField("id", org.apache.thrift.protocol.TType.I32, (short)1);
private static final org.apache.thrift.protocol.TField HEAD_FIELD_DESC = new org.apache.thrift.protocol.TField("head", org.apache.thrift.protocol.TType.STRUCT, (short)2);
private static final org.apache.thrift.protocol.TField TAIL_FIELD_DESC = new org.apache.thrift.protocol.TField("tail", org.apache.thrift.protocol.TType.STRUCT, (short)3);
private static final org.apache.thrift.protocol.TField NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("name", org.apache.thrift.protocol.TType.STRING, (short)4);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
schemes.put(StandardScheme.class, new GraphEdgeStandardSchemeFactory());
schemes.put(TupleScheme.class, new GraphEdgeTupleSchemeFactory());
}
private int id; // required
private GraphVertex head; // required
private GraphVertex tail; // required
private String name; // optional
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
ID((short)1, "id"),
HEAD((short)2, "head"),
TAIL((short)3, "tail"),
NAME((short)4, "name");
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: // ID
return ID;
case 2: // HEAD
return HEAD;
case 3: // TAIL
return TAIL;
case 4: // NAME
return 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
private static final int __ID_ISSET_ID = 0;
private BitSet __isset_bit_vector = new BitSet(1);
private _Fields optionals[] = {_Fields.NAME};
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.ID, new org.apache.thrift.meta_data.FieldMetaData("id", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
tmpMap.put(_Fields.HEAD, new org.apache.thrift.meta_data.FieldMetaData("head", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, GraphVertex.class)));
tmpMap.put(_Fields.TAIL, new org.apache.thrift.meta_data.FieldMetaData("tail", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, GraphVertex.class)));
tmpMap.put(_Fields.NAME, new org.apache.thrift.meta_data.FieldMetaData("name", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(GraphEdge.class, metaDataMap);
}
public GraphEdge() {
}
public GraphEdge(
int id,
GraphVertex head,
GraphVertex tail)
{
this();
this.id = id;
setIdIsSet(true);
this.head = head;
this.tail = tail;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public GraphEdge(GraphEdge other) {
__isset_bit_vector.clear();
__isset_bit_vector.or(other.__isset_bit_vector);
this.id = other.id;
if (other.isSetHead()) {
this.head = new GraphVertex(other.head);
}
if (other.isSetTail()) {
this.tail = new GraphVertex(other.tail);
}
if (other.isSetName()) {
this.name = other.name;
}
}
public GraphEdge deepCopy() {
return new GraphEdge(this);
}
@Override
public void clear() {
setIdIsSet(false);
this.id = 0;
this.head = null;
this.tail = null;
this.name = null;
}
public int getId() {
return this.id;
}
public void setId(int id) {
this.id = id;
setIdIsSet(true);
}
public void unsetId() {
__isset_bit_vector.clear(__ID_ISSET_ID);
}
/** Returns true if field id is set (has been assigned a value) and false otherwise */
public boolean isSetId() {
return __isset_bit_vector.get(__ID_ISSET_ID);
}
public void setIdIsSet(boolean value) {
__isset_bit_vector.set(__ID_ISSET_ID, value);
}
public GraphVertex getHead() {
return this.head;
}
public void setHead(GraphVertex head) {
this.head = head;
}
public void unsetHead() {
this.head = null;
}
/** Returns true if field head is set (has been assigned a value) and false otherwise */
public boolean isSetHead() {
return this.head != null;
}
public void setHeadIsSet(boolean value) {
if (!value) {
this.head = null;
}
}
public GraphVertex getTail() {
return this.tail;
}
public void setTail(GraphVertex tail) {
this.tail = tail;
}
public void unsetTail() {
this.tail = null;
}
/** Returns true if field tail is set (has been assigned a value) and false otherwise */
public boolean isSetTail() {
return this.tail != null;
}
public void setTailIsSet(boolean value) {
if (!value) {
this.tail = null;
}
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public void unsetName() {
this.name = null;
}
/** Returns true if field name is set (has been assigned a value) and false otherwise */
public boolean isSetName() {
return this.name != null;
}
public void setNameIsSet(boolean value) {
if (!value) {
this.name = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case ID:
if (value == null) {
unsetId();
} else {
setId((Integer)value);
}
break;
case HEAD:
if (value == null) {
unsetHead();
} else {
setHead((GraphVertex)value);
}
break;
case TAIL:
if (value == null) {
unsetTail();
} else {
setTail((GraphVertex)value);
}
break;
case NAME:
if (value == null) {
unsetName();
} else {
setName((String)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case ID:
return Integer.valueOf(getId());
case HEAD:
return getHead();
case TAIL:
return getTail();
case NAME:
return getName();
}
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 ID:
return isSetId();
case HEAD:
return isSetHead();
case TAIL:
return isSetTail();
case NAME:
return isSetName();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof GraphEdge)
return this.equals((GraphEdge)that);
return false;
}
public boolean equals(GraphEdge that) {
if (that == null)
return false;
boolean this_present_id = true;
boolean that_present_id = true;
if (this_present_id || that_present_id) {
if (!(this_present_id && that_present_id))
return false;
if (this.id != that.id)
return false;
}
boolean this_present_head = true && this.isSetHead();
boolean that_present_head = true && that.isSetHead();
if (this_present_head || that_present_head) {
if (!(this_present_head && that_present_head))
return false;
if (!this.head.equals(that.head))
return false;
}
boolean this_present_tail = true && this.isSetTail();
boolean that_present_tail = true && that.isSetTail();
if (this_present_tail || that_present_tail) {
if (!(this_present_tail && that_present_tail))
return false;
if (!this.tail.equals(that.tail))
return false;
}
boolean this_present_name = true && this.isSetName();
boolean that_present_name = true && that.isSetName();
if (this_present_name || that_present_name) {
if (!(this_present_name && that_present_name))
return false;
if (!this.name.equals(that.name))
return false;
}
return true;
}
@Override
public int hashCode() {
return 0;
}
public int compareTo(GraphEdge other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
GraphEdge typedOther = (GraphEdge)other;
lastComparison = Boolean.valueOf(isSetId()).compareTo(typedOther.isSetId());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetId()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.id, typedOther.id);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetHead()).compareTo(typedOther.isSetHead());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetHead()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.head, typedOther.head);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetTail()).compareTo(typedOther.isSetTail());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetTail()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.tail, typedOther.tail);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetName()).compareTo(typedOther.isSetName());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetName()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.name, typedOther.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("GraphEdge(");
boolean first = true;
sb.append("id:");
sb.append(this.id);
first = false;
if (!first) sb.append(", ");
sb.append("head:");
if (this.head == null) {
sb.append("null");
} else {
sb.append(this.head);
}
first = false;
if (!first) sb.append(", ");
sb.append("tail:");
if (this.tail == null) {
sb.append("null");
} else {
sb.append(this.tail);
}
first = false;
if (isSetName()) {
if (!first) sb.append(", ");
sb.append("name:");
if (this.name == null) {
sb.append("null");
} else {
sb.append(this.name);
}
first = false;
}
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
if (!isSetId()) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'id' is unset! Struct:" + toString());
}
if (!isSetHead()) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'head' is unset! Struct:" + toString());
}
if (!isSetTail()) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'tail' is unset! Struct:" + toString());
}
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
// it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
__isset_bit_vector = new BitSet(1);
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private static class GraphEdgeStandardSchemeFactory implements SchemeFactory {
public GraphEdgeStandardScheme getScheme() {
return new GraphEdgeStandardScheme();
}
}
private static class GraphEdgeStandardScheme extends StandardScheme<GraphEdge> {
public void read(org.apache.thrift.protocol.TProtocol iprot, GraphEdge 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: // ID
if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
struct.id = iprot.readI32();
struct.setIdIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 2: // HEAD
if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
struct.head = new GraphVertex();
struct.head.read(iprot);
struct.setHeadIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 3: // TAIL
if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
struct.tail = new GraphVertex();
struct.tail.read(iprot);
struct.setTailIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 4: // NAME
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.name = iprot.readString();
struct.setNameIsSet(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();
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, GraphEdge struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
oprot.writeFieldBegin(ID_FIELD_DESC);
oprot.writeI32(struct.id);
oprot.writeFieldEnd();
if (struct.head != null) {
oprot.writeFieldBegin(HEAD_FIELD_DESC);
struct.head.write(oprot);
oprot.writeFieldEnd();
}
if (struct.tail != null) {
oprot.writeFieldBegin(TAIL_FIELD_DESC);
struct.tail.write(oprot);
oprot.writeFieldEnd();
}
if (struct.name != null) {
if (struct.isSetName()) {
oprot.writeFieldBegin(NAME_FIELD_DESC);
oprot.writeString(struct.name);
oprot.writeFieldEnd();
}
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class GraphEdgeTupleSchemeFactory implements SchemeFactory {
public GraphEdgeTupleScheme getScheme() {
return new GraphEdgeTupleScheme();
}
}
private static class GraphEdgeTupleScheme extends TupleScheme<GraphEdge> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, GraphEdge struct) throws org.apache.thrift.TException {
TTupleProtocol oprot = (TTupleProtocol) prot;
oprot.writeI32(struct.id);
struct.head.write(oprot);
struct.tail.write(oprot);
BitSet optionals = new BitSet();
if (struct.isSetName()) {
optionals.set(0);
}
oprot.writeBitSet(optionals, 1);
if (struct.isSetName()) {
oprot.writeString(struct.name);
}
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, GraphEdge struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
struct.id = iprot.readI32();
struct.setIdIsSet(true);
struct.head = new GraphVertex();
struct.head.read(iprot);
struct.setHeadIsSet(true);
struct.tail = new GraphVertex();
struct.tail.read(iprot);
struct.setTailIsSet(true);
BitSet incoming = iprot.readBitSet(1);
if (incoming.get(0)) {
struct.name = iprot.readString();
struct.setNameIsSet(true);
}
}
}
}