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

Java tutorial

Introduction

Here is the source code for ezbake.data.elastic.thrift.FacetRequest.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 FacetRequest extends org.apache.thrift.TUnion<FacetRequest, FacetRequest._Fields> {
    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct(
            "FacetRequest");
    private static final org.apache.thrift.protocol.TField HISTOGRAM_FACET_FIELD_DESC = new org.apache.thrift.protocol.TField(
            "histogramFacet", org.apache.thrift.protocol.TType.STRUCT, (short) 1);
    private static final org.apache.thrift.protocol.TField RANGE_FACET_FIELD_DESC = new org.apache.thrift.protocol.TField(
            "rangeFacet", org.apache.thrift.protocol.TType.STRUCT, (short) 2);
    private static final org.apache.thrift.protocol.TField FILTER_FACET_FIELD_DESC = new org.apache.thrift.protocol.TField(
            "filterFacet", org.apache.thrift.protocol.TType.STRUCT, (short) 3);
    private static final org.apache.thrift.protocol.TField TERMS_FACET_FIELD_DESC = new org.apache.thrift.protocol.TField(
            "termsFacet", org.apache.thrift.protocol.TType.STRUCT, (short) 4);
    private static final org.apache.thrift.protocol.TField DATE_HISTOGRAM_FACET_FIELD_DESC = new org.apache.thrift.protocol.TField(
            "dateHistogramFacet", org.apache.thrift.protocol.TType.STRUCT, (short) 5);
    private static final org.apache.thrift.protocol.TField TERMS_STATS_FACET_FIELD_DESC = new org.apache.thrift.protocol.TField(
            "termsStatsFacet", org.apache.thrift.protocol.TType.STRUCT, (short) 6);
    private static final org.apache.thrift.protocol.TField STATISTICAL_FACET_FIELD_DESC = new org.apache.thrift.protocol.TField(
            "statisticalFacet", org.apache.thrift.protocol.TType.STRUCT, (short) 7);
    private static final org.apache.thrift.protocol.TField TERMS_SCRIPT_FACET_FIELD_DESC = new org.apache.thrift.protocol.TField(
            "termsScriptFacet", org.apache.thrift.protocol.TType.STRUCT, (short) 8);

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements org.apache.thrift.TFieldIdEnum {
        HISTOGRAM_FACET((short) 1, "histogramFacet"), RANGE_FACET((short) 2, "rangeFacet"), FILTER_FACET((short) 3,
                "filterFacet"), TERMS_FACET((short) 4, "termsFacet"), DATE_HISTOGRAM_FACET((short) 5,
                        "dateHistogramFacet"), TERMS_STATS_FACET((short) 6, "termsStatsFacet"), STATISTICAL_FACET(
                                (short) 7, "statisticalFacet"), TERMS_SCRIPT_FACET((short) 8, "termsScriptFacet");

        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: // HISTOGRAM_FACET
                return HISTOGRAM_FACET;
            case 2: // RANGE_FACET
                return RANGE_FACET;
            case 3: // FILTER_FACET
                return FILTER_FACET;
            case 4: // TERMS_FACET
                return TERMS_FACET;
            case 5: // DATE_HISTOGRAM_FACET
                return DATE_HISTOGRAM_FACET;
            case 6: // TERMS_STATS_FACET
                return TERMS_STATS_FACET;
            case 7: // STATISTICAL_FACET
                return STATISTICAL_FACET;
            case 8: // TERMS_SCRIPT_FACET
                return TERMS_SCRIPT_FACET;
            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.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.HISTOGRAM_FACET,
                new org.apache.thrift.meta_data.FieldMetaData("histogramFacet",
                        org.apache.thrift.TFieldRequirementType.DEFAULT,
                        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT,
                                HistogramFacet.class)));
        tmpMap.put(_Fields.RANGE_FACET,
                new org.apache.thrift.meta_data.FieldMetaData("rangeFacet",
                        org.apache.thrift.TFieldRequirementType.DEFAULT,
                        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT,
                                RangeFacet.class)));
        tmpMap.put(_Fields.FILTER_FACET,
                new org.apache.thrift.meta_data.FieldMetaData("filterFacet",
                        org.apache.thrift.TFieldRequirementType.DEFAULT,
                        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT,
                                FilterFacet.class)));
        tmpMap.put(_Fields.TERMS_FACET,
                new org.apache.thrift.meta_data.FieldMetaData("termsFacet",
                        org.apache.thrift.TFieldRequirementType.DEFAULT,
                        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT,
                                TermsFacet.class)));
        tmpMap.put(_Fields.DATE_HISTOGRAM_FACET,
                new org.apache.thrift.meta_data.FieldMetaData("dateHistogramFacet",
                        org.apache.thrift.TFieldRequirementType.DEFAULT,
                        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT,
                                DateHistogramFacet.class)));
        tmpMap.put(_Fields.TERMS_STATS_FACET,
                new org.apache.thrift.meta_data.FieldMetaData("termsStatsFacet",
                        org.apache.thrift.TFieldRequirementType.DEFAULT,
                        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT,
                                TermsStatsFacet.class)));
        tmpMap.put(_Fields.STATISTICAL_FACET,
                new org.apache.thrift.meta_data.FieldMetaData("statisticalFacet",
                        org.apache.thrift.TFieldRequirementType.DEFAULT,
                        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT,
                                StatisticalFacet.class)));
        tmpMap.put(_Fields.TERMS_SCRIPT_FACET,
                new org.apache.thrift.meta_data.FieldMetaData("termsScriptFacet",
                        org.apache.thrift.TFieldRequirementType.DEFAULT,
                        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT,
                                TermsScriptFacet.class)));
        metaDataMap = Collections.unmodifiableMap(tmpMap);
        org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(FacetRequest.class, metaDataMap);
    }

    public FacetRequest() {
        super();
    }

    public FacetRequest(_Fields setField, Object value) {
        super(setField, value);
    }

    public FacetRequest(FacetRequest other) {
        super(other);
    }

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

    public static FacetRequest histogramFacet(HistogramFacet value) {
        FacetRequest x = new FacetRequest();
        x.setHistogramFacet(value);
        return x;
    }

    public static FacetRequest rangeFacet(RangeFacet value) {
        FacetRequest x = new FacetRequest();
        x.setRangeFacet(value);
        return x;
    }

    public static FacetRequest filterFacet(FilterFacet value) {
        FacetRequest x = new FacetRequest();
        x.setFilterFacet(value);
        return x;
    }

    public static FacetRequest termsFacet(TermsFacet value) {
        FacetRequest x = new FacetRequest();
        x.setTermsFacet(value);
        return x;
    }

    public static FacetRequest dateHistogramFacet(DateHistogramFacet value) {
        FacetRequest x = new FacetRequest();
        x.setDateHistogramFacet(value);
        return x;
    }

    public static FacetRequest termsStatsFacet(TermsStatsFacet value) {
        FacetRequest x = new FacetRequest();
        x.setTermsStatsFacet(value);
        return x;
    }

    public static FacetRequest statisticalFacet(StatisticalFacet value) {
        FacetRequest x = new FacetRequest();
        x.setStatisticalFacet(value);
        return x;
    }

    public static FacetRequest termsScriptFacet(TermsScriptFacet value) {
        FacetRequest x = new FacetRequest();
        x.setTermsScriptFacet(value);
        return x;
    }

    @Override
    protected void checkType(_Fields setField, Object value) throws ClassCastException {
        switch (setField) {
        case HISTOGRAM_FACET:
            if (value instanceof HistogramFacet) {
                break;
            }
            throw new ClassCastException(
                    "Was expecting value of type HistogramFacet for field 'histogramFacet', but got "
                            + value.getClass().getSimpleName());
        case RANGE_FACET:
            if (value instanceof RangeFacet) {
                break;
            }
            throw new ClassCastException("Was expecting value of type RangeFacet for field 'rangeFacet', but got "
                    + value.getClass().getSimpleName());
        case FILTER_FACET:
            if (value instanceof FilterFacet) {
                break;
            }
            throw new ClassCastException("Was expecting value of type FilterFacet for field 'filterFacet', but got "
                    + value.getClass().getSimpleName());
        case TERMS_FACET:
            if (value instanceof TermsFacet) {
                break;
            }
            throw new ClassCastException("Was expecting value of type TermsFacet for field 'termsFacet', but got "
                    + value.getClass().getSimpleName());
        case DATE_HISTOGRAM_FACET:
            if (value instanceof DateHistogramFacet) {
                break;
            }
            throw new ClassCastException(
                    "Was expecting value of type DateHistogramFacet for field 'dateHistogramFacet', but got "
                            + value.getClass().getSimpleName());
        case TERMS_STATS_FACET:
            if (value instanceof TermsStatsFacet) {
                break;
            }
            throw new ClassCastException(
                    "Was expecting value of type TermsStatsFacet for field 'termsStatsFacet', but got "
                            + value.getClass().getSimpleName());
        case STATISTICAL_FACET:
            if (value instanceof StatisticalFacet) {
                break;
            }
            throw new ClassCastException(
                    "Was expecting value of type StatisticalFacet for field 'statisticalFacet', but got "
                            + value.getClass().getSimpleName());
        case TERMS_SCRIPT_FACET:
            if (value instanceof TermsScriptFacet) {
                break;
            }
            throw new ClassCastException(
                    "Was expecting value of type TermsScriptFacet for field 'termsScriptFacet', but got "
                            + value.getClass().getSimpleName());
        default:
            throw new IllegalArgumentException("Unknown field id " + setField);
        }
    }

    @Override
    protected Object standardSchemeReadValue(org.apache.thrift.protocol.TProtocol iprot,
            org.apache.thrift.protocol.TField field) throws org.apache.thrift.TException {
        _Fields setField = _Fields.findByThriftId(field.id);
        if (setField != null) {
            switch (setField) {
            case HISTOGRAM_FACET:
                if (field.type == HISTOGRAM_FACET_FIELD_DESC.type) {
                    HistogramFacet histogramFacet;
                    histogramFacet = new HistogramFacet();
                    histogramFacet.read(iprot);
                    return histogramFacet;
                } else {
                    org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
                    return null;
                }
            case RANGE_FACET:
                if (field.type == RANGE_FACET_FIELD_DESC.type) {
                    RangeFacet rangeFacet;
                    rangeFacet = new RangeFacet();
                    rangeFacet.read(iprot);
                    return rangeFacet;
                } else {
                    org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
                    return null;
                }
            case FILTER_FACET:
                if (field.type == FILTER_FACET_FIELD_DESC.type) {
                    FilterFacet filterFacet;
                    filterFacet = new FilterFacet();
                    filterFacet.read(iprot);
                    return filterFacet;
                } else {
                    org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
                    return null;
                }
            case TERMS_FACET:
                if (field.type == TERMS_FACET_FIELD_DESC.type) {
                    TermsFacet termsFacet;
                    termsFacet = new TermsFacet();
                    termsFacet.read(iprot);
                    return termsFacet;
                } else {
                    org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
                    return null;
                }
            case DATE_HISTOGRAM_FACET:
                if (field.type == DATE_HISTOGRAM_FACET_FIELD_DESC.type) {
                    DateHistogramFacet dateHistogramFacet;
                    dateHistogramFacet = new DateHistogramFacet();
                    dateHistogramFacet.read(iprot);
                    return dateHistogramFacet;
                } else {
                    org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
                    return null;
                }
            case TERMS_STATS_FACET:
                if (field.type == TERMS_STATS_FACET_FIELD_DESC.type) {
                    TermsStatsFacet termsStatsFacet;
                    termsStatsFacet = new TermsStatsFacet();
                    termsStatsFacet.read(iprot);
                    return termsStatsFacet;
                } else {
                    org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
                    return null;
                }
            case STATISTICAL_FACET:
                if (field.type == STATISTICAL_FACET_FIELD_DESC.type) {
                    StatisticalFacet statisticalFacet;
                    statisticalFacet = new StatisticalFacet();
                    statisticalFacet.read(iprot);
                    return statisticalFacet;
                } else {
                    org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
                    return null;
                }
            case TERMS_SCRIPT_FACET:
                if (field.type == TERMS_SCRIPT_FACET_FIELD_DESC.type) {
                    TermsScriptFacet termsScriptFacet;
                    termsScriptFacet = new TermsScriptFacet();
                    termsScriptFacet.read(iprot);
                    return termsScriptFacet;
                } else {
                    org.apache.thrift.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 {
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
            return null;
        }
    }

    @Override
    protected void standardSchemeWriteValue(org.apache.thrift.protocol.TProtocol oprot)
            throws org.apache.thrift.TException {
        switch (setField_) {
        case HISTOGRAM_FACET:
            HistogramFacet histogramFacet = (HistogramFacet) value_;
            histogramFacet.write(oprot);
            return;
        case RANGE_FACET:
            RangeFacet rangeFacet = (RangeFacet) value_;
            rangeFacet.write(oprot);
            return;
        case FILTER_FACET:
            FilterFacet filterFacet = (FilterFacet) value_;
            filterFacet.write(oprot);
            return;
        case TERMS_FACET:
            TermsFacet termsFacet = (TermsFacet) value_;
            termsFacet.write(oprot);
            return;
        case DATE_HISTOGRAM_FACET:
            DateHistogramFacet dateHistogramFacet = (DateHistogramFacet) value_;
            dateHistogramFacet.write(oprot);
            return;
        case TERMS_STATS_FACET:
            TermsStatsFacet termsStatsFacet = (TermsStatsFacet) value_;
            termsStatsFacet.write(oprot);
            return;
        case STATISTICAL_FACET:
            StatisticalFacet statisticalFacet = (StatisticalFacet) value_;
            statisticalFacet.write(oprot);
            return;
        case TERMS_SCRIPT_FACET:
            TermsScriptFacet termsScriptFacet = (TermsScriptFacet) value_;
            termsScriptFacet.write(oprot);
            return;
        default:
            throw new IllegalStateException("Cannot write union with unknown field " + setField_);
        }
    }

    @Override
    protected Object tupleSchemeReadValue(org.apache.thrift.protocol.TProtocol iprot, short fieldID)
            throws org.apache.thrift.TException {
        _Fields setField = _Fields.findByThriftId(fieldID);
        if (setField != null) {
            switch (setField) {
            case HISTOGRAM_FACET:
                HistogramFacet histogramFacet;
                histogramFacet = new HistogramFacet();
                histogramFacet.read(iprot);
                return histogramFacet;
            case RANGE_FACET:
                RangeFacet rangeFacet;
                rangeFacet = new RangeFacet();
                rangeFacet.read(iprot);
                return rangeFacet;
            case FILTER_FACET:
                FilterFacet filterFacet;
                filterFacet = new FilterFacet();
                filterFacet.read(iprot);
                return filterFacet;
            case TERMS_FACET:
                TermsFacet termsFacet;
                termsFacet = new TermsFacet();
                termsFacet.read(iprot);
                return termsFacet;
            case DATE_HISTOGRAM_FACET:
                DateHistogramFacet dateHistogramFacet;
                dateHistogramFacet = new DateHistogramFacet();
                dateHistogramFacet.read(iprot);
                return dateHistogramFacet;
            case TERMS_STATS_FACET:
                TermsStatsFacet termsStatsFacet;
                termsStatsFacet = new TermsStatsFacet();
                termsStatsFacet.read(iprot);
                return termsStatsFacet;
            case STATISTICAL_FACET:
                StatisticalFacet statisticalFacet;
                statisticalFacet = new StatisticalFacet();
                statisticalFacet.read(iprot);
                return statisticalFacet;
            case TERMS_SCRIPT_FACET:
                TermsScriptFacet termsScriptFacet;
                termsScriptFacet = new TermsScriptFacet();
                termsScriptFacet.read(iprot);
                return termsScriptFacet;
            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.thrift.protocol.TProtocol oprot)
            throws org.apache.thrift.TException {
        switch (setField_) {
        case HISTOGRAM_FACET:
            HistogramFacet histogramFacet = (HistogramFacet) value_;
            histogramFacet.write(oprot);
            return;
        case RANGE_FACET:
            RangeFacet rangeFacet = (RangeFacet) value_;
            rangeFacet.write(oprot);
            return;
        case FILTER_FACET:
            FilterFacet filterFacet = (FilterFacet) value_;
            filterFacet.write(oprot);
            return;
        case TERMS_FACET:
            TermsFacet termsFacet = (TermsFacet) value_;
            termsFacet.write(oprot);
            return;
        case DATE_HISTOGRAM_FACET:
            DateHistogramFacet dateHistogramFacet = (DateHistogramFacet) value_;
            dateHistogramFacet.write(oprot);
            return;
        case TERMS_STATS_FACET:
            TermsStatsFacet termsStatsFacet = (TermsStatsFacet) value_;
            termsStatsFacet.write(oprot);
            return;
        case STATISTICAL_FACET:
            StatisticalFacet statisticalFacet = (StatisticalFacet) value_;
            statisticalFacet.write(oprot);
            return;
        case TERMS_SCRIPT_FACET:
            TermsScriptFacet termsScriptFacet = (TermsScriptFacet) value_;
            termsScriptFacet.write(oprot);
            return;
        default:
            throw new IllegalStateException("Cannot write union with unknown field " + setField_);
        }
    }

    @Override
    protected org.apache.thrift.protocol.TField getFieldDesc(_Fields setField) {
        switch (setField) {
        case HISTOGRAM_FACET:
            return HISTOGRAM_FACET_FIELD_DESC;
        case RANGE_FACET:
            return RANGE_FACET_FIELD_DESC;
        case FILTER_FACET:
            return FILTER_FACET_FIELD_DESC;
        case TERMS_FACET:
            return TERMS_FACET_FIELD_DESC;
        case DATE_HISTOGRAM_FACET:
            return DATE_HISTOGRAM_FACET_FIELD_DESC;
        case TERMS_STATS_FACET:
            return TERMS_STATS_FACET_FIELD_DESC;
        case STATISTICAL_FACET:
            return STATISTICAL_FACET_FIELD_DESC;
        case TERMS_SCRIPT_FACET:
            return TERMS_SCRIPT_FACET_FIELD_DESC;
        default:
            throw new IllegalArgumentException("Unknown field id " + setField);
        }
    }

    @Override
    protected org.apache.thrift.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 HistogramFacet getHistogramFacet() {
        if (getSetField() == _Fields.HISTOGRAM_FACET) {
            return (HistogramFacet) getFieldValue();
        } else {
            throw new RuntimeException("Cannot get field 'histogramFacet' because union is currently set to "
                    + getFieldDesc(getSetField()).name);
        }
    }

    public void setHistogramFacet(HistogramFacet value) {
        if (value == null)
            throw new NullPointerException();
        setField_ = _Fields.HISTOGRAM_FACET;
        value_ = value;
    }

    public RangeFacet getRangeFacet() {
        if (getSetField() == _Fields.RANGE_FACET) {
            return (RangeFacet) getFieldValue();
        } else {
            throw new RuntimeException("Cannot get field 'rangeFacet' because union is currently set to "
                    + getFieldDesc(getSetField()).name);
        }
    }

    public void setRangeFacet(RangeFacet value) {
        if (value == null)
            throw new NullPointerException();
        setField_ = _Fields.RANGE_FACET;
        value_ = value;
    }

    public FilterFacet getFilterFacet() {
        if (getSetField() == _Fields.FILTER_FACET) {
            return (FilterFacet) getFieldValue();
        } else {
            throw new RuntimeException("Cannot get field 'filterFacet' because union is currently set to "
                    + getFieldDesc(getSetField()).name);
        }
    }

    public void setFilterFacet(FilterFacet value) {
        if (value == null)
            throw new NullPointerException();
        setField_ = _Fields.FILTER_FACET;
        value_ = value;
    }

    public TermsFacet getTermsFacet() {
        if (getSetField() == _Fields.TERMS_FACET) {
            return (TermsFacet) getFieldValue();
        } else {
            throw new RuntimeException("Cannot get field 'termsFacet' because union is currently set to "
                    + getFieldDesc(getSetField()).name);
        }
    }

    public void setTermsFacet(TermsFacet value) {
        if (value == null)
            throw new NullPointerException();
        setField_ = _Fields.TERMS_FACET;
        value_ = value;
    }

    public DateHistogramFacet getDateHistogramFacet() {
        if (getSetField() == _Fields.DATE_HISTOGRAM_FACET) {
            return (DateHistogramFacet) getFieldValue();
        } else {
            throw new RuntimeException("Cannot get field 'dateHistogramFacet' because union is currently set to "
                    + getFieldDesc(getSetField()).name);
        }
    }

    public void setDateHistogramFacet(DateHistogramFacet value) {
        if (value == null)
            throw new NullPointerException();
        setField_ = _Fields.DATE_HISTOGRAM_FACET;
        value_ = value;
    }

    public TermsStatsFacet getTermsStatsFacet() {
        if (getSetField() == _Fields.TERMS_STATS_FACET) {
            return (TermsStatsFacet) getFieldValue();
        } else {
            throw new RuntimeException("Cannot get field 'termsStatsFacet' because union is currently set to "
                    + getFieldDesc(getSetField()).name);
        }
    }

    public void setTermsStatsFacet(TermsStatsFacet value) {
        if (value == null)
            throw new NullPointerException();
        setField_ = _Fields.TERMS_STATS_FACET;
        value_ = value;
    }

    public StatisticalFacet getStatisticalFacet() {
        if (getSetField() == _Fields.STATISTICAL_FACET) {
            return (StatisticalFacet) getFieldValue();
        } else {
            throw new RuntimeException("Cannot get field 'statisticalFacet' because union is currently set to "
                    + getFieldDesc(getSetField()).name);
        }
    }

    public void setStatisticalFacet(StatisticalFacet value) {
        if (value == null)
            throw new NullPointerException();
        setField_ = _Fields.STATISTICAL_FACET;
        value_ = value;
    }

    public TermsScriptFacet getTermsScriptFacet() {
        if (getSetField() == _Fields.TERMS_SCRIPT_FACET) {
            return (TermsScriptFacet) getFieldValue();
        } else {
            throw new RuntimeException("Cannot get field 'termsScriptFacet' because union is currently set to "
                    + getFieldDesc(getSetField()).name);
        }
    }

    public void setTermsScriptFacet(TermsScriptFacet value) {
        if (value == null)
            throw new NullPointerException();
        setField_ = _Fields.TERMS_SCRIPT_FACET;
        value_ = value;
    }

    public boolean isSetHistogramFacet() {
        return setField_ == _Fields.HISTOGRAM_FACET;
    }

    public boolean isSetRangeFacet() {
        return setField_ == _Fields.RANGE_FACET;
    }

    public boolean isSetFilterFacet() {
        return setField_ == _Fields.FILTER_FACET;
    }

    public boolean isSetTermsFacet() {
        return setField_ == _Fields.TERMS_FACET;
    }

    public boolean isSetDateHistogramFacet() {
        return setField_ == _Fields.DATE_HISTOGRAM_FACET;
    }

    public boolean isSetTermsStatsFacet() {
        return setField_ == _Fields.TERMS_STATS_FACET;
    }

    public boolean isSetStatisticalFacet() {
        return setField_ == _Fields.STATISTICAL_FACET;
    }

    public boolean isSetTermsScriptFacet() {
        return setField_ == _Fields.TERMS_SCRIPT_FACET;
    }

    public boolean equals(Object other) {
        if (other instanceof FacetRequest) {
            return equals((FacetRequest) other);
        } else {
            return false;
        }
    }

    public boolean equals(FacetRequest other) {
        return other != null && getSetField() == other.getSetField()
                && getFieldValue().equals(other.getFieldValue());
    }

    @Override
    public int compareTo(FacetRequest other) {
        int lastComparison = org.apache.thrift.TBaseHelper.compareTo(getSetField(), other.getSetField());
        if (lastComparison == 0) {
            return org.apache.thrift.TBaseHelper.compareTo(getFieldValue(), other.getFieldValue());
        }
        return lastComparison;
    }

    @Override
    public int hashCode() {
        HashCodeBuilder hcb = new HashCodeBuilder();
        hcb.append(this.getClass().getName());
        org.apache.thrift.TFieldIdEnum setField = getSetField();
        if (setField != null) {
            hcb.append(setField.getThriftFieldId());
            Object value = getFieldValue();
            if (value instanceof org.apache.thrift.TEnum) {
                hcb.append(((org.apache.thrift.TEnum) getFieldValue()).getValue());
            } else {
                hcb.append(value);
            }
        }
        return hcb.toHashCode();
    }

    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);
        }
    }

}