blob: a3974312aeae4a6eaae0e5dbf7914cd083f5dc03 [file] [log] [blame]
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hadoop.hbase.thrift.generated;
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.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.thrift.*;
import org.apache.thrift.meta_data.*;
import org.apache.thrift.protocol.*;
/**
* A TRegionInfo contains information about an HTable region.
*/
public class TRegionInfo implements TBase<TRegionInfo._Fields>, java.io.Serializable, Cloneable, Comparable<TRegionInfo> {
private static final TStruct STRUCT_DESC = new TStruct("TRegionInfo");
private static final TField START_KEY_FIELD_DESC = new TField("startKey", TType.STRING, (short)1);
private static final TField END_KEY_FIELD_DESC = new TField("endKey", TType.STRING, (short)2);
private static final TField ID_FIELD_DESC = new TField("id", TType.I64, (short)3);
private static final TField NAME_FIELD_DESC = new TField("name", TType.STRING, (short)4);
private static final TField VERSION_FIELD_DESC = new TField("version", TType.BYTE, (short)5);
public byte[] startKey;
public byte[] endKey;
public long id;
public byte[] name;
public byte version;
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements TFieldIdEnum {
START_KEY((short)1, "startKey"),
END_KEY((short)2, "endKey"),
ID((short)3, "id"),
NAME((short)4, "name"),
VERSION((short)5, "version");
private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byId.put((int)field._thriftId, field);
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
return byId.get(fieldId);
}
/**
* 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 static final int __VERSION_ISSET_ID = 1;
private BitSet __isset_bit_vector = new BitSet(2);
public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
put(_Fields.START_KEY, new FieldMetaData("startKey", TFieldRequirementType.DEFAULT,
new FieldValueMetaData(TType.STRING)));
put(_Fields.END_KEY, new FieldMetaData("endKey", TFieldRequirementType.DEFAULT,
new FieldValueMetaData(TType.STRING)));
put(_Fields.ID, new FieldMetaData("id", TFieldRequirementType.DEFAULT,
new FieldValueMetaData(TType.I64)));
put(_Fields.NAME, new FieldMetaData("name", TFieldRequirementType.DEFAULT,
new FieldValueMetaData(TType.STRING)));
put(_Fields.VERSION, new FieldMetaData("version", TFieldRequirementType.DEFAULT,
new FieldValueMetaData(TType.BYTE)));
}});
static {
FieldMetaData.addStructMetaDataMap(TRegionInfo.class, metaDataMap);
}
public TRegionInfo() {
}
public TRegionInfo(
byte[] startKey,
byte[] endKey,
long id,
byte[] name,
byte version)
{
this();
this.startKey = startKey;
this.endKey = endKey;
this.id = id;
setIdIsSet(true);
this.name = name;
this.version = version;
setVersionIsSet(true);
}
/**
* Performs a deep copy on <i>other</i>.
*/
public TRegionInfo(TRegionInfo other) {
__isset_bit_vector.clear();
__isset_bit_vector.or(other.__isset_bit_vector);
if (other.isSetStartKey()) {
this.startKey = other.startKey;
}
if (other.isSetEndKey()) {
this.endKey = other.endKey;
}
this.id = other.id;
if (other.isSetName()) {
this.name = other.name;
}
this.version = other.version;
}
public TRegionInfo deepCopy() {
return new TRegionInfo(this);
}
@Deprecated
public TRegionInfo clone() {
return new TRegionInfo(this);
}
public byte[] getStartKey() {
return this.startKey;
}
public TRegionInfo setStartKey(byte[] startKey) {
this.startKey = startKey;
return this;
}
public void unsetStartKey() {
this.startKey = null;
}
/** Returns true if field startKey is set (has been asigned a value) and false otherwise */
public boolean isSetStartKey() {
return this.startKey != null;
}
public void setStartKeyIsSet(boolean value) {
if (!value) {
this.startKey = null;
}
}
public byte[] getEndKey() {
return this.endKey;
}
public TRegionInfo setEndKey(byte[] endKey) {
this.endKey = endKey;
return this;
}
public void unsetEndKey() {
this.endKey = null;
}
/** Returns true if field endKey is set (has been asigned a value) and false otherwise */
public boolean isSetEndKey() {
return this.endKey != null;
}
public void setEndKeyIsSet(boolean value) {
if (!value) {
this.endKey = null;
}
}
public long getId() {
return this.id;
}
public TRegionInfo setId(long id) {
this.id = id;
setIdIsSet(true);
return this;
}
public void unsetId() {
__isset_bit_vector.clear(__ID_ISSET_ID);
}
/** Returns true if field id is set (has been asigned 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 byte[] getName() {
return this.name;
}
public TRegionInfo setName(byte[] name) {
this.name = name;
return this;
}
public void unsetName() {
this.name = null;
}
/** Returns true if field name is set (has been asigned a value) and false otherwise */
public boolean isSetName() {
return this.name != null;
}
public void setNameIsSet(boolean value) {
if (!value) {
this.name = null;
}
}
public byte getVersion() {
return this.version;
}
public TRegionInfo setVersion(byte version) {
this.version = version;
setVersionIsSet(true);
return this;
}
public void unsetVersion() {
__isset_bit_vector.clear(__VERSION_ISSET_ID);
}
/** Returns true if field version is set (has been asigned a value) and false otherwise */
public boolean isSetVersion() {
return __isset_bit_vector.get(__VERSION_ISSET_ID);
}
public void setVersionIsSet(boolean value) {
__isset_bit_vector.set(__VERSION_ISSET_ID, value);
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case START_KEY:
if (value == null) {
unsetStartKey();
} else {
setStartKey((byte[])value);
}
break;
case END_KEY:
if (value == null) {
unsetEndKey();
} else {
setEndKey((byte[])value);
}
break;
case ID:
if (value == null) {
unsetId();
} else {
setId((Long)value);
}
break;
case NAME:
if (value == null) {
unsetName();
} else {
setName((byte[])value);
}
break;
case VERSION:
if (value == null) {
unsetVersion();
} else {
setVersion((Byte)value);
}
break;
}
}
public void setFieldValue(int fieldID, Object value) {
setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
}
public Object getFieldValue(_Fields field) {
switch (field) {
case START_KEY:
return getStartKey();
case END_KEY:
return getEndKey();
case ID:
return new Long(getId());
case NAME:
return getName();
case VERSION:
return new Byte(getVersion());
}
throw new IllegalStateException();
}
public Object getFieldValue(int fieldId) {
return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
}
/** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
public boolean isSet(_Fields field) {
switch (field) {
case START_KEY:
return isSetStartKey();
case END_KEY:
return isSetEndKey();
case ID:
return isSetId();
case NAME:
return isSetName();
case VERSION:
return isSetVersion();
}
throw new IllegalStateException();
}
public boolean isSet(int fieldID) {
return isSet(_Fields.findByThriftIdOrThrow(fieldID));
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof TRegionInfo)
return this.equals((TRegionInfo)that);
return false;
}
public boolean equals(TRegionInfo that) {
if (that == null)
return false;
boolean this_present_startKey = true && this.isSetStartKey();
boolean that_present_startKey = true && that.isSetStartKey();
if (this_present_startKey || that_present_startKey) {
if (!(this_present_startKey && that_present_startKey))
return false;
if (!java.util.Arrays.equals(this.startKey, that.startKey))
return false;
}
boolean this_present_endKey = true && this.isSetEndKey();
boolean that_present_endKey = true && that.isSetEndKey();
if (this_present_endKey || that_present_endKey) {
if (!(this_present_endKey && that_present_endKey))
return false;
if (!java.util.Arrays.equals(this.endKey, that.endKey))
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_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 (!java.util.Arrays.equals(this.name, that.name))
return false;
}
boolean this_present_version = true;
boolean that_present_version = true;
if (this_present_version || that_present_version) {
if (!(this_present_version && that_present_version))
return false;
if (this.version != that.version)
return false;
}
return true;
}
@Override
public int hashCode() {
HashCodeBuilder builder = new HashCodeBuilder();
boolean present_startKey = true && (isSetStartKey());
builder.append(present_startKey);
if (present_startKey)
builder.append(startKey);
boolean present_endKey = true && (isSetEndKey());
builder.append(present_endKey);
if (present_endKey)
builder.append(endKey);
boolean present_id = true;
builder.append(present_id);
if (present_id)
builder.append(id);
boolean present_name = true && (isSetName());
builder.append(present_name);
if (present_name)
builder.append(name);
boolean present_version = true;
builder.append(present_version);
if (present_version)
builder.append(version);
return builder.toHashCode();
}
public int compareTo(TRegionInfo other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
TRegionInfo typedOther = (TRegionInfo)other;
lastComparison = Boolean.valueOf(isSetStartKey()).compareTo(isSetStartKey());
if (lastComparison != 0) {
return lastComparison;
}
lastComparison = TBaseHelper.compareTo(startKey, typedOther.startKey);
if (lastComparison != 0) {
return lastComparison;
}
lastComparison = Boolean.valueOf(isSetEndKey()).compareTo(isSetEndKey());
if (lastComparison != 0) {
return lastComparison;
}
lastComparison = TBaseHelper.compareTo(endKey, typedOther.endKey);
if (lastComparison != 0) {
return lastComparison;
}
lastComparison = Boolean.valueOf(isSetId()).compareTo(isSetId());
if (lastComparison != 0) {
return lastComparison;
}
lastComparison = TBaseHelper.compareTo(id, typedOther.id);
if (lastComparison != 0) {
return lastComparison;
}
lastComparison = Boolean.valueOf(isSetName()).compareTo(isSetName());
if (lastComparison != 0) {
return lastComparison;
}
lastComparison = TBaseHelper.compareTo(name, typedOther.name);
if (lastComparison != 0) {
return lastComparison;
}
lastComparison = Boolean.valueOf(isSetVersion()).compareTo(isSetVersion());
if (lastComparison != 0) {
return lastComparison;
}
lastComparison = TBaseHelper.compareTo(version, typedOther.version);
if (lastComparison != 0) {
return lastComparison;
}
return 0;
}
public void read(TProtocol iprot) throws TException {
TField field;
iprot.readStructBegin();
while (true)
{
field = iprot.readFieldBegin();
if (field.type == TType.STOP) {
break;
}
_Fields fieldId = _Fields.findByThriftId(field.id);
if (fieldId == null) {
TProtocolUtil.skip(iprot, field.type);
} else {
switch (fieldId) {
case START_KEY:
if (field.type == TType.STRING) {
this.startKey = iprot.readBinary();
} else {
TProtocolUtil.skip(iprot, field.type);
}
break;
case END_KEY:
if (field.type == TType.STRING) {
this.endKey = iprot.readBinary();
} else {
TProtocolUtil.skip(iprot, field.type);
}
break;
case ID:
if (field.type == TType.I64) {
this.id = iprot.readI64();
setIdIsSet(true);
} else {
TProtocolUtil.skip(iprot, field.type);
}
break;
case NAME:
if (field.type == TType.STRING) {
this.name = iprot.readBinary();
} else {
TProtocolUtil.skip(iprot, field.type);
}
break;
case VERSION:
if (field.type == TType.BYTE) {
this.version = iprot.readByte();
setVersionIsSet(true);
} else {
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.startKey != null) {
oprot.writeFieldBegin(START_KEY_FIELD_DESC);
oprot.writeBinary(this.startKey);
oprot.writeFieldEnd();
}
if (this.endKey != null) {
oprot.writeFieldBegin(END_KEY_FIELD_DESC);
oprot.writeBinary(this.endKey);
oprot.writeFieldEnd();
}
oprot.writeFieldBegin(ID_FIELD_DESC);
oprot.writeI64(this.id);
oprot.writeFieldEnd();
if (this.name != null) {
oprot.writeFieldBegin(NAME_FIELD_DESC);
oprot.writeBinary(this.name);
oprot.writeFieldEnd();
}
oprot.writeFieldBegin(VERSION_FIELD_DESC);
oprot.writeByte(this.version);
oprot.writeFieldEnd();
oprot.writeFieldStop();
oprot.writeStructEnd();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("TRegionInfo(");
boolean first = true;
sb.append("startKey:");
if (this.startKey == null) {
sb.append("null");
} else {
sb.append(this.startKey);
}
first = false;
if (!first) sb.append(", ");
sb.append("endKey:");
if (this.endKey == null) {
sb.append("null");
} else {
sb.append(this.endKey);
}
first = false;
if (!first) sb.append(", ");
sb.append("id:");
sb.append(this.id);
first = false;
if (!first) sb.append(", ");
sb.append("name:");
if (this.name == null) {
sb.append("null");
} else {
sb.append(this.name);
}
first = false;
if (!first) sb.append(", ");
sb.append("version:");
sb.append(this.version);
first = false;
sb.append(")");
return sb.toString();
}
public void validate() throws TException {
// check for required fields
}
}