/**
* Autogenerated by Thrift Compiler (0.9.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package org.apache.blur.thrift.generated;
/**
* 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.
*/
import org.apache.blur.thirdparty.thrift_0_9_0.scheme.IScheme;
import org.apache.blur.thirdparty.thrift_0_9_0.scheme.SchemeFactory;
import org.apache.blur.thirdparty.thrift_0_9_0.scheme.StandardScheme;
import org.apache.blur.thirdparty.thrift_0_9_0.scheme.TupleScheme;
import org.apache.blur.thirdparty.thrift_0_9_0.protocol.TTupleProtocol;
import org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocolException;
import org.apache.blur.thirdparty.thrift_0_9_0.EncodingUtils;
import org.apache.blur.thirdparty.thrift_0_9_0.TException;
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 Response extends org.apache.blur.thirdparty.thrift_0_9_0.TUnion<Response, Response._Fields> {
private static final org.apache.blur.thirdparty.thrift_0_9_0.protocol.TStruct STRUCT_DESC = new org.apache.blur.thirdparty.thrift_0_9_0.protocol.TStruct("Response");
private static final org.apache.blur.thirdparty.thrift_0_9_0.protocol.TField SHARD_TO_VALUE_FIELD_DESC = new org.apache.blur.thirdparty.thrift_0_9_0.protocol.TField("shardToValue", org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.MAP, (short)1);
private static final org.apache.blur.thirdparty.thrift_0_9_0.protocol.TField SERVER_TO_VALUE_FIELD_DESC = new org.apache.blur.thirdparty.thrift_0_9_0.protocol.TField("serverToValue", org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.MAP, (short)2);
private static final org.apache.blur.thirdparty.thrift_0_9_0.protocol.TField VALUE_FIELD_DESC = new org.apache.blur.thirdparty.thrift_0_9_0.protocol.TField("value", org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.STRUCT, (short)3);
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.blur.thirdparty.thrift_0_9_0.TFieldIdEnum {
SHARD_TO_VALUE((short)1, "shardToValue"),
SERVER_TO_VALUE((short)2, "serverToValue"),
VALUE((short)3, "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: // SHARD_TO_VALUE
return SHARD_TO_VALUE;
case 2: // SERVER_TO_VALUE
return SERVER_TO_VALUE;
case 3: // 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;
}
}
public static final Map<_Fields, org.apache.blur.thirdparty.thrift_0_9_0.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.blur.thirdparty.thrift_0_9_0.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.blur.thirdparty.thrift_0_9_0.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.SHARD_TO_VALUE, new org.apache.blur.thirdparty.thrift_0_9_0.meta_data.FieldMetaData("shardToValue", org.apache.blur.thirdparty.thrift_0_9_0.TFieldRequirementType.DEFAULT,
new org.apache.blur.thirdparty.thrift_0_9_0.meta_data.MapMetaData(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.MAP,
new org.apache.blur.thirdparty.thrift_0_9_0.meta_data.StructMetaData(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.STRUCT, Shard.class),
new org.apache.blur.thirdparty.thrift_0_9_0.meta_data.StructMetaData(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.STRUCT, ValueObject.class))));
tmpMap.put(_Fields.SERVER_TO_VALUE, new org.apache.blur.thirdparty.thrift_0_9_0.meta_data.FieldMetaData("serverToValue", org.apache.blur.thirdparty.thrift_0_9_0.TFieldRequirementType.DEFAULT,
new org.apache.blur.thirdparty.thrift_0_9_0.meta_data.MapMetaData(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.MAP,
new org.apache.blur.thirdparty.thrift_0_9_0.meta_data.StructMetaData(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.STRUCT, Server.class),
new org.apache.blur.thirdparty.thrift_0_9_0.meta_data.StructMetaData(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.STRUCT, ValueObject.class))));
tmpMap.put(_Fields.VALUE, new org.apache.blur.thirdparty.thrift_0_9_0.meta_data.FieldMetaData("value", org.apache.blur.thirdparty.thrift_0_9_0.TFieldRequirementType.DEFAULT,
new org.apache.blur.thirdparty.thrift_0_9_0.meta_data.StructMetaData(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.STRUCT, ValueObject.class)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.blur.thirdparty.thrift_0_9_0.meta_data.FieldMetaData.addStructMetaDataMap(Response.class, metaDataMap);
}
public Response() {
super();
}
public Response(_Fields setField, Object value) {
super(setField, value);
}
public Response(Response other) {
super(other);
}
public Response deepCopy() {
return new Response(this);
}
public static Response shardToValue(Map<Shard,ValueObject> value) {
Response x = new Response();
x.setShardToValue(value);
return x;
}
public static Response serverToValue(Map<Server,ValueObject> value) {
Response x = new Response();
x.setServerToValue(value);
return x;
}
public static Response value(ValueObject value) {
Response x = new Response();
x.setValue(value);
return x;
}
@Override
protected void checkType(_Fields setField, Object value) throws ClassCastException {
switch (setField) {
case SHARD_TO_VALUE:
if (value instanceof Map) {
break;
}
throw new ClassCastException("Was expecting value of type Map<Shard,ValueObject> for field 'shardToValue', but got " + value.getClass().getSimpleName());
case SERVER_TO_VALUE:
if (value instanceof Map) {
break;
}
throw new ClassCastException("Was expecting value of type Map<Server,ValueObject> for field 'serverToValue', but got " + value.getClass().getSimpleName());
case VALUE:
if (value instanceof ValueObject) {
break;
}
throw new ClassCastException("Was expecting value of type ValueObject for field 'value', but got " + value.getClass().getSimpleName());
default:
throw new IllegalArgumentException("Unknown field id " + setField);
}
}
@Override
protected Object standardSchemeReadValue(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocol iprot, org.apache.blur.thirdparty.thrift_0_9_0.protocol.TField field) throws org.apache.blur.thirdparty.thrift_0_9_0.TException {
_Fields setField = _Fields.findByThriftId(field.id);
if (setField != null) {
switch (setField) {
case SHARD_TO_VALUE:
if (field.type == SHARD_TO_VALUE_FIELD_DESC.type) {
Map<Shard,ValueObject> shardToValue;
{
org.apache.blur.thirdparty.thrift_0_9_0.protocol.TMap _map240 = iprot.readMapBegin();
shardToValue = new HashMap<Shard,ValueObject>(2*_map240.size);
for (int _i241 = 0; _i241 < _map240.size; ++_i241)
{
Shard _key242; // required
ValueObject _val243; // required
_key242 = new Shard();
_key242.read(iprot);
_val243 = new ValueObject();
_val243.read(iprot);
shardToValue.put(_key242, _val243);
}
iprot.readMapEnd();
}
return shardToValue;
} else {
org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocolUtil.skip(iprot, field.type);
return null;
}
case SERVER_TO_VALUE:
if (field.type == SERVER_TO_VALUE_FIELD_DESC.type) {
Map<Server,ValueObject> serverToValue;
{
org.apache.blur.thirdparty.thrift_0_9_0.protocol.TMap _map244 = iprot.readMapBegin();
serverToValue = new HashMap<Server,ValueObject>(2*_map244.size);
for (int _i245 = 0; _i245 < _map244.size; ++_i245)
{
Server _key246; // required
ValueObject _val247; // required
_key246 = new Server();
_key246.read(iprot);
_val247 = new ValueObject();
_val247.read(iprot);
serverToValue.put(_key246, _val247);
}
iprot.readMapEnd();
}
return serverToValue;
} else {
org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocolUtil.skip(iprot, field.type);
return null;
}
case VALUE:
if (field.type == VALUE_FIELD_DESC.type) {
ValueObject value;
value = new ValueObject();
value.read(iprot);
return value;
} else {
org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocolUtil.skip(iprot, field.type);
return null;
}
default:
throw new IllegalStateException("setField wasn't null, but didn't match any of the case statements!");
}
} else {
return null;
}
}
@Override
protected void standardSchemeWriteValue(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocol oprot) throws org.apache.blur.thirdparty.thrift_0_9_0.TException {
switch (setField_) {
case SHARD_TO_VALUE:
Map<Shard,ValueObject> shardToValue = (Map<Shard,ValueObject>)value_;
{
oprot.writeMapBegin(new org.apache.blur.thirdparty.thrift_0_9_0.protocol.TMap(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.STRUCT, org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.STRUCT, shardToValue.size()));
for (Map.Entry<Shard, ValueObject> _iter248 : shardToValue.entrySet())
{
_iter248.getKey().write(oprot);
_iter248.getValue().write(oprot);
}
oprot.writeMapEnd();
}
return;
case SERVER_TO_VALUE:
Map<Server,ValueObject> serverToValue = (Map<Server,ValueObject>)value_;
{
oprot.writeMapBegin(new org.apache.blur.thirdparty.thrift_0_9_0.protocol.TMap(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.STRUCT, org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.STRUCT, serverToValue.size()));
for (Map.Entry<Server, ValueObject> _iter249 : serverToValue.entrySet())
{
_iter249.getKey().write(oprot);
_iter249.getValue().write(oprot);
}
oprot.writeMapEnd();
}
return;
case VALUE:
ValueObject value = (ValueObject)value_;
value.write(oprot);
return;
default:
throw new IllegalStateException("Cannot write union with unknown field " + setField_);
}
}
@Override
protected Object tupleSchemeReadValue(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocol iprot, short fieldID) throws org.apache.blur.thirdparty.thrift_0_9_0.TException {
_Fields setField = _Fields.findByThriftId(fieldID);
if (setField != null) {
switch (setField) {
case SHARD_TO_VALUE:
Map<Shard,ValueObject> shardToValue;
{
org.apache.blur.thirdparty.thrift_0_9_0.protocol.TMap _map250 = iprot.readMapBegin();
shardToValue = new HashMap<Shard,ValueObject>(2*_map250.size);
for (int _i251 = 0; _i251 < _map250.size; ++_i251)
{
Shard _key252; // required
ValueObject _val253; // required
_key252 = new Shard();
_key252.read(iprot);
_val253 = new ValueObject();
_val253.read(iprot);
shardToValue.put(_key252, _val253);
}
iprot.readMapEnd();
}
return shardToValue;
case SERVER_TO_VALUE:
Map<Server,ValueObject> serverToValue;
{
org.apache.blur.thirdparty.thrift_0_9_0.protocol.TMap _map254 = iprot.readMapBegin();
serverToValue = new HashMap<Server,ValueObject>(2*_map254.size);
for (int _i255 = 0; _i255 < _map254.size; ++_i255)
{
Server _key256; // required
ValueObject _val257; // required
_key256 = new Server();
_key256.read(iprot);
_val257 = new ValueObject();
_val257.read(iprot);
serverToValue.put(_key256, _val257);
}
iprot.readMapEnd();
}
return serverToValue;
case VALUE:
ValueObject value;
value = new ValueObject();
value.read(iprot);
return value;
default:
throw new IllegalStateException("setField wasn't null, but didn't match any of the case statements!");
}
} else {
throw new TProtocolException("Couldn't find a field with field id " + fieldID);
}
}
@Override
protected void tupleSchemeWriteValue(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocol oprot) throws org.apache.blur.thirdparty.thrift_0_9_0.TException {
switch (setField_) {
case SHARD_TO_VALUE:
Map<Shard,ValueObject> shardToValue = (Map<Shard,ValueObject>)value_;
{
oprot.writeMapBegin(new org.apache.blur.thirdparty.thrift_0_9_0.protocol.TMap(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.STRUCT, org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.STRUCT, shardToValue.size()));
for (Map.Entry<Shard, ValueObject> _iter258 : shardToValue.entrySet())
{
_iter258.getKey().write(oprot);
_iter258.getValue().write(oprot);
}
oprot.writeMapEnd();
}
return;
case SERVER_TO_VALUE:
Map<Server,ValueObject> serverToValue = (Map<Server,ValueObject>)value_;
{
oprot.writeMapBegin(new org.apache.blur.thirdparty.thrift_0_9_0.protocol.TMap(org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.STRUCT, org.apache.blur.thirdparty.thrift_0_9_0.protocol.TType.STRUCT, serverToValue.size()));
for (Map.Entry<Server, ValueObject> _iter259 : serverToValue.entrySet())
{
_iter259.getKey().write(oprot);
_iter259.getValue().write(oprot);
}
oprot.writeMapEnd();
}
return;
case VALUE:
ValueObject value = (ValueObject)value_;
value.write(oprot);
return;
default:
throw new IllegalStateException("Cannot write union with unknown field " + setField_);
}
}
@Override
protected org.apache.blur.thirdparty.thrift_0_9_0.protocol.TField getFieldDesc(_Fields setField) {
switch (setField) {
case SHARD_TO_VALUE:
return SHARD_TO_VALUE_FIELD_DESC;
case SERVER_TO_VALUE:
return SERVER_TO_VALUE_FIELD_DESC;
case VALUE:
return VALUE_FIELD_DESC;
default:
throw new IllegalArgumentException("Unknown field id " + setField);
}
}
@Override
protected org.apache.blur.thirdparty.thrift_0_9_0.protocol.TStruct getStructDesc() {
return STRUCT_DESC;
}
@Override
protected _Fields enumForId(short id) {
return _Fields.findByThriftIdOrThrow(id);
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public Map<Shard,ValueObject> getShardToValue() {
if (getSetField() == _Fields.SHARD_TO_VALUE) {
return (Map<Shard,ValueObject>)getFieldValue();
} else {
throw new RuntimeException("Cannot get field 'shardToValue' because union is currently set to " + getFieldDesc(getSetField()).name);
}
}
public void setShardToValue(Map<Shard,ValueObject> value) {
if (value == null) throw new NullPointerException();
setField_ = _Fields.SHARD_TO_VALUE;
value_ = value;
}
public Map<Server,ValueObject> getServerToValue() {
if (getSetField() == _Fields.SERVER_TO_VALUE) {
return (Map<Server,ValueObject>)getFieldValue();
} else {
throw new RuntimeException("Cannot get field 'serverToValue' because union is currently set to " + getFieldDesc(getSetField()).name);
}
}
public void setServerToValue(Map<Server,ValueObject> value) {
if (value == null) throw new NullPointerException();
setField_ = _Fields.SERVER_TO_VALUE;
value_ = value;
}
public ValueObject getValue() {
if (getSetField() == _Fields.VALUE) {
return (ValueObject)getFieldValue();
} else {
throw new RuntimeException("Cannot get field 'value' because union is currently set to " + getFieldDesc(getSetField()).name);
}
}
public void setValue(ValueObject value) {
if (value == null) throw new NullPointerException();
setField_ = _Fields.VALUE;
value_ = value;
}
public boolean isSetShardToValue() {
return setField_ == _Fields.SHARD_TO_VALUE;
}
public boolean isSetServerToValue() {
return setField_ == _Fields.SERVER_TO_VALUE;
}
public boolean isSetValue() {
return setField_ == _Fields.VALUE;
}
public boolean equals(Object other) {
if (other instanceof Response) {
return equals((Response)other);
} else {
return false;
}
}
public boolean equals(Response other) {
return other != null && getSetField() == other.getSetField() && getFieldValue().equals(other.getFieldValue());
}
@Override
public int compareTo(Response other) {
int lastComparison = org.apache.blur.thirdparty.thrift_0_9_0.TBaseHelper.compareTo(getSetField(), other.getSetField());
if (lastComparison == 0) {
return org.apache.blur.thirdparty.thrift_0_9_0.TBaseHelper.compareTo(getFieldValue(), other.getFieldValue());
}
return lastComparison;
}
/**
* If you'd like this to perform more respectably, use the hashcode generator option.
*/
@Override
public int hashCode() {
return 0;
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.blur.thirdparty.thrift_0_9_0.protocol.TCompactProtocol(new org.apache.blur.thirdparty.thrift_0_9_0.transport.TIOStreamTransport(out)));
} catch (org.apache.blur.thirdparty.thrift_0_9_0.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.blur.thirdparty.thrift_0_9_0.protocol.TCompactProtocol(new org.apache.blur.thirdparty.thrift_0_9_0.transport.TIOStreamTransport(in)));
} catch (org.apache.blur.thirdparty.thrift_0_9_0.TException te) {
throw new java.io.IOException(te);
}
}
}