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

Java tutorial

Introduction

Here is the source code for ezbake.data.elastic.thrift.FieldSort.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;

/**
 * Defines a lexicographic sort on a given field
 */
public class FieldSort implements org.apache.thrift.TBase<FieldSort, FieldSort._Fields>, java.io.Serializable,
        Cloneable, Comparable<FieldSort> {
    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct(
            "FieldSort");

    private static final org.apache.thrift.protocol.TField FIELD_FIELD_DESC = new org.apache.thrift.protocol.TField(
            "field", org.apache.thrift.protocol.TType.STRING, (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 MODE_FIELD_DESC = new org.apache.thrift.protocol.TField(
            "mode", org.apache.thrift.protocol.TType.I32, (short) 3);
    private static final org.apache.thrift.protocol.TField MISSING_FIELD_DESC = new org.apache.thrift.protocol.TField(
            "missing", org.apache.thrift.protocol.TType.STRUCT, (short) 4);
    private static final org.apache.thrift.protocol.TField IGNORE_UNMAPPED_FIELD_DESC = new org.apache.thrift.protocol.TField(
            "ignoreUnmapped", org.apache.thrift.protocol.TType.BOOL, (short) 5);

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

    /**
     * The name of the field to sort on
     */
    public String field; // required
    /**
     * The order to sort
     * 
     * @see SortOrder
     */
    public SortOrder order; // required
    /**
     * The sorting mode for array/multi-value fields
     * 
     * @see SortMode
     */
    public SortMode mode; // optional
    /**
     * What to do with missing values
     */
    public MissingSort missing; // optional
    /**
     * If true ES will ignore sorting fields that are not mapped on the type
     */
    public boolean ignoreUnmapped; // 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 {
        /**
         * The name of the field to sort on
         */
        FIELD((short) 1, "field"),
        /**
         * The order to sort
         * 
         * @see SortOrder
         */
        ORDER((short) 2, "order"),
        /**
         * The sorting mode for array/multi-value fields
         * 
         * @see SortMode
         */
        MODE((short) 3, "mode"),
        /**
         * What to do with missing values
         */
        MISSING((short) 4, "missing"),
        /**
         * If true ES will ignore sorting fields that are not mapped on the type
         */
        IGNORE_UNMAPPED((short) 5, "ignoreUnmapped");

        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: // FIELD
                return FIELD;
            case 2: // ORDER
                return ORDER;
            case 3: // MODE
                return MODE;
            case 4: // MISSING
                return MISSING;
            case 5: // IGNORE_UNMAPPED
                return IGNORE_UNMAPPED;
            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 __IGNOREUNMAPPED_ISSET_ID = 0;
    private byte __isset_bitfield = 0;
    private _Fields optionals[] = { _Fields.MODE, _Fields.MISSING, _Fields.IGNORE_UNMAPPED };
    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.FIELD, new org.apache.thrift.meta_data.FieldMetaData("field",
                org.apache.thrift.TFieldRequirementType.REQUIRED,
                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.REQUIRED,
                        new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM,
                                SortOrder.class)));
        tmpMap.put(_Fields.MODE,
                new org.apache.thrift.meta_data.FieldMetaData("mode",
                        org.apache.thrift.TFieldRequirementType.OPTIONAL,
                        new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM,
                                SortMode.class)));
        tmpMap.put(_Fields.MISSING,
                new org.apache.thrift.meta_data.FieldMetaData("missing",
                        org.apache.thrift.TFieldRequirementType.OPTIONAL,
                        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT,
                                MissingSort.class)));
        tmpMap.put(_Fields.IGNORE_UNMAPPED,
                new org.apache.thrift.meta_data.FieldMetaData("ignoreUnmapped",
                        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(FieldSort.class, metaDataMap);
    }

    public FieldSort() {
    }

    public FieldSort(String field, SortOrder order) {
        this();
        this.field = field;
        this.order = order;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public FieldSort(FieldSort other) {
        __isset_bitfield = other.__isset_bitfield;
        if (other.isSetField()) {
            this.field = other.field;
        }
        if (other.isSetOrder()) {
            this.order = other.order;
        }
        if (other.isSetMode()) {
            this.mode = other.mode;
        }
        if (other.isSetMissing()) {
            this.missing = new MissingSort(other.missing);
        }
        this.ignoreUnmapped = other.ignoreUnmapped;
    }

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

    @Override
    public void clear() {
        this.field = null;
        this.order = null;
        this.mode = null;
        this.missing = null;
        setIgnoreUnmappedIsSet(false);
        this.ignoreUnmapped = false;
    }

    /**
     * The name of the field to sort on
     */
    public String getField() {
        return this.field;
    }

    /**
     * The name of the field to sort on
     */
    public FieldSort setField(String field) {
        this.field = field;
        return this;
    }

    public void unsetField() {
        this.field = null;
    }

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

    public void setFieldIsSet(boolean value) {
        if (!value) {
            this.field = null;
        }
    }

    /**
     * The order to sort
     * 
     * @see SortOrder
     */
    public SortOrder getOrder() {
        return this.order;
    }

    /**
     * The order to sort
     * 
     * @see SortOrder
     */
    public FieldSort setOrder(SortOrder 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;
        }
    }

    /**
     * The sorting mode for array/multi-value fields
     * 
     * @see SortMode
     */
    public SortMode getMode() {
        return this.mode;
    }

    /**
     * The sorting mode for array/multi-value fields
     * 
     * @see SortMode
     */
    public FieldSort setMode(SortMode mode) {
        this.mode = mode;
        return this;
    }

    public void unsetMode() {
        this.mode = null;
    }

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

    public void setModeIsSet(boolean value) {
        if (!value) {
            this.mode = null;
        }
    }

    /**
     * What to do with missing values
     */
    public MissingSort getMissing() {
        return this.missing;
    }

    /**
     * What to do with missing values
     */
    public FieldSort setMissing(MissingSort missing) {
        this.missing = missing;
        return this;
    }

    public void unsetMissing() {
        this.missing = null;
    }

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

    public void setMissingIsSet(boolean value) {
        if (!value) {
            this.missing = null;
        }
    }

    /**
     * If true ES will ignore sorting fields that are not mapped on the type
     */
    public boolean isIgnoreUnmapped() {
        return this.ignoreUnmapped;
    }

    /**
     * If true ES will ignore sorting fields that are not mapped on the type
     */
    public FieldSort setIgnoreUnmapped(boolean ignoreUnmapped) {
        this.ignoreUnmapped = ignoreUnmapped;
        setIgnoreUnmappedIsSet(true);
        return this;
    }

    public void unsetIgnoreUnmapped() {
        __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __IGNOREUNMAPPED_ISSET_ID);
    }

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

    public void setIgnoreUnmappedIsSet(boolean value) {
        __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __IGNOREUNMAPPED_ISSET_ID, value);
    }

    public void setFieldValue(_Fields field, Object value) {
        switch (field) {
        case FIELD:
            if (value == null) {
                unsetField();
            } else {
                setField((String) value);
            }
            break;

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

        case MODE:
            if (value == null) {
                unsetMode();
            } else {
                setMode((SortMode) value);
            }
            break;

        case MISSING:
            if (value == null) {
                unsetMissing();
            } else {
                setMissing((MissingSort) value);
            }
            break;

        case IGNORE_UNMAPPED:
            if (value == null) {
                unsetIgnoreUnmapped();
            } else {
                setIgnoreUnmapped((Boolean) value);
            }
            break;

        }
    }

    public Object getFieldValue(_Fields field) {
        switch (field) {
        case FIELD:
            return getField();

        case ORDER:
            return getOrder();

        case MODE:
            return getMode();

        case MISSING:
            return getMissing();

        case IGNORE_UNMAPPED:
            return Boolean.valueOf(isIgnoreUnmapped());

        }
        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 FIELD:
            return isSetField();
        case ORDER:
            return isSetOrder();
        case MODE:
            return isSetMode();
        case MISSING:
            return isSetMissing();
        case IGNORE_UNMAPPED:
            return isSetIgnoreUnmapped();
        }
        throw new IllegalStateException();
    }

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

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

        boolean this_present_field = true && this.isSetField();
        boolean that_present_field = true && that.isSetField();
        if (this_present_field || that_present_field) {
            if (!(this_present_field && that_present_field))
                return false;
            if (!this.field.equals(that.field))
                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_mode = true && this.isSetMode();
        boolean that_present_mode = true && that.isSetMode();
        if (this_present_mode || that_present_mode) {
            if (!(this_present_mode && that_present_mode))
                return false;
            if (!this.mode.equals(that.mode))
                return false;
        }

        boolean this_present_missing = true && this.isSetMissing();
        boolean that_present_missing = true && that.isSetMissing();
        if (this_present_missing || that_present_missing) {
            if (!(this_present_missing && that_present_missing))
                return false;
            if (!this.missing.equals(that.missing))
                return false;
        }

        boolean this_present_ignoreUnmapped = true && this.isSetIgnoreUnmapped();
        boolean that_present_ignoreUnmapped = true && that.isSetIgnoreUnmapped();
        if (this_present_ignoreUnmapped || that_present_ignoreUnmapped) {
            if (!(this_present_ignoreUnmapped && that_present_ignoreUnmapped))
                return false;
            if (this.ignoreUnmapped != that.ignoreUnmapped)
                return false;
        }

        return true;
    }

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

        boolean present_field = true && (isSetField());
        builder.append(present_field);
        if (present_field)
            builder.append(field);

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

        boolean present_mode = true && (isSetMode());
        builder.append(present_mode);
        if (present_mode)
            builder.append(mode.getValue());

        boolean present_missing = true && (isSetMissing());
        builder.append(present_missing);
        if (present_missing)
            builder.append(missing);

        boolean present_ignoreUnmapped = true && (isSetIgnoreUnmapped());
        builder.append(present_ignoreUnmapped);
        if (present_ignoreUnmapped)
            builder.append(ignoreUnmapped);

        return builder.toHashCode();
    }

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

        int lastComparison = 0;

        lastComparison = Boolean.valueOf(isSetField()).compareTo(other.isSetField());
        if (lastComparison != 0) {
            return lastComparison;
        }
        if (isSetField()) {
            lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.field, other.field);
            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(isSetMode()).compareTo(other.isSetMode());
        if (lastComparison != 0) {
            return lastComparison;
        }
        if (isSetMode()) {
            lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.mode, other.mode);
            if (lastComparison != 0) {
                return lastComparison;
            }
        }
        lastComparison = Boolean.valueOf(isSetMissing()).compareTo(other.isSetMissing());
        if (lastComparison != 0) {
            return lastComparison;
        }
        if (isSetMissing()) {
            lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.missing, other.missing);
            if (lastComparison != 0) {
                return lastComparison;
            }
        }
        lastComparison = Boolean.valueOf(isSetIgnoreUnmapped()).compareTo(other.isSetIgnoreUnmapped());
        if (lastComparison != 0) {
            return lastComparison;
        }
        if (isSetIgnoreUnmapped()) {
            lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.ignoreUnmapped, other.ignoreUnmapped);
            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("FieldSort(");
        boolean first = true;

        sb.append("field:");
        if (this.field == null) {
            sb.append("null");
        } else {
            sb.append(this.field);
        }
        first = false;
        if (!first)
            sb.append(", ");
        sb.append("order:");
        if (this.order == null) {
            sb.append("null");
        } else {
            sb.append(this.order);
        }
        first = false;
        if (isSetMode()) {
            if (!first)
                sb.append(", ");
            sb.append("mode:");
            if (this.mode == null) {
                sb.append("null");
            } else {
                sb.append(this.mode);
            }
            first = false;
        }
        if (isSetMissing()) {
            if (!first)
                sb.append(", ");
            sb.append("missing:");
            if (this.missing == null) {
                sb.append("null");
            } else {
                sb.append(this.missing);
            }
            first = false;
        }
        if (isSetIgnoreUnmapped()) {
            if (!first)
                sb.append(", ");
            sb.append("ignoreUnmapped:");
            sb.append(this.ignoreUnmapped);
            first = false;
        }
        sb.append(")");
        return sb.toString();
    }

    public void validate() throws org.apache.thrift.TException {
        // check for required fields
        if (field == null) {
            throw new org.apache.thrift.protocol.TProtocolException(
                    "Required field 'field' was not present! Struct: " + toString());
        }
        if (order == null) {
            throw new org.apache.thrift.protocol.TProtocolException(
                    "Required field 'order' 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 FieldSortStandardSchemeFactory implements SchemeFactory {
        public FieldSortStandardScheme getScheme() {
            return new FieldSortStandardScheme();
        }
    }

    private static class FieldSortStandardScheme extends StandardScheme<FieldSort> {

        public void read(org.apache.thrift.protocol.TProtocol iprot, FieldSort 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: // FIELD
                    if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
                        struct.field = iprot.readString();
                        struct.setFieldIsSet(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 = SortOrder.findByValue(iprot.readI32());
                        struct.setOrderIsSet(true);
                    } else {
                        org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
                    }
                    break;
                case 3: // MODE
                    if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
                        struct.mode = SortMode.findByValue(iprot.readI32());
                        struct.setModeIsSet(true);
                    } else {
                        org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
                    }
                    break;
                case 4: // MISSING
                    if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
                        struct.missing = new MissingSort();
                        struct.missing.read(iprot);
                        struct.setMissingIsSet(true);
                    } else {
                        org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
                    }
                    break;
                case 5: // IGNORE_UNMAPPED
                    if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
                        struct.ignoreUnmapped = iprot.readBool();
                        struct.setIgnoreUnmappedIsSet(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, FieldSort struct)
                throws org.apache.thrift.TException {
            struct.validate();

            oprot.writeStructBegin(STRUCT_DESC);
            if (struct.field != null) {
                oprot.writeFieldBegin(FIELD_FIELD_DESC);
                oprot.writeString(struct.field);
                oprot.writeFieldEnd();
            }
            if (struct.order != null) {
                oprot.writeFieldBegin(ORDER_FIELD_DESC);
                oprot.writeI32(struct.order.getValue());
                oprot.writeFieldEnd();
            }
            if (struct.mode != null) {
                if (struct.isSetMode()) {
                    oprot.writeFieldBegin(MODE_FIELD_DESC);
                    oprot.writeI32(struct.mode.getValue());
                    oprot.writeFieldEnd();
                }
            }
            if (struct.missing != null) {
                if (struct.isSetMissing()) {
                    oprot.writeFieldBegin(MISSING_FIELD_DESC);
                    struct.missing.write(oprot);
                    oprot.writeFieldEnd();
                }
            }
            if (struct.isSetIgnoreUnmapped()) {
                oprot.writeFieldBegin(IGNORE_UNMAPPED_FIELD_DESC);
                oprot.writeBool(struct.ignoreUnmapped);
                oprot.writeFieldEnd();
            }
            oprot.writeFieldStop();
            oprot.writeStructEnd();
        }

    }

    private static class FieldSortTupleSchemeFactory implements SchemeFactory {
        public FieldSortTupleScheme getScheme() {
            return new FieldSortTupleScheme();
        }
    }

    private static class FieldSortTupleScheme extends TupleScheme<FieldSort> {

        @Override
        public void write(org.apache.thrift.protocol.TProtocol prot, FieldSort struct)
                throws org.apache.thrift.TException {
            TTupleProtocol oprot = (TTupleProtocol) prot;
            oprot.writeString(struct.field);
            oprot.writeI32(struct.order.getValue());
            BitSet optionals = new BitSet();
            if (struct.isSetMode()) {
                optionals.set(0);
            }
            if (struct.isSetMissing()) {
                optionals.set(1);
            }
            if (struct.isSetIgnoreUnmapped()) {
                optionals.set(2);
            }
            oprot.writeBitSet(optionals, 3);
            if (struct.isSetMode()) {
                oprot.writeI32(struct.mode.getValue());
            }
            if (struct.isSetMissing()) {
                struct.missing.write(oprot);
            }
            if (struct.isSetIgnoreUnmapped()) {
                oprot.writeBool(struct.ignoreUnmapped);
            }
        }

        @Override
        public void read(org.apache.thrift.protocol.TProtocol prot, FieldSort struct)
                throws org.apache.thrift.TException {
            TTupleProtocol iprot = (TTupleProtocol) prot;
            struct.field = iprot.readString();
            struct.setFieldIsSet(true);
            struct.order = SortOrder.findByValue(iprot.readI32());
            struct.setOrderIsSet(true);
            BitSet incoming = iprot.readBitSet(3);
            if (incoming.get(0)) {
                struct.mode = SortMode.findByValue(iprot.readI32());
                struct.setModeIsSet(true);
            }
            if (incoming.get(1)) {
                struct.missing = new MissingSort();
                struct.missing.read(iprot);
                struct.setMissingIsSet(true);
            }
            if (incoming.get(2)) {
                struct.ignoreUnmapped = iprot.readBool();
                struct.setIgnoreUnmappedIsSet(true);
            }
        }
    }

}