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

Java tutorial

Introduction

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

/**
 * A document to insert
 */
public class Document implements org.apache.thrift.TBase<Document, Document._Fields>, java.io.Serializable,
        Cloneable, Comparable<Document> {
    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct(
            "Document");

    private static final org.apache.thrift.protocol.TField _TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField(
            "_type", org.apache.thrift.protocol.TType.STRING, (short) 1);
    private static final org.apache.thrift.protocol.TField VISIBILITY_FIELD_DESC = new org.apache.thrift.protocol.TField(
            "visibility", org.apache.thrift.protocol.TType.STRUCT, (short) 2);
    private static final org.apache.thrift.protocol.TField _JSON_OBJECT_FIELD_DESC = new org.apache.thrift.protocol.TField(
            "_jsonObject", org.apache.thrift.protocol.TType.STRING, (short) 3);
    private static final org.apache.thrift.protocol.TField _VERSION_FIELD_DESC = new org.apache.thrift.protocol.TField(
            "_version", org.apache.thrift.protocol.TType.I64, (short) 4);
    private static final org.apache.thrift.protocol.TField _ID_FIELD_DESC = new org.apache.thrift.protocol.TField(
            "_id", org.apache.thrift.protocol.TType.STRING, (short) 5);
    private static final org.apache.thrift.protocol.TField PERCOLATE_FIELD_DESC = new org.apache.thrift.protocol.TField(
            "percolate", org.apache.thrift.protocol.TType.STRUCT, (short) 6);

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

    /**
     * Elastic type to search
     */
    public String _type; // required
    /**
     * Visibility to control who has access to this document
     */
    public ezbake.base.thrift.Visibility visibility; // required
    /**
     * JSON of document
     */
    public String _jsonObject; // required
    /**
     * Elastic Version ID
     */
    public long _version; // optional
    /**
     * Elastic document ID
     */
    public String _id; // optional
    /**
     * Percolate request
     */
    public PercolateRequest percolate; // 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 {
        /**
         * Elastic type to search
         */
        _TYPE((short) 1, "_type"),
        /**
         * Visibility to control who has access to this document
         */
        VISIBILITY((short) 2, "visibility"),
        /**
         * JSON of document
         */
        _JSON_OBJECT((short) 3, "_jsonObject"),
        /**
         * Elastic Version ID
         */
        _VERSION((short) 4, "_version"),
        /**
         * Elastic document ID
         */
        _ID((short) 5, "_id"),
        /**
         * Percolate request
         */
        PERCOLATE((short) 6, "percolate");

        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: // _TYPE
                return _TYPE;
            case 2: // VISIBILITY
                return VISIBILITY;
            case 3: // _JSON_OBJECT
                return _JSON_OBJECT;
            case 4: // _VERSION
                return _VERSION;
            case 5: // _ID
                return _ID;
            case 6: // PERCOLATE
                return PERCOLATE;
            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 ___VERSION_ISSET_ID = 0;
    private byte __isset_bitfield = 0;
    private _Fields optionals[] = { _Fields._VERSION, _Fields._ID, _Fields.PERCOLATE };
    public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
    static {
        Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(
                _Fields.class);
        tmpMap.put(_Fields._TYPE, new org.apache.thrift.meta_data.FieldMetaData("_type",
                org.apache.thrift.TFieldRequirementType.REQUIRED,
                new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
        tmpMap.put(_Fields.VISIBILITY,
                new org.apache.thrift.meta_data.FieldMetaData("visibility",
                        org.apache.thrift.TFieldRequirementType.REQUIRED,
                        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT,
                                ezbake.base.thrift.Visibility.class)));
        tmpMap.put(_Fields._JSON_OBJECT, new org.apache.thrift.meta_data.FieldMetaData("_jsonObject",
                org.apache.thrift.TFieldRequirementType.REQUIRED,
                new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
        tmpMap.put(_Fields._VERSION,
                new org.apache.thrift.meta_data.FieldMetaData("_version",
                        org.apache.thrift.TFieldRequirementType.OPTIONAL,
                        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
        tmpMap.put(_Fields._ID, new org.apache.thrift.meta_data.FieldMetaData("_id",
                org.apache.thrift.TFieldRequirementType.OPTIONAL,
                new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
        tmpMap.put(_Fields.PERCOLATE,
                new org.apache.thrift.meta_data.FieldMetaData("percolate",
                        org.apache.thrift.TFieldRequirementType.OPTIONAL,
                        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT,
                                PercolateRequest.class)));
        metaDataMap = Collections.unmodifiableMap(tmpMap);
        org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Document.class, metaDataMap);
    }

    public Document() {
    }

    public Document(String _type, ezbake.base.thrift.Visibility visibility, String _jsonObject) {
        this();
        this._type = _type;
        this.visibility = visibility;
        this._jsonObject = _jsonObject;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public Document(Document other) {
        __isset_bitfield = other.__isset_bitfield;
        if (other.isSet_type()) {
            this._type = other._type;
        }
        if (other.isSetVisibility()) {
            this.visibility = new ezbake.base.thrift.Visibility(other.visibility);
        }
        if (other.isSet_jsonObject()) {
            this._jsonObject = other._jsonObject;
        }
        this._version = other._version;
        if (other.isSet_id()) {
            this._id = other._id;
        }
        if (other.isSetPercolate()) {
            this.percolate = new PercolateRequest(other.percolate);
        }
    }

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

    @Override
    public void clear() {
        this._type = null;
        this.visibility = null;
        this._jsonObject = null;
        set_versionIsSet(false);
        this._version = 0;
        this._id = null;
        this.percolate = null;
    }

    /**
     * Elastic type to search
     */
    public String get_type() {
        return this._type;
    }

    /**
     * Elastic type to search
     */
    public Document set_type(String _type) {
        this._type = _type;
        return this;
    }

    public void unset_type() {
        this._type = null;
    }

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

    public void set_typeIsSet(boolean value) {
        if (!value) {
            this._type = null;
        }
    }

    /**
     * Visibility to control who has access to this document
     */
    public ezbake.base.thrift.Visibility getVisibility() {
        return this.visibility;
    }

    /**
     * Visibility to control who has access to this document
     */
    public Document setVisibility(ezbake.base.thrift.Visibility visibility) {
        this.visibility = visibility;
        return this;
    }

    public void unsetVisibility() {
        this.visibility = null;
    }

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

    public void setVisibilityIsSet(boolean value) {
        if (!value) {
            this.visibility = null;
        }
    }

    /**
     * JSON of document
     */
    public String get_jsonObject() {
        return this._jsonObject;
    }

    /**
     * JSON of document
     */
    public Document set_jsonObject(String _jsonObject) {
        this._jsonObject = _jsonObject;
        return this;
    }

    public void unset_jsonObject() {
        this._jsonObject = null;
    }

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

    public void set_jsonObjectIsSet(boolean value) {
        if (!value) {
            this._jsonObject = null;
        }
    }

    /**
     * Elastic Version ID
     */
    public long get_version() {
        return this._version;
    }

    /**
     * Elastic Version ID
     */
    public Document set_version(long _version) {
        this._version = _version;
        set_versionIsSet(true);
        return this;
    }

    public void unset_version() {
        __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, ___VERSION_ISSET_ID);
    }

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

    public void set_versionIsSet(boolean value) {
        __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, ___VERSION_ISSET_ID, value);
    }

    /**
     * Elastic document ID
     */
    public String get_id() {
        return this._id;
    }

    /**
     * Elastic document ID
     */
    public Document set_id(String _id) {
        this._id = _id;
        return this;
    }

    public void unset_id() {
        this._id = null;
    }

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

    public void set_idIsSet(boolean value) {
        if (!value) {
            this._id = null;
        }
    }

    /**
     * Percolate request
     */
    public PercolateRequest getPercolate() {
        return this.percolate;
    }

    /**
     * Percolate request
     */
    public Document setPercolate(PercolateRequest percolate) {
        this.percolate = percolate;
        return this;
    }

    public void unsetPercolate() {
        this.percolate = null;
    }

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

    public void setPercolateIsSet(boolean value) {
        if (!value) {
            this.percolate = null;
        }
    }

    public void setFieldValue(_Fields field, Object value) {
        switch (field) {
        case _TYPE:
            if (value == null) {
                unset_type();
            } else {
                set_type((String) value);
            }
            break;

        case VISIBILITY:
            if (value == null) {
                unsetVisibility();
            } else {
                setVisibility((ezbake.base.thrift.Visibility) value);
            }
            break;

        case _JSON_OBJECT:
            if (value == null) {
                unset_jsonObject();
            } else {
                set_jsonObject((String) value);
            }
            break;

        case _VERSION:
            if (value == null) {
                unset_version();
            } else {
                set_version((Long) value);
            }
            break;

        case _ID:
            if (value == null) {
                unset_id();
            } else {
                set_id((String) value);
            }
            break;

        case PERCOLATE:
            if (value == null) {
                unsetPercolate();
            } else {
                setPercolate((PercolateRequest) value);
            }
            break;

        }
    }

    public Object getFieldValue(_Fields field) {
        switch (field) {
        case _TYPE:
            return get_type();

        case VISIBILITY:
            return getVisibility();

        case _JSON_OBJECT:
            return get_jsonObject();

        case _VERSION:
            return Long.valueOf(get_version());

        case _ID:
            return get_id();

        case PERCOLATE:
            return getPercolate();

        }
        throw new IllegalStateException();
    }

    /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
    public boolean isSet(_Fields field) {
        if (field == null) {
            throw new IllegalArgumentException();
        }

        switch (field) {
        case _TYPE:
            return isSet_type();
        case VISIBILITY:
            return isSetVisibility();
        case _JSON_OBJECT:
            return isSet_jsonObject();
        case _VERSION:
            return isSet_version();
        case _ID:
            return isSet_id();
        case PERCOLATE:
            return isSetPercolate();
        }
        throw new IllegalStateException();
    }

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

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

        boolean this_present__type = true && this.isSet_type();
        boolean that_present__type = true && that.isSet_type();
        if (this_present__type || that_present__type) {
            if (!(this_present__type && that_present__type))
                return false;
            if (!this._type.equals(that._type))
                return false;
        }

        boolean this_present_visibility = true && this.isSetVisibility();
        boolean that_present_visibility = true && that.isSetVisibility();
        if (this_present_visibility || that_present_visibility) {
            if (!(this_present_visibility && that_present_visibility))
                return false;
            if (!this.visibility.equals(that.visibility))
                return false;
        }

        boolean this_present__jsonObject = true && this.isSet_jsonObject();
        boolean that_present__jsonObject = true && that.isSet_jsonObject();
        if (this_present__jsonObject || that_present__jsonObject) {
            if (!(this_present__jsonObject && that_present__jsonObject))
                return false;
            if (!this._jsonObject.equals(that._jsonObject))
                return false;
        }

        boolean this_present__version = true && this.isSet_version();
        boolean that_present__version = true && that.isSet_version();
        if (this_present__version || that_present__version) {
            if (!(this_present__version && that_present__version))
                return false;
            if (this._version != that._version)
                return false;
        }

        boolean this_present__id = true && this.isSet_id();
        boolean that_present__id = true && that.isSet_id();
        if (this_present__id || that_present__id) {
            if (!(this_present__id && that_present__id))
                return false;
            if (!this._id.equals(that._id))
                return false;
        }

        boolean this_present_percolate = true && this.isSetPercolate();
        boolean that_present_percolate = true && that.isSetPercolate();
        if (this_present_percolate || that_present_percolate) {
            if (!(this_present_percolate && that_present_percolate))
                return false;
            if (!this.percolate.equals(that.percolate))
                return false;
        }

        return true;
    }

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

        boolean present__type = true && (isSet_type());
        builder.append(present__type);
        if (present__type)
            builder.append(_type);

        boolean present_visibility = true && (isSetVisibility());
        builder.append(present_visibility);
        if (present_visibility)
            builder.append(visibility);

        boolean present__jsonObject = true && (isSet_jsonObject());
        builder.append(present__jsonObject);
        if (present__jsonObject)
            builder.append(_jsonObject);

        boolean present__version = true && (isSet_version());
        builder.append(present__version);
        if (present__version)
            builder.append(_version);

        boolean present__id = true && (isSet_id());
        builder.append(present__id);
        if (present__id)
            builder.append(_id);

        boolean present_percolate = true && (isSetPercolate());
        builder.append(present_percolate);
        if (present_percolate)
            builder.append(percolate);

        return builder.toHashCode();
    }

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

        int lastComparison = 0;

        lastComparison = Boolean.valueOf(isSet_type()).compareTo(other.isSet_type());
        if (lastComparison != 0) {
            return lastComparison;
        }
        if (isSet_type()) {
            lastComparison = org.apache.thrift.TBaseHelper.compareTo(this._type, other._type);
            if (lastComparison != 0) {
                return lastComparison;
            }
        }
        lastComparison = Boolean.valueOf(isSetVisibility()).compareTo(other.isSetVisibility());
        if (lastComparison != 0) {
            return lastComparison;
        }
        if (isSetVisibility()) {
            lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.visibility, other.visibility);
            if (lastComparison != 0) {
                return lastComparison;
            }
        }
        lastComparison = Boolean.valueOf(isSet_jsonObject()).compareTo(other.isSet_jsonObject());
        if (lastComparison != 0) {
            return lastComparison;
        }
        if (isSet_jsonObject()) {
            lastComparison = org.apache.thrift.TBaseHelper.compareTo(this._jsonObject, other._jsonObject);
            if (lastComparison != 0) {
                return lastComparison;
            }
        }
        lastComparison = Boolean.valueOf(isSet_version()).compareTo(other.isSet_version());
        if (lastComparison != 0) {
            return lastComparison;
        }
        if (isSet_version()) {
            lastComparison = org.apache.thrift.TBaseHelper.compareTo(this._version, other._version);
            if (lastComparison != 0) {
                return lastComparison;
            }
        }
        lastComparison = Boolean.valueOf(isSet_id()).compareTo(other.isSet_id());
        if (lastComparison != 0) {
            return lastComparison;
        }
        if (isSet_id()) {
            lastComparison = org.apache.thrift.TBaseHelper.compareTo(this._id, other._id);
            if (lastComparison != 0) {
                return lastComparison;
            }
        }
        lastComparison = Boolean.valueOf(isSetPercolate()).compareTo(other.isSetPercolate());
        if (lastComparison != 0) {
            return lastComparison;
        }
        if (isSetPercolate()) {
            lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.percolate, other.percolate);
            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("Document(");
        boolean first = true;

        sb.append("_type:");
        if (this._type == null) {
            sb.append("null");
        } else {
            sb.append(this._type);
        }
        first = false;
        if (!first)
            sb.append(", ");
        sb.append("visibility:");
        if (this.visibility == null) {
            sb.append("null");
        } else {
            sb.append(this.visibility);
        }
        first = false;
        if (!first)
            sb.append(", ");
        sb.append("_jsonObject:");
        if (this._jsonObject == null) {
            sb.append("null");
        } else {
            sb.append(this._jsonObject);
        }
        first = false;
        if (isSet_version()) {
            if (!first)
                sb.append(", ");
            sb.append("_version:");
            sb.append(this._version);
            first = false;
        }
        if (isSet_id()) {
            if (!first)
                sb.append(", ");
            sb.append("_id:");
            if (this._id == null) {
                sb.append("null");
            } else {
                sb.append(this._id);
            }
            first = false;
        }
        if (isSetPercolate()) {
            if (!first)
                sb.append(", ");
            sb.append("percolate:");
            if (this.percolate == null) {
                sb.append("null");
            } else {
                sb.append(this.percolate);
            }
            first = false;
        }
        sb.append(")");
        return sb.toString();
    }

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

    private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
        try {
            write(new org.apache.thrift.protocol.TCompactProtocol(
                    new org.apache.thrift.transport.TIOStreamTransport(out)));
        } catch (org.apache.thrift.TException te) {
            throw new java.io.IOException(te);
        }
    }

    private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
        try {
            // 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 DocumentStandardSchemeFactory implements SchemeFactory {
        public DocumentStandardScheme getScheme() {
            return new DocumentStandardScheme();
        }
    }

    private static class DocumentStandardScheme extends StandardScheme<Document> {

        public void read(org.apache.thrift.protocol.TProtocol iprot, Document struct)
                throws org.apache.thrift.TException {
            org.apache.thrift.protocol.TField schemeField;
            iprot.readStructBegin();
            while (true) {
                schemeField = iprot.readFieldBegin();
                if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
                    break;
                }
                switch (schemeField.id) {
                case 1: // _TYPE
                    if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
                        struct._type = iprot.readString();
                        struct.set_typeIsSet(true);
                    } else {
                        org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
                    }
                    break;
                case 2: // VISIBILITY
                    if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
                        struct.visibility = new ezbake.base.thrift.Visibility();
                        struct.visibility.read(iprot);
                        struct.setVisibilityIsSet(true);
                    } else {
                        org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
                    }
                    break;
                case 3: // _JSON_OBJECT
                    if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
                        struct._jsonObject = iprot.readString();
                        struct.set_jsonObjectIsSet(true);
                    } else {
                        org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
                    }
                    break;
                case 4: // _VERSION
                    if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
                        struct._version = iprot.readI64();
                        struct.set_versionIsSet(true);
                    } else {
                        org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
                    }
                    break;
                case 5: // _ID
                    if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
                        struct._id = iprot.readString();
                        struct.set_idIsSet(true);
                    } else {
                        org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
                    }
                    break;
                case 6: // PERCOLATE
                    if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
                        struct.percolate = new PercolateRequest();
                        struct.percolate.read(iprot);
                        struct.setPercolateIsSet(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, Document struct)
                throws org.apache.thrift.TException {
            struct.validate();

            oprot.writeStructBegin(STRUCT_DESC);
            if (struct._type != null) {
                oprot.writeFieldBegin(_TYPE_FIELD_DESC);
                oprot.writeString(struct._type);
                oprot.writeFieldEnd();
            }
            if (struct.visibility != null) {
                oprot.writeFieldBegin(VISIBILITY_FIELD_DESC);
                struct.visibility.write(oprot);
                oprot.writeFieldEnd();
            }
            if (struct._jsonObject != null) {
                oprot.writeFieldBegin(_JSON_OBJECT_FIELD_DESC);
                oprot.writeString(struct._jsonObject);
                oprot.writeFieldEnd();
            }
            if (struct.isSet_version()) {
                oprot.writeFieldBegin(_VERSION_FIELD_DESC);
                oprot.writeI64(struct._version);
                oprot.writeFieldEnd();
            }
            if (struct._id != null) {
                if (struct.isSet_id()) {
                    oprot.writeFieldBegin(_ID_FIELD_DESC);
                    oprot.writeString(struct._id);
                    oprot.writeFieldEnd();
                }
            }
            if (struct.percolate != null) {
                if (struct.isSetPercolate()) {
                    oprot.writeFieldBegin(PERCOLATE_FIELD_DESC);
                    struct.percolate.write(oprot);
                    oprot.writeFieldEnd();
                }
            }
            oprot.writeFieldStop();
            oprot.writeStructEnd();
        }

    }

    private static class DocumentTupleSchemeFactory implements SchemeFactory {
        public DocumentTupleScheme getScheme() {
            return new DocumentTupleScheme();
        }
    }

    private static class DocumentTupleScheme extends TupleScheme<Document> {

        @Override
        public void write(org.apache.thrift.protocol.TProtocol prot, Document struct)
                throws org.apache.thrift.TException {
            TTupleProtocol oprot = (TTupleProtocol) prot;
            oprot.writeString(struct._type);
            struct.visibility.write(oprot);
            oprot.writeString(struct._jsonObject);
            BitSet optionals = new BitSet();
            if (struct.isSet_version()) {
                optionals.set(0);
            }
            if (struct.isSet_id()) {
                optionals.set(1);
            }
            if (struct.isSetPercolate()) {
                optionals.set(2);
            }
            oprot.writeBitSet(optionals, 3);
            if (struct.isSet_version()) {
                oprot.writeI64(struct._version);
            }
            if (struct.isSet_id()) {
                oprot.writeString(struct._id);
            }
            if (struct.isSetPercolate()) {
                struct.percolate.write(oprot);
            }
        }

        @Override
        public void read(org.apache.thrift.protocol.TProtocol prot, Document struct)
                throws org.apache.thrift.TException {
            TTupleProtocol iprot = (TTupleProtocol) prot;
            struct._type = iprot.readString();
            struct.set_typeIsSet(true);
            struct.visibility = new ezbake.base.thrift.Visibility();
            struct.visibility.read(iprot);
            struct.setVisibilityIsSet(true);
            struct._jsonObject = iprot.readString();
            struct.set_jsonObjectIsSet(true);
            BitSet incoming = iprot.readBitSet(3);
            if (incoming.get(0)) {
                struct._version = iprot.readI64();
                struct.set_versionIsSet(true);
            }
            if (incoming.get(1)) {
                struct._id = iprot.readString();
                struct.set_idIsSet(true);
            }
            if (incoming.get(2)) {
                struct.percolate = new PercolateRequest();
                struct.percolate.read(iprot);
                struct.setPercolateIsSet(true);
            }
        }
    }

}