/** * Autogenerated by Thrift * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING */ package org.apache.hadoop.thriftfs.api; import java.util.List; import java.util.ArrayList; import java.util.Map; import java.util.HashMap; import java.util.Set; import java.util.HashSet; import java.util.Collections; import org.apache.log4j.Logger; import org.apache.thrift.*; import org.apache.thrift.meta_data.*; import org.apache.thrift.protocol.*; public class BlockLocation implements TBase, java.io.Serializable, Cloneable { private static final TStruct STRUCT_DESC = new TStruct("BlockLocation"); private static final TField HOSTS_FIELD_DESC = new TField("hosts", TType.LIST, (short)1); private static final TField NAMES_FIELD_DESC = new TField("names", TType.LIST, (short)2); private static final TField OFFSET_FIELD_DESC = new TField("offset", TType.I64, (short)3); private static final TField LENGTH_FIELD_DESC = new TField("length", TType.I64, (short)4); public List<String> hosts; public static final int HOSTS = 1; public List<String> names; public static final int NAMES = 2; public long offset; public static final int OFFSET = 3; public long length; public static final int LENGTH = 4; private final Isset __isset = new Isset(); private static final class Isset implements java.io.Serializable { public boolean offset = false; public boolean length = false; } public static final Map<Integer, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new HashMap<Integer, FieldMetaData>() {{ put(HOSTS, new FieldMetaData("hosts", TFieldRequirementType.DEFAULT, new ListMetaData(TType.LIST, new FieldValueMetaData(TType.STRING)))); put(NAMES, new FieldMetaData("names", TFieldRequirementType.DEFAULT, new ListMetaData(TType.LIST, new FieldValueMetaData(TType.STRING)))); put(OFFSET, new FieldMetaData("offset", TFieldRequirementType.DEFAULT, new FieldValueMetaData(TType.I64))); put(LENGTH, new FieldMetaData("length", TFieldRequirementType.DEFAULT, new FieldValueMetaData(TType.I64))); }}); static { FieldMetaData.addStructMetaDataMap(BlockLocation.class, metaDataMap); } public BlockLocation() { } public BlockLocation( List<String> hosts, List<String> names, long offset, long length) { this(); this.hosts = hosts; this.names = names; this.offset = offset; this.__isset.offset = true; this.length = length; this.__isset.length = true; } /** * Performs a deep copy on <i>other</i>. */ public BlockLocation(BlockLocation other) { if (other.isSetHosts()) { List<String> __this__hosts = new ArrayList<String>(); for (String other_element : other.hosts) { __this__hosts.add(other_element); } this.hosts = __this__hosts; } if (other.isSetNames()) { List<String> __this__names = new ArrayList<String>(); for (String other_element : other.names) { __this__names.add(other_element); } this.names = __this__names; } __isset.offset = other.__isset.offset; this.offset = other.offset; __isset.length = other.__isset.length; this.length = other.length; } @Override public BlockLocation clone() { return new BlockLocation(this); } public int getHostsSize() { return (this.hosts == null) ? 0 : this.hosts.size(); } public java.util.Iterator<String> getHostsIterator() { return (this.hosts == null) ? null : this.hosts.iterator(); } public void addToHosts(String elem) { if (this.hosts == null) { this.hosts = new ArrayList<String>(); } this.hosts.add(elem); } public List<String> getHosts() { return this.hosts; } public void setHosts(List<String> hosts) { this.hosts = hosts; } public void unsetHosts() { this.hosts = null; } // Returns true if field hosts is set (has been asigned a value) and false otherwise public boolean isSetHosts() { return this.hosts != null; } public void setHostsIsSet(boolean value) { if (!value) { this.hosts = null; } } public int getNamesSize() { return (this.names == null) ? 0 : this.names.size(); } public java.util.Iterator<String> getNamesIterator() { return (this.names == null) ? null : this.names.iterator(); } public void addToNames(String elem) { if (this.names == null) { this.names = new ArrayList<String>(); } this.names.add(elem); } public List<String> getNames() { return this.names; } public void setNames(List<String> names) { this.names = names; } public void unsetNames() { this.names = null; } // Returns true if field names is set (has been asigned a value) and false otherwise public boolean isSetNames() { return this.names != null; } public void setNamesIsSet(boolean value) { if (!value) { this.names = null; } } public long getOffset() { return this.offset; } public void setOffset(long offset) { this.offset = offset; this.__isset.offset = true; } public void unsetOffset() { this.__isset.offset = false; } // Returns true if field offset is set (has been asigned a value) and false otherwise public boolean isSetOffset() { return this.__isset.offset; } public void setOffsetIsSet(boolean value) { this.__isset.offset = value; } public long getLength() { return this.length; } public void setLength(long length) { this.length = length; this.__isset.length = true; } public void unsetLength() { this.__isset.length = false; } // Returns true if field length is set (has been asigned a value) and false otherwise public boolean isSetLength() { return this.__isset.length; } public void setLengthIsSet(boolean value) { this.__isset.length = value; } public void setFieldValue(int fieldID, Object value) { switch (fieldID) { case HOSTS: if (value == null) { unsetHosts(); } else { setHosts((List<String>)value); } break; case NAMES: if (value == null) { unsetNames(); } else { setNames((List<String>)value); } break; case OFFSET: if (value == null) { unsetOffset(); } else { setOffset((Long)value); } break; case LENGTH: if (value == null) { unsetLength(); } else { setLength((Long)value); } break; default: throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!"); } } public Object getFieldValue(int fieldID) { switch (fieldID) { case HOSTS: return getHosts(); case NAMES: return getNames(); case OFFSET: return new Long(getOffset()); case LENGTH: return new Long(getLength()); default: throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!"); } } // Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise public boolean isSet(int fieldID) { switch (fieldID) { case HOSTS: return isSetHosts(); case NAMES: return isSetNames(); case OFFSET: return isSetOffset(); case LENGTH: return isSetLength(); default: throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!"); } } @Override public boolean equals(Object that) { if (that == null) return false; if (that instanceof BlockLocation) return this.equals((BlockLocation)that); return false; } public boolean equals(BlockLocation that) { if (that == null) return false; boolean this_present_hosts = true && this.isSetHosts(); boolean that_present_hosts = true && that.isSetHosts(); if (this_present_hosts || that_present_hosts) { if (!(this_present_hosts && that_present_hosts)) return false; if (!this.hosts.equals(that.hosts)) return false; } boolean this_present_names = true && this.isSetNames(); boolean that_present_names = true && that.isSetNames(); if (this_present_names || that_present_names) { if (!(this_present_names && that_present_names)) return false; if (!this.names.equals(that.names)) return false; } boolean this_present_offset = true; boolean that_present_offset = true; if (this_present_offset || that_present_offset) { if (!(this_present_offset && that_present_offset)) return false; if (this.offset != that.offset) return false; } boolean this_present_length = true; boolean that_present_length = true; if (this_present_length || that_present_length) { if (!(this_present_length && that_present_length)) return false; if (this.length != that.length) return false; } return true; } @Override public int hashCode() { return 0; } 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 HOSTS: if (field.type == TType.LIST) { { TList _list0 = iprot.readListBegin(); this.hosts = new ArrayList<String>(_list0.size); for (int _i1 = 0; _i1 < _list0.size; ++_i1) { String _elem2; _elem2 = iprot.readString(); this.hosts.add(_elem2); } iprot.readListEnd(); } } else { TProtocolUtil.skip(iprot, field.type); } break; case NAMES: if (field.type == TType.LIST) { { TList _list3 = iprot.readListBegin(); this.names = new ArrayList<String>(_list3.size); for (int _i4 = 0; _i4 < _list3.size; ++_i4) { String _elem5; _elem5 = iprot.readString(); this.names.add(_elem5); } iprot.readListEnd(); } } else { TProtocolUtil.skip(iprot, field.type); } break; case OFFSET: if (field.type == TType.I64) { this.offset = iprot.readI64(); this.__isset.offset = true; } else { TProtocolUtil.skip(iprot, field.type); } break; case LENGTH: if (field.type == TType.I64) { this.length = iprot.readI64(); this.__isset.length = true; } else { TProtocolUtil.skip(iprot, field.type); } break; default: TProtocolUtil.skip(iprot, field.type); break; } 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.hosts != null) { oprot.writeFieldBegin(HOSTS_FIELD_DESC); { oprot.writeListBegin(new TList(TType.STRING, this.hosts.size())); for (String _iter6 : this.hosts) { oprot.writeString(_iter6); } oprot.writeListEnd(); } oprot.writeFieldEnd(); } if (this.names != null) { oprot.writeFieldBegin(NAMES_FIELD_DESC); { oprot.writeListBegin(new TList(TType.STRING, this.names.size())); for (String _iter7 : this.names) { oprot.writeString(_iter7); } oprot.writeListEnd(); } oprot.writeFieldEnd(); } oprot.writeFieldBegin(OFFSET_FIELD_DESC); oprot.writeI64(this.offset); oprot.writeFieldEnd(); oprot.writeFieldBegin(LENGTH_FIELD_DESC); oprot.writeI64(this.length); oprot.writeFieldEnd(); oprot.writeFieldStop(); oprot.writeStructEnd(); } @Override public String toString() { StringBuilder sb = new StringBuilder("BlockLocation("); boolean first = true; sb.append("hosts:"); if (this.hosts == null) { sb.append("null"); } else { sb.append(this.hosts); } first = false; if (!first) sb.append(", "); sb.append("names:"); if (this.names == null) { sb.append("null"); } else { sb.append(this.names); } first = false; if (!first) sb.append(", "); sb.append("offset:"); sb.append(this.offset); first = false; if (!first) sb.append(", "); sb.append("length:"); sb.append(this.length); first = false; sb.append(")"); return sb.toString(); } public void validate() throws TException { // check for required fields // check that fields of type enum have valid values } }