All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.cinchapi.concourse.thrift.ComplexTObject Maven / Gradle / Ivy

Go to download

Concourse is a self-tuning database that is designed for both ad hoc analytics and high volume transactions at scale. Developers use Concourse to quickly build mission critical software while also benefiting from real time insight into their most important data. With Concourse, end-to-end data management requires no extra infrastructure, no prior configuration and no additional coding–all of which greatly reduce costs and allow developers to focus on core business problems.

There is a newer version: 0.11.2
Show newest version
/*
 * Copyright (c) 2013-2019 Cinchapi Inc.
 *
 * Licensed 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 com.cinchapi.concourse.thrift;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumMap;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import javax.annotation.Generated;

import org.apache.thrift.protocol.TTupleProtocol;
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 com.cinchapi.common.base.CheckedExceptions;
import com.cinchapi.concourse.util.ByteBuffers;
import com.cinchapi.concourse.util.Convert;
import com.google.common.base.MoreObjects;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;

@SuppressWarnings({ "cast", "rawtypes", "serial", "unchecked" })
/**
 * A recursive structure that encodes one or more {@link TObject TObjects}.
 * 
 * 

* The most basic {@link ComplexTObject} is a * {@link ComplexTObjectType#SCALAR scalar}, which is just a wrapped * {@link TObject}. Beyond that, complex collections can be represented as a * {@link Set}, {@link List} or {@link Map} of * {@link ComplexTObject ComplexTObjects}. *

*/ @Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2016-09-19") public class ComplexTObject implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { /** * Deserialize a {@link ComplexTObject} by reading its binary form from the * {@code buffer}. * * @param buffer a {@link ByteBuffer} with the serialized content of a * {@link ComplexTObject} * @return the ComplexTObject */ public static ComplexTObject fromByteBuffer(ByteBuffer buffer) { ComplexTObjectType type = ComplexTObjectType.values()[buffer.get()]; ComplexTObject obj = new ComplexTObject(); obj.type = type; if(type == ComplexTObjectType.MAP) { obj.tmap = Maps.newLinkedHashMap(); while (buffer.hasRemaining()) { int keyLength = buffer.getInt(); ComplexTObject key = ComplexTObject .fromByteBuffer(ByteBuffers.get(buffer, keyLength)); int valueLength = buffer.getInt(); ComplexTObject value = ComplexTObject .fromByteBuffer(ByteBuffers.get(buffer, valueLength)); obj.tmap.put(key, value); } } else if(type == ComplexTObjectType.LIST || type == ComplexTObjectType.SET) { Collection collection = type == ComplexTObjectType.LIST ? (obj.tlist = Lists.newArrayList()) : (obj.tset = Sets.newLinkedHashSet()); while (buffer.hasRemaining()) { int length = buffer.getInt(); ComplexTObject item = ComplexTObject .fromByteBuffer(ByteBuffers.get(buffer, length)); collection.add(item); } } else if(type == ComplexTObjectType.TCRITERIA) { List symbols = Lists.newArrayList(); while (buffer.hasRemaining()) { int length = buffer.getInt(); TSymbolType symbolType = TSymbolType.values()[buffer.get()]; String symbol = ByteBuffers .getString(ByteBuffers.get(buffer, length)); symbols.add(new TSymbol(symbolType, symbol)); } obj.tcriteria = new TCriteria(symbols); } else if(type == ComplexTObjectType.BINARY) { obj.tbinary = ByteBuffers.get(buffer, buffer.remaining()); } else { Type ttype = Type.values()[buffer.get()]; TObject ref = new TObject(ByteBuffers.getRemaining(buffer), ttype); if(type == ComplexTObjectType.SCALAR) { obj.tscalar = ref; } else { obj.tobject = ref; } } return obj; } /** * Create a new {@link ComplexTObject} from the specified java * {@code object}. * The original object can be retrieved using the {@link #getJavaObject()} * method. * * @param object the object to wrap within the {@link ComplexTObject}. * @return the ComplexTObject */ public static ComplexTObject fromJavaObject(T object) { ComplexTObject complex = new ComplexTObject(); if(object instanceof Map) { Map map = (Map) object; complex.setType(ComplexTObjectType.MAP); Map tmap = Maps.newLinkedHashMap(); for (Entry entry : map.entrySet()) { tmap.put(fromJavaObject(entry.getKey()), fromJavaObject(entry.getValue())); } complex.setTmap(tmap); } else if(object instanceof List) { List list = (List) object; complex.setType(ComplexTObjectType.LIST); List tlist = Lists.newArrayList(); for (Object elt : list) { tlist.add(fromJavaObject(elt)); } complex.setTlist(tlist); } else if(object instanceof Set) { Set set = (Set) object; complex.setType(ComplexTObjectType.SET); Set tset = Sets.newLinkedHashSet(); for (Object elt : set) { tset.add(fromJavaObject(elt)); } complex.setTset(tset); } else if(object instanceof TObject) { complex.setType(ComplexTObjectType.TOBJECT); complex.setTobject((TObject) object); } else if(object instanceof TCriteria) { complex.setType(ComplexTObjectType.TCRITERIA); complex.setTcriteria((TCriteria) object); } else if(object instanceof byte[] || object instanceof ByteBuffer) { complex.setType(ComplexTObjectType.BINARY); if(object instanceof ByteBuffer) { complex.setTbinary((ByteBuffer) object); } else { complex.setTbinary(ByteBuffer.wrap((byte[]) object)); } } else { complex.setType(ComplexTObjectType.SCALAR); complex.setTscalar(Convert.javaToThrift(object)); } return complex; } private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct( "ComplexTObject"); private static final org.apache.thrift.protocol.TField TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField( "type", org.apache.thrift.protocol.TType.I32, (short) 1); private static final org.apache.thrift.protocol.TField TSCALAR_FIELD_DESC = new org.apache.thrift.protocol.TField( "tscalar", org.apache.thrift.protocol.TType.STRUCT, (short) 2); private static final org.apache.thrift.protocol.TField TMAP_FIELD_DESC = new org.apache.thrift.protocol.TField( "tmap", org.apache.thrift.protocol.TType.MAP, (short) 3); private static final org.apache.thrift.protocol.TField TLIST_FIELD_DESC = new org.apache.thrift.protocol.TField( "tlist", org.apache.thrift.protocol.TType.LIST, (short) 4); private static final org.apache.thrift.protocol.TField TSET_FIELD_DESC = new org.apache.thrift.protocol.TField( "tset", org.apache.thrift.protocol.TType.SET, (short) 5); private static final org.apache.thrift.protocol.TField TOBJECT_FIELD_DESC = new org.apache.thrift.protocol.TField( "tobject", org.apache.thrift.protocol.TType.STRUCT, (short) 6); private static final org.apache.thrift.protocol.TField TCRITERIA_FIELD_DESC = new org.apache.thrift.protocol.TField( "tcriteria", org.apache.thrift.protocol.TType.STRUCT, (short) 7); private static final org.apache.thrift.protocol.TField TBINARY_FIELD_DESC = new org.apache.thrift.protocol.TField( "tbinary", org.apache.thrift.protocol.TType.STRING, (short) 8); private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); static { schemes.put(StandardScheme.class, new ComplexTObjectStandardSchemeFactory()); schemes.put(TupleScheme.class, new ComplexTObjectTupleSchemeFactory()); } /** * * @see ComplexTObjectType */ public ComplexTObjectType type; // required public com.cinchapi.concourse.thrift.TObject tscalar; // optional public Map tmap; // optional public List tlist; // optional public Set tset; // optional public com.cinchapi.concourse.thrift.TObject tobject; // optional public com.cinchapi.concourse.thrift.TCriteria tcriteria; // optional public ByteBuffer tbinary; // optional private transient Object cached; /** * The set of fields this struct contains, along with convenience methods * for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { /** * * @see ComplexTObjectType */ TYPE((short) 1, "type"), TSCALAR((short) 2, "tscalar"), TMAP((short) 3, "tmap"), TLIST((short) 4, "tlist"), TSET((short) 5, "tset"), TOBJECT((short) 6, "tobject"), TCRITERIA((short) 7, "tcriteria"), TBINARY((short) 8, "tbinary"); 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: // TYPE return TYPE; case 2: // TSCALAR return TSCALAR; case 3: // TMAP return TMAP; case 4: // TLIST return TLIST; case 5: // TSET return TSET; case 6: // TOBJECT return TOBJECT; case 7: // TCRITERIA return TCRITERIA; case 8: // TBINARY return TBINARY; 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 @SuppressWarnings("unused") private static final _Fields optionals[] = { _Fields.TSCALAR, _Fields.TMAP, _Fields.TLIST, _Fields.TSET, _Fields.TOBJECT, _Fields.TCRITERIA, _Fields.TBINARY }; 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.TYPE, new org.apache.thrift.meta_data.FieldMetaData("type", org.apache.thrift.TFieldRequirementType.REQUIRED, new org.apache.thrift.meta_data.EnumMetaData( org.apache.thrift.protocol.TType.ENUM, ComplexTObjectType.class))); tmpMap.put(_Fields.TSCALAR, new org.apache.thrift.meta_data.FieldMetaData("tscalar", org.apache.thrift.TFieldRequirementType.OPTIONAL, new org.apache.thrift.meta_data.StructMetaData( org.apache.thrift.protocol.TType.STRUCT, com.cinchapi.concourse.thrift.TObject.class))); tmpMap.put(_Fields.TMAP, new org.apache.thrift.meta_data.FieldMetaData("tmap", org.apache.thrift.TFieldRequirementType.OPTIONAL, new org.apache.thrift.meta_data.MapMetaData( org.apache.thrift.protocol.TType.MAP, new org.apache.thrift.meta_data.FieldValueMetaData( org.apache.thrift.protocol.TType.STRUCT, "ComplexTObject"), new org.apache.thrift.meta_data.FieldValueMetaData( org.apache.thrift.protocol.TType.STRUCT, "ComplexTObject")))); tmpMap.put(_Fields.TLIST, new org.apache.thrift.meta_data.FieldMetaData("tlist", org.apache.thrift.TFieldRequirementType.OPTIONAL, new org.apache.thrift.meta_data.ListMetaData( org.apache.thrift.protocol.TType.LIST, new org.apache.thrift.meta_data.FieldValueMetaData( org.apache.thrift.protocol.TType.STRUCT, "ComplexTObject")))); tmpMap.put(_Fields.TSET, new org.apache.thrift.meta_data.FieldMetaData("tset", org.apache.thrift.TFieldRequirementType.OPTIONAL, new org.apache.thrift.meta_data.SetMetaData( org.apache.thrift.protocol.TType.SET, new org.apache.thrift.meta_data.FieldValueMetaData( org.apache.thrift.protocol.TType.STRUCT, "ComplexTObject")))); tmpMap.put(_Fields.TOBJECT, new org.apache.thrift.meta_data.FieldMetaData("tobject", org.apache.thrift.TFieldRequirementType.OPTIONAL, new org.apache.thrift.meta_data.StructMetaData( org.apache.thrift.protocol.TType.STRUCT, com.cinchapi.concourse.thrift.TObject.class))); tmpMap.put(_Fields.TCRITERIA, new org.apache.thrift.meta_data.FieldMetaData("tcriteria", org.apache.thrift.TFieldRequirementType.OPTIONAL, new org.apache.thrift.meta_data.StructMetaData( org.apache.thrift.protocol.TType.STRUCT, com.cinchapi.concourse.thrift.TCriteria.class))); tmpMap.put(_Fields.TBINARY, new org.apache.thrift.meta_data.FieldMetaData("tbinary", org.apache.thrift.TFieldRequirementType.OPTIONAL, new org.apache.thrift.meta_data.FieldValueMetaData( org.apache.thrift.protocol.TType.STRING, true))); metaDataMap = Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData .addStructMetaDataMap(ComplexTObject.class, metaDataMap); } public ComplexTObject() {} public ComplexTObject(ComplexTObjectType type) { this(); this.type = type; } /** * Performs a deep copy on other. */ public ComplexTObject(ComplexTObject other) { if(other.isSetType()) { this.type = other.type; } if(other.isSetTscalar()) { this.tscalar = new com.cinchapi.concourse.thrift.TObject( other.tscalar); } if(other.isSetTmap()) { Map __this__tmap = new LinkedHashMap( other.tmap.size()); for (Map.Entry other_element : other.tmap .entrySet()) { ComplexTObject other_element_key = other_element.getKey(); ComplexTObject other_element_value = other_element.getValue(); ComplexTObject __this__tmap_copy_key = other_element_key; ComplexTObject __this__tmap_copy_value = other_element_value; __this__tmap.put(__this__tmap_copy_key, __this__tmap_copy_value); } this.tmap = __this__tmap; } if(other.isSetTlist()) { List __this__tlist = new ArrayList( other.tlist.size()); for (ComplexTObject other_element : other.tlist) { __this__tlist.add(other_element); } this.tlist = __this__tlist; } if(other.isSetTset()) { Set __this__tset = new HashSet( other.tset.size()); for (ComplexTObject other_element : other.tset) { __this__tset.add(other_element); } this.tset = __this__tset; } if(other.isSetTobject()) { this.tobject = new com.cinchapi.concourse.thrift.TObject( other.tobject); } if(other.isSetTcriteria()) { this.tcriteria = new com.cinchapi.concourse.thrift.TCriteria( other.tcriteria); } if(other.isSetTbinary()) { this.tbinary = org.apache.thrift.TBaseHelper .copyBinary(other.tbinary); } } /** * Return a {@link ByteBuffer} that contains a serialized representation of * this {@link ComplexTObject}. * * @return the serialized form in a {@link ByteBuffer} */ public ByteBuffer toByteBuffer() { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); // TODO: use // something // else // because // ByteArrayOutputStream // unnecessarily // uses // synchronization ByteBuffer size = ByteBuffer.allocate(4); bytes.write(type.ordinal()); if(type == ComplexTObjectType.MAP) { tmap.entrySet().forEach(entry -> { try { byte[] key = entry.getKey().toByteBuffer().array(); bytes.write( (byte[]) size.putInt(key.length).flip().array()); bytes.write(key); byte[] value = entry.getValue().toByteBuffer().array(); bytes.write( (byte[]) size.putInt(value.length).flip().array()); bytes.write(value); } catch (IOException e) { throw CheckedExceptions.wrapAsRuntimeException(e); } }); } else if(type == ComplexTObjectType.LIST || type == ComplexTObjectType.SET) { Collection collection = type == ComplexTObjectType.LIST ? tlist : tset; collection.forEach((item) -> { try { byte[] itemBytes = item.toByteBuffer().array(); bytes.write((byte[]) size.putInt(itemBytes.length).flip() .array()); bytes.write(itemBytes); } catch (IOException e) { throw CheckedExceptions.wrapAsRuntimeException(e); } }); } else if(type == ComplexTObjectType.TCRITERIA) { tcriteria.symbols.forEach((item) -> { try { byte[] symbolBytes = item.symbol .getBytes(StandardCharsets.UTF_8); int length = symbolBytes.length; bytes.write((byte[]) size.putInt(length).flip().array()); bytes.write(item.type.ordinal()); bytes.write(symbolBytes); } catch (IOException e) { throw CheckedExceptions.wrapAsRuntimeException(e); } }); } else if(type == ComplexTObjectType.BINARY) { try { bytes.write(tbinary.array()); } catch (IOException e) { throw CheckedExceptions.wrapAsRuntimeException(e); } } else { TObject obj = MoreObjects.firstNonNull(tobject, tscalar); try { bytes.write(obj.type.ordinal()); bytes.write(obj.getData()); } catch (IOException e) { throw CheckedExceptions.wrapAsRuntimeException(e); } } return ByteBuffer.wrap(bytes.toByteArray()); } /** * Return the canonical java object that is wrapped within this * {@link ComplexTObject}. * * @return the wrapped java object */ public T getJavaObject() { if(cached == null) { if(type == ComplexTObjectType.MAP) { Map tmap = getTmap(); Map map = Maps.newLinkedHashMap(); for (Entry entry : tmap .entrySet()) { map.put(entry.getKey().getJavaObject(), entry.getValue().getJavaObject()); } cached = map; } else if(type == ComplexTObjectType.LIST) { List tlist = getTlist(); List list = Lists .newArrayListWithCapacity(tlist.size()); for (ComplexTObject elt : tlist) { list.add(elt.getJavaObject()); } cached = list; } else if(type == ComplexTObjectType.SET) { Set tset = getTset(); Set set = Sets .newLinkedHashSetWithExpectedSize(tset.size()); for (ComplexTObject elt : tset) { set.add(elt.getJavaObject()); } cached = set; } else if(type == ComplexTObjectType.TOBJECT) { cached = getTobject(); } else if(type == ComplexTObjectType.TCRITERIA) { cached = getTcriteria(); } else if(type == ComplexTObjectType.BINARY) { return (T) bufferForTbinary(); } else { TObject tscalar = getTscalar(); cached = Convert.thriftToJava(tscalar); } } return (T) cached; } public ComplexTObject deepCopy() { return new ComplexTObject(this); } @Override public void clear() { this.type = null; this.tscalar = null; this.tmap = null; this.tlist = null; this.tset = null; this.tobject = null; this.tcriteria = null; this.tbinary = null; } /** * * @see ComplexTObjectType */ public ComplexTObjectType getType() { return this.type; } /** * * @see ComplexTObjectType */ public ComplexTObject setType(ComplexTObjectType type) { this.type = type; return this; } public void unsetType() { this.type = null; } /** * Returns true if field type is set (has been assigned a value) and false * otherwise */ public boolean isSetType() { return this.type != null; } public void setTypeIsSet(boolean value) { if(!value) { this.type = null; } } public com.cinchapi.concourse.thrift.TObject getTscalar() { return this.tscalar; } public ComplexTObject setTscalar( com.cinchapi.concourse.thrift.TObject tscalar) { this.tscalar = tscalar; return this; } public void unsetTscalar() { this.tscalar = null; } /** * Returns true if field tscalar is set (has been assigned a value) and * false otherwise */ public boolean isSetTscalar() { return this.tscalar != null; } public void setTscalarIsSet(boolean value) { if(!value) { this.tscalar = null; } } public int getTmapSize() { return (this.tmap == null) ? 0 : this.tmap.size(); } public void putToTmap(ComplexTObject key, ComplexTObject val) { if(this.tmap == null) { this.tmap = new LinkedHashMap(); } this.tmap.put(key, val); } public Map getTmap() { return this.tmap; } public ComplexTObject setTmap(Map tmap) { this.tmap = tmap; return this; } public void unsetTmap() { this.tmap = null; } /** * Returns true if field tmap is set (has been assigned a value) and false * otherwise */ public boolean isSetTmap() { return this.tmap != null; } public void setTmapIsSet(boolean value) { if(!value) { this.tmap = null; } } public int getTlistSize() { return (this.tlist == null) ? 0 : this.tlist.size(); } public java.util.Iterator getTlistIterator() { return (this.tlist == null) ? null : this.tlist.iterator(); } public void addToTlist(ComplexTObject elem) { if(this.tlist == null) { this.tlist = new ArrayList(); } this.tlist.add(elem); } public List getTlist() { return this.tlist; } public ComplexTObject setTlist(List tlist) { this.tlist = tlist; return this; } public void unsetTlist() { this.tlist = null; } /** * Returns true if field tlist is set (has been assigned a value) and false * otherwise */ public boolean isSetTlist() { return this.tlist != null; } public void setTlistIsSet(boolean value) { if(!value) { this.tlist = null; } } public int getTsetSize() { return (this.tset == null) ? 0 : this.tset.size(); } public java.util.Iterator getTsetIterator() { return (this.tset == null) ? null : this.tset.iterator(); } public void addToTset(ComplexTObject elem) { if(this.tset == null) { this.tset = new HashSet(); } this.tset.add(elem); } public Set getTset() { return this.tset; } public ComplexTObject setTset(Set tset) { this.tset = tset; return this; } public void unsetTset() { this.tset = null; } /** * Returns true if field tset is set (has been assigned a value) and false * otherwise */ public boolean isSetTset() { return this.tset != null; } public void setTsetIsSet(boolean value) { if(!value) { this.tset = null; } } public com.cinchapi.concourse.thrift.TObject getTobject() { return this.tobject; } public ComplexTObject setTobject( com.cinchapi.concourse.thrift.TObject tobject) { this.tobject = tobject; return this; } public void unsetTobject() { this.tobject = null; } /** * Returns true if field tobject is set (has been assigned a value) and * false otherwise */ public boolean isSetTobject() { return this.tobject != null; } public void setTobjectIsSet(boolean value) { if(!value) { this.tobject = null; } } public com.cinchapi.concourse.thrift.TCriteria getTcriteria() { return this.tcriteria; } public ComplexTObject setTcriteria( com.cinchapi.concourse.thrift.TCriteria tcriteria) { this.tcriteria = tcriteria; return this; } public void unsetTcriteria() { this.tcriteria = null; } /** * Returns true if field tcriteria is set (has been assigned a value) and * false otherwise */ public boolean isSetTcriteria() { return this.tcriteria != null; } public void setTcriteriaIsSet(boolean value) { if(!value) { this.tcriteria = null; } } public byte[] getTbinary() { setTbinary(org.apache.thrift.TBaseHelper.rightSize(tbinary)); return tbinary == null ? null : tbinary.array(); } public ByteBuffer bufferForTbinary() { return org.apache.thrift.TBaseHelper.copyBinary(tbinary); } public ComplexTObject setTbinary(byte[] tbinary) { this.tbinary = tbinary == null ? (ByteBuffer) null : ByteBuffer.wrap(Arrays.copyOf(tbinary, tbinary.length)); return this; } public ComplexTObject setTbinary(ByteBuffer tbinary) { this.tbinary = org.apache.thrift.TBaseHelper.copyBinary(tbinary); return this; } public void unsetTbinary() { this.tbinary = null; } /** * Returns true if field tbinary is set (has been assigned a value) and * false otherwise */ public boolean isSetTbinary() { return this.tbinary != null; } public void setTbinaryIsSet(boolean value) { if(!value) { this.tbinary = null; } } public void setFieldValue(_Fields field, Object value) { switch (field) { case TYPE: if(value == null) { unsetType(); } else { setType((ComplexTObjectType) value); } break; case TSCALAR: if(value == null) { unsetTscalar(); } else { setTscalar((com.cinchapi.concourse.thrift.TObject) value); } break; case TMAP: if(value == null) { unsetTmap(); } else { setTmap((Map) value); } break; case TLIST: if(value == null) { unsetTlist(); } else { setTlist((List) value); } break; case TSET: if(value == null) { unsetTset(); } else { setTset((Set) value); } break; case TOBJECT: if(value == null) { unsetTobject(); } else { setTobject((com.cinchapi.concourse.thrift.TObject) value); } break; case TCRITERIA: if(value == null) { unsetTcriteria(); } else { setTcriteria((com.cinchapi.concourse.thrift.TCriteria) value); } break; case TBINARY: if(value == null) { unsetTbinary(); } else { setTbinary((ByteBuffer) value); } break; } } public Object getFieldValue(_Fields field) { switch (field) { case TYPE: return getType(); case TSCALAR: return getTscalar(); case TMAP: return getTmap(); case TLIST: return getTlist(); case TSET: return getTset(); case TOBJECT: return getTobject(); case TCRITERIA: return getTcriteria(); case TBINARY: return getTbinary(); } 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 TYPE: return isSetType(); case TSCALAR: return isSetTscalar(); case TMAP: return isSetTmap(); case TLIST: return isSetTlist(); case TSET: return isSetTset(); case TOBJECT: return isSetTobject(); case TCRITERIA: return isSetTcriteria(); case TBINARY: return isSetTbinary(); } throw new IllegalStateException(); } @Override public boolean equals(Object that) { if(that == null) return false; if(that instanceof ComplexTObject) return this.equals((ComplexTObject) that); return false; } public boolean equals(ComplexTObject that) { if(that == null) return false; boolean this_present_type = true && this.isSetType(); boolean that_present_type = true && that.isSetType(); if(this_present_type || that_present_type) { if(!(this_present_type && that_present_type)) return false; if(!this.type.equals(that.type)) return false; } boolean this_present_tscalar = true && this.isSetTscalar(); boolean that_present_tscalar = true && that.isSetTscalar(); if(this_present_tscalar || that_present_tscalar) { if(!(this_present_tscalar && that_present_tscalar)) return false; if(!this.tscalar.equals(that.tscalar)) return false; } boolean this_present_tmap = true && this.isSetTmap(); boolean that_present_tmap = true && that.isSetTmap(); if(this_present_tmap || that_present_tmap) { if(!(this_present_tmap && that_present_tmap)) return false; if(!this.tmap.equals(that.tmap)) return false; } boolean this_present_tlist = true && this.isSetTlist(); boolean that_present_tlist = true && that.isSetTlist(); if(this_present_tlist || that_present_tlist) { if(!(this_present_tlist && that_present_tlist)) return false; if(!this.tlist.equals(that.tlist)) return false; } boolean this_present_tset = true && this.isSetTset(); boolean that_present_tset = true && that.isSetTset(); if(this_present_tset || that_present_tset) { if(!(this_present_tset && that_present_tset)) return false; if(!this.tset.equals(that.tset)) return false; } boolean this_present_tobject = true && this.isSetTobject(); boolean that_present_tobject = true && that.isSetTobject(); if(this_present_tobject || that_present_tobject) { if(!(this_present_tobject && that_present_tobject)) return false; if(!this.tobject.equals(that.tobject)) return false; } boolean this_present_tcriteria = true && this.isSetTcriteria(); boolean that_present_tcriteria = true && that.isSetTcriteria(); if(this_present_tcriteria || that_present_tcriteria) { if(!(this_present_tcriteria && that_present_tcriteria)) return false; if(!this.tcriteria.equals(that.tcriteria)) return false; } boolean this_present_tbinary = true && this.isSetTbinary(); boolean that_present_tbinary = true && that.isSetTbinary(); if(this_present_tbinary || that_present_tbinary) { if(!(this_present_tbinary && that_present_tbinary)) return false; if(!this.tbinary.equals(that.tbinary)) return false; } return true; } @Override public int hashCode() { List list = new ArrayList(); boolean present_type = true && (isSetType()); list.add(present_type); if(present_type) list.add(type.getValue()); boolean present_tscalar = true && (isSetTscalar()); list.add(present_tscalar); if(present_tscalar) list.add(tscalar); boolean present_tmap = true && (isSetTmap()); list.add(present_tmap); if(present_tmap) list.add(tmap); boolean present_tlist = true && (isSetTlist()); list.add(present_tlist); if(present_tlist) list.add(tlist); boolean present_tset = true && (isSetTset()); list.add(present_tset); if(present_tset) list.add(tset); boolean present_tobject = true && (isSetTobject()); list.add(present_tobject); if(present_tobject) list.add(tobject); boolean present_tcriteria = true && (isSetTcriteria()); list.add(present_tcriteria); if(present_tcriteria) list.add(tcriteria); boolean present_tbinary = true && (isSetTbinary()); list.add(present_tbinary); if(present_tbinary) list.add(tbinary); return list.hashCode(); } @Override public int compareTo(ComplexTObject other) { if(!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = Boolean.valueOf(isSetType()) .compareTo(other.isSetType()); if(lastComparison != 0) { return lastComparison; } if(isSetType()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.type, other.type); if(lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetTscalar()) .compareTo(other.isSetTscalar()); if(lastComparison != 0) { return lastComparison; } if(isSetTscalar()) { lastComparison = org.apache.thrift.TBaseHelper .compareTo(this.tscalar, other.tscalar); if(lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetTmap()) .compareTo(other.isSetTmap()); if(lastComparison != 0) { return lastComparison; } if(isSetTmap()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.tmap, other.tmap); if(lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetTlist()) .compareTo(other.isSetTlist()); if(lastComparison != 0) { return lastComparison; } if(isSetTlist()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.tlist, other.tlist); if(lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetTset()) .compareTo(other.isSetTset()); if(lastComparison != 0) { return lastComparison; } if(isSetTset()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.tset, other.tset); if(lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetTobject()) .compareTo(other.isSetTobject()); if(lastComparison != 0) { return lastComparison; } if(isSetTobject()) { lastComparison = org.apache.thrift.TBaseHelper .compareTo(this.tobject, other.tobject); if(lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetTcriteria()) .compareTo(other.isSetTcriteria()); if(lastComparison != 0) { return lastComparison; } if(isSetTcriteria()) { lastComparison = org.apache.thrift.TBaseHelper .compareTo(this.tcriteria, other.tcriteria); if(lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(isSetTbinary()) .compareTo(other.isSetTbinary()); if(lastComparison != 0) { return lastComparison; } if(isSetTbinary()) { lastComparison = org.apache.thrift.TBaseHelper .compareTo(this.tbinary, other.tbinary); 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("ComplexTObject("); boolean first = true; sb.append("type:"); if(this.type == null) { sb.append("null"); } else { sb.append(this.type); } first = false; if(isSetTscalar()) { if(!first) sb.append(", "); sb.append("tscalar:"); if(this.tscalar == null) { sb.append("null"); } else { sb.append(this.tscalar); } first = false; } if(isSetTmap()) { if(!first) sb.append(", "); sb.append("tmap:"); if(this.tmap == null) { sb.append("null"); } else { sb.append(this.tmap); } first = false; } if(isSetTlist()) { if(!first) sb.append(", "); sb.append("tlist:"); if(this.tlist == null) { sb.append("null"); } else { sb.append(this.tlist); } first = false; } if(isSetTset()) { if(!first) sb.append(", "); sb.append("tset:"); if(this.tset == null) { sb.append("null"); } else { sb.append(this.tset); } first = false; } if(isSetTobject()) { if(!first) sb.append(", "); sb.append("tobject:"); if(this.tobject == null) { sb.append("null"); } else { sb.append(this.tobject); } first = false; } if(isSetTcriteria()) { if(!first) sb.append(", "); sb.append("tcriteria:"); if(this.tcriteria == null) { sb.append("null"); } else { sb.append(this.tcriteria); } first = false; } if(isSetTbinary()) { if(!first) sb.append(", "); sb.append("tbinary:"); if(this.tbinary == null) { sb.append("null"); } else { org.apache.thrift.TBaseHelper.toString(this.tbinary, sb); } first = false; } sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields if(type == null) { throw new org.apache.thrift.protocol.TProtocolException( "Required field 'type' was not present! Struct: " + toString()); } // check for sub-struct validity if(tscalar != null) { tscalar.validate(); } if(tobject != null) { tobject.validate(); } if(tcriteria != null) { tcriteria.validate(); } } 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 ComplexTObjectStandardSchemeFactory implements SchemeFactory { public ComplexTObjectStandardScheme getScheme() { return new ComplexTObjectStandardScheme(); } } private static class ComplexTObjectStandardScheme extends StandardScheme { public void read(org.apache.thrift.protocol.TProtocol iprot, ComplexTObject 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: // TYPE if(schemeField.type == org.apache.thrift.protocol.TType.I32) { struct.type = com.cinchapi.concourse.thrift.ComplexTObjectType .findByValue(iprot.readI32()); struct.setTypeIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 2: // TSCALAR if(schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { struct.tscalar = new com.cinchapi.concourse.thrift.TObject(); struct.tscalar.read(iprot); struct.setTscalarIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 3: // TMAP if(schemeField.type == org.apache.thrift.protocol.TType.MAP) { { org.apache.thrift.protocol.TMap _map0 = iprot .readMapBegin(); struct.tmap = new LinkedHashMap( 2 * _map0.size); ComplexTObject _key1; ComplexTObject _val2; for (int _i3 = 0; _i3 < _map0.size; ++_i3) { _key1 = new ComplexTObject(); _key1.read(iprot); _val2 = new ComplexTObject(); _val2.read(iprot); struct.tmap.put(_key1, _val2); } iprot.readMapEnd(); } struct.setTmapIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 4: // TLIST if(schemeField.type == org.apache.thrift.protocol.TType.LIST) { { org.apache.thrift.protocol.TList _list4 = iprot .readListBegin(); struct.tlist = new ArrayList( _list4.size); ComplexTObject _elem5; for (int _i6 = 0; _i6 < _list4.size; ++_i6) { _elem5 = new ComplexTObject(); _elem5.read(iprot); struct.tlist.add(_elem5); } iprot.readListEnd(); } struct.setTlistIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 5: // TSET if(schemeField.type == org.apache.thrift.protocol.TType.SET) { { org.apache.thrift.protocol.TSet _set7 = iprot .readSetBegin(); struct.tset = new HashSet( 2 * _set7.size); ComplexTObject _elem8; for (int _i9 = 0; _i9 < _set7.size; ++_i9) { _elem8 = new ComplexTObject(); _elem8.read(iprot); struct.tset.add(_elem8); } iprot.readSetEnd(); } struct.setTsetIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 6: // TOBJECT if(schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { struct.tobject = new com.cinchapi.concourse.thrift.TObject(); struct.tobject.read(iprot); struct.setTobjectIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 7: // TCRITERIA if(schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { struct.tcriteria = new com.cinchapi.concourse.thrift.TCriteria(); struct.tcriteria.read(iprot); struct.setTcriteriaIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 8: // TBINARY if(schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.tbinary = iprot.readBinary(); struct.setTbinaryIsSet(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, ComplexTObject struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if(struct.type != null) { oprot.writeFieldBegin(TYPE_FIELD_DESC); oprot.writeI32(struct.type.getValue()); oprot.writeFieldEnd(); } if(struct.tscalar != null) { if(struct.isSetTscalar()) { oprot.writeFieldBegin(TSCALAR_FIELD_DESC); struct.tscalar.write(oprot); oprot.writeFieldEnd(); } } if(struct.tmap != null) { if(struct.isSetTmap()) { oprot.writeFieldBegin(TMAP_FIELD_DESC); { oprot.writeMapBegin(new org.apache.thrift.protocol.TMap( org.apache.thrift.protocol.TType.STRUCT, org.apache.thrift.protocol.TType.STRUCT, struct.tmap.size())); for (Map.Entry _iter10 : struct.tmap .entrySet()) { _iter10.getKey().write(oprot); _iter10.getValue().write(oprot); } oprot.writeMapEnd(); } oprot.writeFieldEnd(); } } if(struct.tlist != null) { if(struct.isSetTlist()) { oprot.writeFieldBegin(TLIST_FIELD_DESC); { oprot.writeListBegin( new org.apache.thrift.protocol.TList( org.apache.thrift.protocol.TType.STRUCT, struct.tlist.size())); for (ComplexTObject _iter11 : struct.tlist) { _iter11.write(oprot); } oprot.writeListEnd(); } oprot.writeFieldEnd(); } } if(struct.tset != null) { if(struct.isSetTset()) { oprot.writeFieldBegin(TSET_FIELD_DESC); { oprot.writeSetBegin(new org.apache.thrift.protocol.TSet( org.apache.thrift.protocol.TType.STRUCT, struct.tset.size())); for (ComplexTObject _iter12 : struct.tset) { _iter12.write(oprot); } oprot.writeSetEnd(); } oprot.writeFieldEnd(); } } if(struct.tobject != null) { if(struct.isSetTobject()) { oprot.writeFieldBegin(TOBJECT_FIELD_DESC); struct.tobject.write(oprot); oprot.writeFieldEnd(); } } if(struct.tcriteria != null) { if(struct.isSetTcriteria()) { oprot.writeFieldBegin(TCRITERIA_FIELD_DESC); struct.tcriteria.write(oprot); oprot.writeFieldEnd(); } } if(struct.tbinary != null) { if(struct.isSetTbinary()) { oprot.writeFieldBegin(TBINARY_FIELD_DESC); oprot.writeBinary(struct.tbinary); oprot.writeFieldEnd(); } } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class ComplexTObjectTupleSchemeFactory implements SchemeFactory { public ComplexTObjectTupleScheme getScheme() { return new ComplexTObjectTupleScheme(); } } private static class ComplexTObjectTupleScheme extends TupleScheme { @Override public void write(org.apache.thrift.protocol.TProtocol prot, ComplexTObject struct) throws org.apache.thrift.TException { TTupleProtocol oprot = (TTupleProtocol) prot; oprot.writeI32(struct.type.getValue()); BitSet optionals = new BitSet(); if(struct.isSetTscalar()) { optionals.set(0); } if(struct.isSetTmap()) { optionals.set(1); } if(struct.isSetTlist()) { optionals.set(2); } if(struct.isSetTset()) { optionals.set(3); } if(struct.isSetTobject()) { optionals.set(4); } if(struct.isSetTcriteria()) { optionals.set(5); } if(struct.isSetTbinary()) { optionals.set(6); } oprot.writeBitSet(optionals, 7); if(struct.isSetTscalar()) { struct.tscalar.write(oprot); } if(struct.isSetTmap()) { { oprot.writeI32(struct.tmap.size()); for (Map.Entry _iter13 : struct.tmap .entrySet()) { _iter13.getKey().write(oprot); _iter13.getValue().write(oprot); } } } if(struct.isSetTlist()) { { oprot.writeI32(struct.tlist.size()); for (ComplexTObject _iter14 : struct.tlist) { _iter14.write(oprot); } } } if(struct.isSetTset()) { { oprot.writeI32(struct.tset.size()); for (ComplexTObject _iter15 : struct.tset) { _iter15.write(oprot); } } } if(struct.isSetTobject()) { struct.tobject.write(oprot); } if(struct.isSetTcriteria()) { struct.tcriteria.write(oprot); } if(struct.isSetTbinary()) { oprot.writeBinary(struct.tbinary); } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, ComplexTObject struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; struct.type = com.cinchapi.concourse.thrift.ComplexTObjectType .findByValue(iprot.readI32()); struct.setTypeIsSet(true); BitSet incoming = iprot.readBitSet(7); if(incoming.get(0)) { struct.tscalar = new com.cinchapi.concourse.thrift.TObject(); struct.tscalar.read(iprot); struct.setTscalarIsSet(true); } if(incoming.get(1)) { { org.apache.thrift.protocol.TMap _map16 = new org.apache.thrift.protocol.TMap( org.apache.thrift.protocol.TType.STRUCT, org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); struct.tmap = new LinkedHashMap( 2 * _map16.size); ComplexTObject _key17; ComplexTObject _val18; for (int _i19 = 0; _i19 < _map16.size; ++_i19) { _key17 = new ComplexTObject(); _key17.read(iprot); _val18 = new ComplexTObject(); _val18.read(iprot); struct.tmap.put(_key17, _val18); } } struct.setTmapIsSet(true); } if(incoming.get(2)) { { org.apache.thrift.protocol.TList _list20 = new org.apache.thrift.protocol.TList( org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); struct.tlist = new ArrayList(_list20.size); ComplexTObject _elem21; for (int _i22 = 0; _i22 < _list20.size; ++_i22) { _elem21 = new ComplexTObject(); _elem21.read(iprot); struct.tlist.add(_elem21); } } struct.setTlistIsSet(true); } if(incoming.get(3)) { { org.apache.thrift.protocol.TSet _set23 = new org.apache.thrift.protocol.TSet( org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); struct.tset = new HashSet(2 * _set23.size); ComplexTObject _elem24; for (int _i25 = 0; _i25 < _set23.size; ++_i25) { _elem24 = new ComplexTObject(); _elem24.read(iprot); struct.tset.add(_elem24); } } struct.setTsetIsSet(true); } if(incoming.get(4)) { struct.tobject = new com.cinchapi.concourse.thrift.TObject(); struct.tobject.read(iprot); struct.setTobjectIsSet(true); } if(incoming.get(5)) { struct.tcriteria = new com.cinchapi.concourse.thrift.TCriteria(); struct.tcriteria.read(iprot); struct.setTcriteriaIsSet(true); } if(incoming.get(6)) { struct.tbinary = iprot.readBinary(); struct.setTbinaryIsSet(true); } } } }