ezbake.data.elastic.thrift.TermsFacet.java Source code

Java tutorial

Introduction

Here is the source code for ezbake.data.elastic.thrift.TermsFacet.java

Source

/*   Copyright (C) 2013-2014 Computer Sciences Corporation
 *
 * 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. */

/**
 * Autogenerated by Thrift Compiler (0.9.1)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
package ezbake.data.elastic.thrift;

import org.apache.commons.lang3.builder.HashCodeBuilder;
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 org.apache.thrift.protocol.TProtocolException;
import org.apache.thrift.EncodingUtils;
import org.apache.thrift.TException;
import org.apache.thrift.async.AsyncMethodCallback;
import org.apache.thrift.server.AbstractNonblockingServer.*;
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 TermsFacet implements org.apache.thrift.TBase<TermsFacet, TermsFacet._Fields>, java.io.Serializable,
        Cloneable, Comparable<TermsFacet> {
    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct(
            "TermsFacet");

    private static final org.apache.thrift.protocol.TField FIELDS_FIELD_DESC = new org.apache.thrift.protocol.TField(
            "fields", org.apache.thrift.protocol.TType.LIST, (short) 1);
    private static final org.apache.thrift.protocol.TField ORDER_FIELD_DESC = new org.apache.thrift.protocol.TField(
            "order", org.apache.thrift.protocol.TType.I32, (short) 2);
    private static final org.apache.thrift.protocol.TField EXCLUDE_FIELD_DESC = new org.apache.thrift.protocol.TField(
            "exclude", org.apache.thrift.protocol.TType.LIST, (short) 3);
    private static final org.apache.thrift.protocol.TField REGEX_FIELD_DESC = new org.apache.thrift.protocol.TField(
            "regex", org.apache.thrift.protocol.TType.STRING, (short) 4);
    private static final org.apache.thrift.protocol.TField SIZE_FIELD_DESC = new org.apache.thrift.protocol.TField(
            "size", org.apache.thrift.protocol.TType.I32, (short) 5);
    private static final org.apache.thrift.protocol.TField IS_SCRIPT_FIELD_FIELD_DESC = new org.apache.thrift.protocol.TField(
            "isScriptField", org.apache.thrift.protocol.TType.BOOL, (short) 6);
    private static final org.apache.thrift.protocol.TField ALL_TERMS_FIELD_DESC = new org.apache.thrift.protocol.TField(
            "allTerms", org.apache.thrift.protocol.TType.BOOL, (short) 7);

    private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
    static {
        schemes.put(StandardScheme.class, new TermsFacetStandardSchemeFactory());
        schemes.put(TupleScheme.class, new TermsFacetTupleSchemeFactory());
    }

    public List<String> fields; // required
    /**
     * 
     * @see FacetOrder
     */
    public FacetOrder order; // optional
    public List<String> exclude; // optional
    public String regex; // optional
    public int size; // optional
    public boolean isScriptField; // optional
    public boolean allTerms; // 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 {
        FIELDS((short) 1, "fields"),
        /**
         * 
         * @see FacetOrder
         */
        ORDER((short) 2, "order"), EXCLUDE((short) 3, "exclude"), REGEX((short) 4, "regex"), SIZE((short) 5,
                "size"), IS_SCRIPT_FIELD((short) 6, "isScriptField"), ALL_TERMS((short) 7, "allTerms");

        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: // FIELDS
                return FIELDS;
            case 2: // ORDER
                return ORDER;
            case 3: // EXCLUDE
                return EXCLUDE;
            case 4: // REGEX
                return REGEX;
            case 5: // SIZE
                return SIZE;
            case 6: // IS_SCRIPT_FIELD
                return IS_SCRIPT_FIELD;
            case 7: // ALL_TERMS
                return ALL_TERMS;
            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 __SIZE_ISSET_ID = 0;
    private static final int __ISSCRIPTFIELD_ISSET_ID = 1;
    private static final int __ALLTERMS_ISSET_ID = 2;
    private byte __isset_bitfield = 0;
    private _Fields optionals[] = { _Fields.ORDER, _Fields.EXCLUDE, _Fields.REGEX, _Fields.SIZE,
            _Fields.IS_SCRIPT_FIELD, _Fields.ALL_TERMS };
    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.FIELDS,
                new org.apache.thrift.meta_data.FieldMetaData("fields",
                        org.apache.thrift.TFieldRequirementType.REQUIRED,
                        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.STRING))));
        tmpMap.put(_Fields.ORDER,
                new org.apache.thrift.meta_data.FieldMetaData("order",
                        org.apache.thrift.TFieldRequirementType.OPTIONAL,
                        new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM,
                                FacetOrder.class)));
        tmpMap.put(_Fields.EXCLUDE,
                new org.apache.thrift.meta_data.FieldMetaData("exclude",
                        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.STRING))));
        tmpMap.put(_Fields.REGEX, new org.apache.thrift.meta_data.FieldMetaData("regex",
                org.apache.thrift.TFieldRequirementType.OPTIONAL,
                new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
        tmpMap.put(_Fields.SIZE,
                new org.apache.thrift.meta_data.FieldMetaData("size",
                        org.apache.thrift.TFieldRequirementType.OPTIONAL,
                        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
        tmpMap.put(_Fields.IS_SCRIPT_FIELD,
                new org.apache.thrift.meta_data.FieldMetaData("isScriptField",
                        org.apache.thrift.TFieldRequirementType.OPTIONAL,
                        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
        tmpMap.put(_Fields.ALL_TERMS,
                new org.apache.thrift.meta_data.FieldMetaData("allTerms",
                        org.apache.thrift.TFieldRequirementType.OPTIONAL,
                        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
        metaDataMap = Collections.unmodifiableMap(tmpMap);
        org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TermsFacet.class, metaDataMap);
    }

    public TermsFacet() {
    }

    public TermsFacet(List<String> fields) {
        this();
        this.fields = fields;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public TermsFacet(TermsFacet other) {
        __isset_bitfield = other.__isset_bitfield;
        if (other.isSetFields()) {
            List<String> __this__fields = new ArrayList<String>(other.fields);
            this.fields = __this__fields;
        }
        if (other.isSetOrder()) {
            this.order = other.order;
        }
        if (other.isSetExclude()) {
            List<String> __this__exclude = new ArrayList<String>(other.exclude);
            this.exclude = __this__exclude;
        }
        if (other.isSetRegex()) {
            this.regex = other.regex;
        }
        this.size = other.size;
        this.isScriptField = other.isScriptField;
        this.allTerms = other.allTerms;
    }

    public TermsFacet deepCopy() {
        return new TermsFacet(this);
    }

    @Override
    public void clear() {
        this.fields = null;
        this.order = null;
        this.exclude = null;
        this.regex = null;
        setSizeIsSet(false);
        this.size = 0;
        setIsScriptFieldIsSet(false);
        this.isScriptField = false;
        setAllTermsIsSet(false);
        this.allTerms = false;
    }

    public int getFieldsSize() {
        return (this.fields == null) ? 0 : this.fields.size();
    }

    public java.util.Iterator<String> getFieldsIterator() {
        return (this.fields == null) ? null : this.fields.iterator();
    }

    public void addToFields(String elem) {
        if (this.fields == null) {
            this.fields = new ArrayList<String>();
        }
        this.fields.add(elem);
    }

    public List<String> getFields() {
        return this.fields;
    }

    public TermsFacet setFields(List<String> fields) {
        this.fields = fields;
        return this;
    }

    public void unsetFields() {
        this.fields = null;
    }

    /** Returns true if field fields is set (has been assigned a value) and false otherwise */
    public boolean isSetFields() {
        return this.fields != null;
    }

    public void setFieldsIsSet(boolean value) {
        if (!value) {
            this.fields = null;
        }
    }

    /**
     * 
     * @see FacetOrder
     */
    public FacetOrder getOrder() {
        return this.order;
    }

    /**
     * 
     * @see FacetOrder
     */
    public TermsFacet setOrder(FacetOrder order) {
        this.order = order;
        return this;
    }

    public void unsetOrder() {
        this.order = null;
    }

    /** Returns true if field order is set (has been assigned a value) and false otherwise */
    public boolean isSetOrder() {
        return this.order != null;
    }

    public void setOrderIsSet(boolean value) {
        if (!value) {
            this.order = null;
        }
    }

    public int getExcludeSize() {
        return (this.exclude == null) ? 0 : this.exclude.size();
    }

    public java.util.Iterator<String> getExcludeIterator() {
        return (this.exclude == null) ? null : this.exclude.iterator();
    }

    public void addToExclude(String elem) {
        if (this.exclude == null) {
            this.exclude = new ArrayList<String>();
        }
        this.exclude.add(elem);
    }

    public List<String> getExclude() {
        return this.exclude;
    }

    public TermsFacet setExclude(List<String> exclude) {
        this.exclude = exclude;
        return this;
    }

    public void unsetExclude() {
        this.exclude = null;
    }

    /** Returns true if field exclude is set (has been assigned a value) and false otherwise */
    public boolean isSetExclude() {
        return this.exclude != null;
    }

    public void setExcludeIsSet(boolean value) {
        if (!value) {
            this.exclude = null;
        }
    }

    public String getRegex() {
        return this.regex;
    }

    public TermsFacet setRegex(String regex) {
        this.regex = regex;
        return this;
    }

    public void unsetRegex() {
        this.regex = null;
    }

    /** Returns true if field regex is set (has been assigned a value) and false otherwise */
    public boolean isSetRegex() {
        return this.regex != null;
    }

    public void setRegexIsSet(boolean value) {
        if (!value) {
            this.regex = null;
        }
    }

    public int getSize() {
        return this.size;
    }

    public TermsFacet setSize(int size) {
        this.size = size;
        setSizeIsSet(true);
        return this;
    }

    public void unsetSize() {
        __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __SIZE_ISSET_ID);
    }

    /** Returns true if field size is set (has been assigned a value) and false otherwise */
    public boolean isSetSize() {
        return EncodingUtils.testBit(__isset_bitfield, __SIZE_ISSET_ID);
    }

    public void setSizeIsSet(boolean value) {
        __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __SIZE_ISSET_ID, value);
    }

    public boolean isIsScriptField() {
        return this.isScriptField;
    }

    public TermsFacet setIsScriptField(boolean isScriptField) {
        this.isScriptField = isScriptField;
        setIsScriptFieldIsSet(true);
        return this;
    }

    public void unsetIsScriptField() {
        __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __ISSCRIPTFIELD_ISSET_ID);
    }

    /** Returns true if field isScriptField is set (has been assigned a value) and false otherwise */
    public boolean isSetIsScriptField() {
        return EncodingUtils.testBit(__isset_bitfield, __ISSCRIPTFIELD_ISSET_ID);
    }

    public void setIsScriptFieldIsSet(boolean value) {
        __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __ISSCRIPTFIELD_ISSET_ID, value);
    }

    public boolean isAllTerms() {
        return this.allTerms;
    }

    public TermsFacet setAllTerms(boolean allTerms) {
        this.allTerms = allTerms;
        setAllTermsIsSet(true);
        return this;
    }

    public void unsetAllTerms() {
        __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __ALLTERMS_ISSET_ID);
    }

    /** Returns true if field allTerms is set (has been assigned a value) and false otherwise */
    public boolean isSetAllTerms() {
        return EncodingUtils.testBit(__isset_bitfield, __ALLTERMS_ISSET_ID);
    }

    public void setAllTermsIsSet(boolean value) {
        __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __ALLTERMS_ISSET_ID, value);
    }

    public void setFieldValue(_Fields field, Object value) {
        switch (field) {
        case FIELDS:
            if (value == null) {
                unsetFields();
            } else {
                setFields((List<String>) value);
            }
            break;

        case ORDER:
            if (value == null) {
                unsetOrder();
            } else {
                setOrder((FacetOrder) value);
            }
            break;

        case EXCLUDE:
            if (value == null) {
                unsetExclude();
            } else {
                setExclude((List<String>) value);
            }
            break;

        case REGEX:
            if (value == null) {
                unsetRegex();
            } else {
                setRegex((String) value);
            }
            break;

        case SIZE:
            if (value == null) {
                unsetSize();
            } else {
                setSize((Integer) value);
            }
            break;

        case IS_SCRIPT_FIELD:
            if (value == null) {
                unsetIsScriptField();
            } else {
                setIsScriptField((Boolean) value);
            }
            break;

        case ALL_TERMS:
            if (value == null) {
                unsetAllTerms();
            } else {
                setAllTerms((Boolean) value);
            }
            break;

        }
    }

    public Object getFieldValue(_Fields field) {
        switch (field) {
        case FIELDS:
            return getFields();

        case ORDER:
            return getOrder();

        case EXCLUDE:
            return getExclude();

        case REGEX:
            return getRegex();

        case SIZE:
            return Integer.valueOf(getSize());

        case IS_SCRIPT_FIELD:
            return Boolean.valueOf(isIsScriptField());

        case ALL_TERMS:
            return Boolean.valueOf(isAllTerms());

        }
        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 FIELDS:
            return isSetFields();
        case ORDER:
            return isSetOrder();
        case EXCLUDE:
            return isSetExclude();
        case REGEX:
            return isSetRegex();
        case SIZE:
            return isSetSize();
        case IS_SCRIPT_FIELD:
            return isSetIsScriptField();
        case ALL_TERMS:
            return isSetAllTerms();
        }
        throw new IllegalStateException();
    }

    @Override
    public boolean equals(Object that) {
        if (that == null)
            return false;
        if (that instanceof TermsFacet)
            return this.equals((TermsFacet) that);
        return false;
    }

    public boolean equals(TermsFacet that) {
        if (that == null)
            return false;

        boolean this_present_fields = true && this.isSetFields();
        boolean that_present_fields = true && that.isSetFields();
        if (this_present_fields || that_present_fields) {
            if (!(this_present_fields && that_present_fields))
                return false;
            if (!this.fields.equals(that.fields))
                return false;
        }

        boolean this_present_order = true && this.isSetOrder();
        boolean that_present_order = true && that.isSetOrder();
        if (this_present_order || that_present_order) {
            if (!(this_present_order && that_present_order))
                return false;
            if (!this.order.equals(that.order))
                return false;
        }

        boolean this_present_exclude = true && this.isSetExclude();
        boolean that_present_exclude = true && that.isSetExclude();
        if (this_present_exclude || that_present_exclude) {
            if (!(this_present_exclude && that_present_exclude))
                return false;
            if (!this.exclude.equals(that.exclude))
                return false;
        }

        boolean this_present_regex = true && this.isSetRegex();
        boolean that_present_regex = true && that.isSetRegex();
        if (this_present_regex || that_present_regex) {
            if (!(this_present_regex && that_present_regex))
                return false;
            if (!this.regex.equals(that.regex))
                return false;
        }

        boolean this_present_size = true && this.isSetSize();
        boolean that_present_size = true && that.isSetSize();
        if (this_present_size || that_present_size) {
            if (!(this_present_size && that_present_size))
                return false;
            if (this.size != that.size)
                return false;
        }

        boolean this_present_isScriptField = true && this.isSetIsScriptField();
        boolean that_present_isScriptField = true && that.isSetIsScriptField();
        if (this_present_isScriptField || that_present_isScriptField) {
            if (!(this_present_isScriptField && that_present_isScriptField))
                return false;
            if (this.isScriptField != that.isScriptField)
                return false;
        }

        boolean this_present_allTerms = true && this.isSetAllTerms();
        boolean that_present_allTerms = true && that.isSetAllTerms();
        if (this_present_allTerms || that_present_allTerms) {
            if (!(this_present_allTerms && that_present_allTerms))
                return false;
            if (this.allTerms != that.allTerms)
                return false;
        }

        return true;
    }

    @Override
    public int hashCode() {
        HashCodeBuilder builder = new HashCodeBuilder();

        boolean present_fields = true && (isSetFields());
        builder.append(present_fields);
        if (present_fields)
            builder.append(fields);

        boolean present_order = true && (isSetOrder());
        builder.append(present_order);
        if (present_order)
            builder.append(order.getValue());

        boolean present_exclude = true && (isSetExclude());
        builder.append(present_exclude);
        if (present_exclude)
            builder.append(exclude);

        boolean present_regex = true && (isSetRegex());
        builder.append(present_regex);
        if (present_regex)
            builder.append(regex);

        boolean present_size = true && (isSetSize());
        builder.append(present_size);
        if (present_size)
            builder.append(size);

        boolean present_isScriptField = true && (isSetIsScriptField());
        builder.append(present_isScriptField);
        if (present_isScriptField)
            builder.append(isScriptField);

        boolean present_allTerms = true && (isSetAllTerms());
        builder.append(present_allTerms);
        if (present_allTerms)
            builder.append(allTerms);

        return builder.toHashCode();
    }

    @Override
    public int compareTo(TermsFacet other) {
        if (!getClass().equals(other.getClass())) {
            return getClass().getName().compareTo(other.getClass().getName());
        }

        int lastComparison = 0;

        lastComparison = Boolean.valueOf(isSetFields()).compareTo(other.isSetFields());
        if (lastComparison != 0) {
            return lastComparison;
        }
        if (isSetFields()) {
            lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.fields, other.fields);
            if (lastComparison != 0) {
                return lastComparison;
            }
        }
        lastComparison = Boolean.valueOf(isSetOrder()).compareTo(other.isSetOrder());
        if (lastComparison != 0) {
            return lastComparison;
        }
        if (isSetOrder()) {
            lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.order, other.order);
            if (lastComparison != 0) {
                return lastComparison;
            }
        }
        lastComparison = Boolean.valueOf(isSetExclude()).compareTo(other.isSetExclude());
        if (lastComparison != 0) {
            return lastComparison;
        }
        if (isSetExclude()) {
            lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.exclude, other.exclude);
            if (lastComparison != 0) {
                return lastComparison;
            }
        }
        lastComparison = Boolean.valueOf(isSetRegex()).compareTo(other.isSetRegex());
        if (lastComparison != 0) {
            return lastComparison;
        }
        if (isSetRegex()) {
            lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.regex, other.regex);
            if (lastComparison != 0) {
                return lastComparison;
            }
        }
        lastComparison = Boolean.valueOf(isSetSize()).compareTo(other.isSetSize());
        if (lastComparison != 0) {
            return lastComparison;
        }
        if (isSetSize()) {
            lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.size, other.size);
            if (lastComparison != 0) {
                return lastComparison;
            }
        }
        lastComparison = Boolean.valueOf(isSetIsScriptField()).compareTo(other.isSetIsScriptField());
        if (lastComparison != 0) {
            return lastComparison;
        }
        if (isSetIsScriptField()) {
            lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.isScriptField, other.isScriptField);
            if (lastComparison != 0) {
                return lastComparison;
            }
        }
        lastComparison = Boolean.valueOf(isSetAllTerms()).compareTo(other.isSetAllTerms());
        if (lastComparison != 0) {
            return lastComparison;
        }
        if (isSetAllTerms()) {
            lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.allTerms, other.allTerms);
            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("TermsFacet(");
        boolean first = true;

        sb.append("fields:");
        if (this.fields == null) {
            sb.append("null");
        } else {
            sb.append(this.fields);
        }
        first = false;
        if (isSetOrder()) {
            if (!first)
                sb.append(", ");
            sb.append("order:");
            if (this.order == null) {
                sb.append("null");
            } else {
                sb.append(this.order);
            }
            first = false;
        }
        if (isSetExclude()) {
            if (!first)
                sb.append(", ");
            sb.append("exclude:");
            if (this.exclude == null) {
                sb.append("null");
            } else {
                sb.append(this.exclude);
            }
            first = false;
        }
        if (isSetRegex()) {
            if (!first)
                sb.append(", ");
            sb.append("regex:");
            if (this.regex == null) {
                sb.append("null");
            } else {
                sb.append(this.regex);
            }
            first = false;
        }
        if (isSetSize()) {
            if (!first)
                sb.append(", ");
            sb.append("size:");
            sb.append(this.size);
            first = false;
        }
        if (isSetIsScriptField()) {
            if (!first)
                sb.append(", ");
            sb.append("isScriptField:");
            sb.append(this.isScriptField);
            first = false;
        }
        if (isSetAllTerms()) {
            if (!first)
                sb.append(", ");
            sb.append("allTerms:");
            sb.append(this.allTerms);
            first = false;
        }
        sb.append(")");
        return sb.toString();
    }

    public void validate() throws org.apache.thrift.TException {
        // check for required fields
        if (fields == null) {
            throw new org.apache.thrift.protocol.TProtocolException(
                    "Required field 'fields' was not present! Struct: " + toString());
        }
        // check for sub-struct validity
    }

    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_bitfield = 0;
            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 TermsFacetStandardSchemeFactory implements SchemeFactory {
        public TermsFacetStandardScheme getScheme() {
            return new TermsFacetStandardScheme();
        }
    }

    private static class TermsFacetStandardScheme extends StandardScheme<TermsFacet> {

        public void read(org.apache.thrift.protocol.TProtocol iprot, TermsFacet 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: // FIELDS
                    if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
                        {
                            org.apache.thrift.protocol.TList _list56 = iprot.readListBegin();
                            struct.fields = new ArrayList<String>(_list56.size);
                            for (int _i57 = 0; _i57 < _list56.size; ++_i57) {
                                String _elem58;
                                _elem58 = iprot.readString();
                                struct.fields.add(_elem58);
                            }
                            iprot.readListEnd();
                        }
                        struct.setFieldsIsSet(true);
                    } else {
                        org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
                    }
                    break;
                case 2: // ORDER
                    if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
                        struct.order = FacetOrder.findByValue(iprot.readI32());
                        struct.setOrderIsSet(true);
                    } else {
                        org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
                    }
                    break;
                case 3: // EXCLUDE
                    if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
                        {
                            org.apache.thrift.protocol.TList _list59 = iprot.readListBegin();
                            struct.exclude = new ArrayList<String>(_list59.size);
                            for (int _i60 = 0; _i60 < _list59.size; ++_i60) {
                                String _elem61;
                                _elem61 = iprot.readString();
                                struct.exclude.add(_elem61);
                            }
                            iprot.readListEnd();
                        }
                        struct.setExcludeIsSet(true);
                    } else {
                        org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
                    }
                    break;
                case 4: // REGEX
                    if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
                        struct.regex = iprot.readString();
                        struct.setRegexIsSet(true);
                    } else {
                        org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
                    }
                    break;
                case 5: // SIZE
                    if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
                        struct.size = iprot.readI32();
                        struct.setSizeIsSet(true);
                    } else {
                        org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
                    }
                    break;
                case 6: // IS_SCRIPT_FIELD
                    if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
                        struct.isScriptField = iprot.readBool();
                        struct.setIsScriptFieldIsSet(true);
                    } else {
                        org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
                    }
                    break;
                case 7: // ALL_TERMS
                    if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
                        struct.allTerms = iprot.readBool();
                        struct.setAllTermsIsSet(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, TermsFacet struct)
                throws org.apache.thrift.TException {
            struct.validate();

            oprot.writeStructBegin(STRUCT_DESC);
            if (struct.fields != null) {
                oprot.writeFieldBegin(FIELDS_FIELD_DESC);
                {
                    oprot.writeListBegin(new org.apache.thrift.protocol.TList(
                            org.apache.thrift.protocol.TType.STRING, struct.fields.size()));
                    for (String _iter62 : struct.fields) {
                        oprot.writeString(_iter62);
                    }
                    oprot.writeListEnd();
                }
                oprot.writeFieldEnd();
            }
            if (struct.order != null) {
                if (struct.isSetOrder()) {
                    oprot.writeFieldBegin(ORDER_FIELD_DESC);
                    oprot.writeI32(struct.order.getValue());
                    oprot.writeFieldEnd();
                }
            }
            if (struct.exclude != null) {
                if (struct.isSetExclude()) {
                    oprot.writeFieldBegin(EXCLUDE_FIELD_DESC);
                    {
                        oprot.writeListBegin(new org.apache.thrift.protocol.TList(
                                org.apache.thrift.protocol.TType.STRING, struct.exclude.size()));
                        for (String _iter63 : struct.exclude) {
                            oprot.writeString(_iter63);
                        }
                        oprot.writeListEnd();
                    }
                    oprot.writeFieldEnd();
                }
            }
            if (struct.regex != null) {
                if (struct.isSetRegex()) {
                    oprot.writeFieldBegin(REGEX_FIELD_DESC);
                    oprot.writeString(struct.regex);
                    oprot.writeFieldEnd();
                }
            }
            if (struct.isSetSize()) {
                oprot.writeFieldBegin(SIZE_FIELD_DESC);
                oprot.writeI32(struct.size);
                oprot.writeFieldEnd();
            }
            if (struct.isSetIsScriptField()) {
                oprot.writeFieldBegin(IS_SCRIPT_FIELD_FIELD_DESC);
                oprot.writeBool(struct.isScriptField);
                oprot.writeFieldEnd();
            }
            if (struct.isSetAllTerms()) {
                oprot.writeFieldBegin(ALL_TERMS_FIELD_DESC);
                oprot.writeBool(struct.allTerms);
                oprot.writeFieldEnd();
            }
            oprot.writeFieldStop();
            oprot.writeStructEnd();
        }

    }

    private static class TermsFacetTupleSchemeFactory implements SchemeFactory {
        public TermsFacetTupleScheme getScheme() {
            return new TermsFacetTupleScheme();
        }
    }

    private static class TermsFacetTupleScheme extends TupleScheme<TermsFacet> {

        @Override
        public void write(org.apache.thrift.protocol.TProtocol prot, TermsFacet struct)
                throws org.apache.thrift.TException {
            TTupleProtocol oprot = (TTupleProtocol) prot;
            {
                oprot.writeI32(struct.fields.size());
                for (String _iter64 : struct.fields) {
                    oprot.writeString(_iter64);
                }
            }
            BitSet optionals = new BitSet();
            if (struct.isSetOrder()) {
                optionals.set(0);
            }
            if (struct.isSetExclude()) {
                optionals.set(1);
            }
            if (struct.isSetRegex()) {
                optionals.set(2);
            }
            if (struct.isSetSize()) {
                optionals.set(3);
            }
            if (struct.isSetIsScriptField()) {
                optionals.set(4);
            }
            if (struct.isSetAllTerms()) {
                optionals.set(5);
            }
            oprot.writeBitSet(optionals, 6);
            if (struct.isSetOrder()) {
                oprot.writeI32(struct.order.getValue());
            }
            if (struct.isSetExclude()) {
                {
                    oprot.writeI32(struct.exclude.size());
                    for (String _iter65 : struct.exclude) {
                        oprot.writeString(_iter65);
                    }
                }
            }
            if (struct.isSetRegex()) {
                oprot.writeString(struct.regex);
            }
            if (struct.isSetSize()) {
                oprot.writeI32(struct.size);
            }
            if (struct.isSetIsScriptField()) {
                oprot.writeBool(struct.isScriptField);
            }
            if (struct.isSetAllTerms()) {
                oprot.writeBool(struct.allTerms);
            }
        }

        @Override
        public void read(org.apache.thrift.protocol.TProtocol prot, TermsFacet struct)
                throws org.apache.thrift.TException {
            TTupleProtocol iprot = (TTupleProtocol) prot;
            {
                org.apache.thrift.protocol.TList _list66 = new org.apache.thrift.protocol.TList(
                        org.apache.thrift.protocol.TType.STRING, iprot.readI32());
                struct.fields = new ArrayList<String>(_list66.size);
                for (int _i67 = 0; _i67 < _list66.size; ++_i67) {
                    String _elem68;
                    _elem68 = iprot.readString();
                    struct.fields.add(_elem68);
                }
            }
            struct.setFieldsIsSet(true);
            BitSet incoming = iprot.readBitSet(6);
            if (incoming.get(0)) {
                struct.order = FacetOrder.findByValue(iprot.readI32());
                struct.setOrderIsSet(true);
            }
            if (incoming.get(1)) {
                {
                    org.apache.thrift.protocol.TList _list69 = new org.apache.thrift.protocol.TList(
                            org.apache.thrift.protocol.TType.STRING, iprot.readI32());
                    struct.exclude = new ArrayList<String>(_list69.size);
                    for (int _i70 = 0; _i70 < _list69.size; ++_i70) {
                        String _elem71;
                        _elem71 = iprot.readString();
                        struct.exclude.add(_elem71);
                    }
                }
                struct.setExcludeIsSet(true);
            }
            if (incoming.get(2)) {
                struct.regex = iprot.readString();
                struct.setRegexIsSet(true);
            }
            if (incoming.get(3)) {
                struct.size = iprot.readI32();
                struct.setSizeIsSet(true);
            }
            if (incoming.get(4)) {
                struct.isScriptField = iprot.readBool();
                struct.setIsScriptFieldIsSet(true);
            }
            if (incoming.get(5)) {
                struct.allTerms = iprot.readBool();
                struct.setAllTermsIsSet(true);
            }
        }
    }

}