ezbake.data.mongo.driver.thrift.ResultsWrapper.java Source code

Java tutorial

Introduction

Here is the source code for ezbake.data.mongo.driver.thrift.ResultsWrapper.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.mongo.driver.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 ResultsWrapper implements org.apache.thrift.TBase<ResultsWrapper, ResultsWrapper._Fields>,
        java.io.Serializable, Cloneable, Comparable<ResultsWrapper> {
    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct(
            "ResultsWrapper");

    private static final org.apache.thrift.protocol.TField REQUEST_ID_FIELD_DESC = new org.apache.thrift.protocol.TField(
            "requestId", org.apache.thrift.protocol.TType.STRING, (short) 1);
    private static final org.apache.thrift.protocol.TField RESULT_SET_FIELD_DESC = new org.apache.thrift.protocol.TField(
            "resultSet", org.apache.thrift.protocol.TType.STRING, (short) 2);
    private static final org.apache.thrift.protocol.TField RESPONSE_DATA_FIELD_DESC = new org.apache.thrift.protocol.TField(
            "responseData", org.apache.thrift.protocol.TType.STRING, (short) 3);
    private static final org.apache.thrift.protocol.TField RESULT_SET_VALID_FIELD_DESC = new org.apache.thrift.protocol.TField(
            "resultSetValid", org.apache.thrift.protocol.TType.BOOL, (short) 4);
    private static final org.apache.thrift.protocol.TField ROWS_EFFECTED_FIELD_DESC = new org.apache.thrift.protocol.TField(
            "rowsEffected", org.apache.thrift.protocol.TType.I16, (short) 5);
    private static final org.apache.thrift.protocol.TField MONGOEXCEPTION_FIELD_DESC = new org.apache.thrift.protocol.TField(
            "mongoexception", org.apache.thrift.protocol.TType.STRING, (short) 6);

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

    public String requestId; // required
    public ByteBuffer resultSet; // required
    public ByteBuffer responseData; // required
    public boolean resultSetValid; // required
    public short rowsEffected; // required
    public ByteBuffer mongoexception; // 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 {
        REQUEST_ID((short) 1, "requestId"), RESULT_SET((short) 2, "resultSet"), RESPONSE_DATA((short) 3,
                "responseData"), RESULT_SET_VALID((short) 4, "resultSetValid"), ROWS_EFFECTED((short) 5,
                        "rowsEffected"), MONGOEXCEPTION((short) 6, "mongoexception");

        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: // REQUEST_ID
                return REQUEST_ID;
            case 2: // RESULT_SET
                return RESULT_SET;
            case 3: // RESPONSE_DATA
                return RESPONSE_DATA;
            case 4: // RESULT_SET_VALID
                return RESULT_SET_VALID;
            case 5: // ROWS_EFFECTED
                return ROWS_EFFECTED;
            case 6: // MONGOEXCEPTION
                return MONGOEXCEPTION;
            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 __RESULTSETVALID_ISSET_ID = 0;
    private static final int __ROWSEFFECTED_ISSET_ID = 1;
    private byte __isset_bitfield = 0;
    private _Fields optionals[] = { _Fields.MONGOEXCEPTION };
    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.REQUEST_ID, new org.apache.thrift.meta_data.FieldMetaData("requestId",
                org.apache.thrift.TFieldRequirementType.DEFAULT,
                new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
        tmpMap.put(_Fields.RESULT_SET, new org.apache.thrift.meta_data.FieldMetaData("resultSet",
                org.apache.thrift.TFieldRequirementType.DEFAULT,
                new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING, true)));
        tmpMap.put(_Fields.RESPONSE_DATA, new org.apache.thrift.meta_data.FieldMetaData("responseData",
                org.apache.thrift.TFieldRequirementType.DEFAULT,
                new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING, true)));
        tmpMap.put(_Fields.RESULT_SET_VALID,
                new org.apache.thrift.meta_data.FieldMetaData("resultSetValid",
                        org.apache.thrift.TFieldRequirementType.DEFAULT,
                        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
        tmpMap.put(_Fields.ROWS_EFFECTED,
                new org.apache.thrift.meta_data.FieldMetaData("rowsEffected",
                        org.apache.thrift.TFieldRequirementType.DEFAULT,
                        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I16)));
        tmpMap.put(_Fields.MONGOEXCEPTION, new org.apache.thrift.meta_data.FieldMetaData("mongoexception",
                org.apache.thrift.TFieldRequirementType.OPTIONAL,
                new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING, true)));
        metaDataMap = Collections.unmodifiableMap(tmpMap);
        org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(ResultsWrapper.class, metaDataMap);
    }

    public ResultsWrapper() {
    }

    public ResultsWrapper(String requestId, ByteBuffer resultSet, ByteBuffer responseData, boolean resultSetValid,
            short rowsEffected) {
        this();
        this.requestId = requestId;
        this.resultSet = resultSet;
        this.responseData = responseData;
        this.resultSetValid = resultSetValid;
        setResultSetValidIsSet(true);
        this.rowsEffected = rowsEffected;
        setRowsEffectedIsSet(true);
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public ResultsWrapper(ResultsWrapper other) {
        __isset_bitfield = other.__isset_bitfield;
        if (other.isSetRequestId()) {
            this.requestId = other.requestId;
        }
        if (other.isSetResultSet()) {
            this.resultSet = org.apache.thrift.TBaseHelper.copyBinary(other.resultSet);
            ;
        }
        if (other.isSetResponseData()) {
            this.responseData = org.apache.thrift.TBaseHelper.copyBinary(other.responseData);
            ;
        }
        this.resultSetValid = other.resultSetValid;
        this.rowsEffected = other.rowsEffected;
        if (other.isSetMongoexception()) {
            this.mongoexception = org.apache.thrift.TBaseHelper.copyBinary(other.mongoexception);
            ;
        }
    }

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

    @Override
    public void clear() {
        this.requestId = null;
        this.resultSet = null;
        this.responseData = null;
        setResultSetValidIsSet(false);
        this.resultSetValid = false;
        setRowsEffectedIsSet(false);
        this.rowsEffected = 0;
        this.mongoexception = null;
    }

    public String getRequestId() {
        return this.requestId;
    }

    public ResultsWrapper setRequestId(String requestId) {
        this.requestId = requestId;
        return this;
    }

    public void unsetRequestId() {
        this.requestId = null;
    }

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

    public void setRequestIdIsSet(boolean value) {
        if (!value) {
            this.requestId = null;
        }
    }

    public byte[] getResultSet() {
        setResultSet(org.apache.thrift.TBaseHelper.rightSize(resultSet));
        return resultSet == null ? null : resultSet.array();
    }

    public ByteBuffer bufferForResultSet() {
        return resultSet;
    }

    public ResultsWrapper setResultSet(byte[] resultSet) {
        setResultSet(resultSet == null ? (ByteBuffer) null : ByteBuffer.wrap(resultSet));
        return this;
    }

    public ResultsWrapper setResultSet(ByteBuffer resultSet) {
        this.resultSet = resultSet;
        return this;
    }

    public void unsetResultSet() {
        this.resultSet = null;
    }

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

    public void setResultSetIsSet(boolean value) {
        if (!value) {
            this.resultSet = null;
        }
    }

    public byte[] getResponseData() {
        setResponseData(org.apache.thrift.TBaseHelper.rightSize(responseData));
        return responseData == null ? null : responseData.array();
    }

    public ByteBuffer bufferForResponseData() {
        return responseData;
    }

    public ResultsWrapper setResponseData(byte[] responseData) {
        setResponseData(responseData == null ? (ByteBuffer) null : ByteBuffer.wrap(responseData));
        return this;
    }

    public ResultsWrapper setResponseData(ByteBuffer responseData) {
        this.responseData = responseData;
        return this;
    }

    public void unsetResponseData() {
        this.responseData = null;
    }

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

    public void setResponseDataIsSet(boolean value) {
        if (!value) {
            this.responseData = null;
        }
    }

    public boolean isResultSetValid() {
        return this.resultSetValid;
    }

    public ResultsWrapper setResultSetValid(boolean resultSetValid) {
        this.resultSetValid = resultSetValid;
        setResultSetValidIsSet(true);
        return this;
    }

    public void unsetResultSetValid() {
        __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __RESULTSETVALID_ISSET_ID);
    }

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

    public void setResultSetValidIsSet(boolean value) {
        __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __RESULTSETVALID_ISSET_ID, value);
    }

    public short getRowsEffected() {
        return this.rowsEffected;
    }

    public ResultsWrapper setRowsEffected(short rowsEffected) {
        this.rowsEffected = rowsEffected;
        setRowsEffectedIsSet(true);
        return this;
    }

    public void unsetRowsEffected() {
        __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __ROWSEFFECTED_ISSET_ID);
    }

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

    public void setRowsEffectedIsSet(boolean value) {
        __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __ROWSEFFECTED_ISSET_ID, value);
    }

    public byte[] getMongoexception() {
        setMongoexception(org.apache.thrift.TBaseHelper.rightSize(mongoexception));
        return mongoexception == null ? null : mongoexception.array();
    }

    public ByteBuffer bufferForMongoexception() {
        return mongoexception;
    }

    public ResultsWrapper setMongoexception(byte[] mongoexception) {
        setMongoexception(mongoexception == null ? (ByteBuffer) null : ByteBuffer.wrap(mongoexception));
        return this;
    }

    public ResultsWrapper setMongoexception(ByteBuffer mongoexception) {
        this.mongoexception = mongoexception;
        return this;
    }

    public void unsetMongoexception() {
        this.mongoexception = null;
    }

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

    public void setMongoexceptionIsSet(boolean value) {
        if (!value) {
            this.mongoexception = null;
        }
    }

    public void setFieldValue(_Fields field, Object value) {
        switch (field) {
        case REQUEST_ID:
            if (value == null) {
                unsetRequestId();
            } else {
                setRequestId((String) value);
            }
            break;

        case RESULT_SET:
            if (value == null) {
                unsetResultSet();
            } else {
                setResultSet((ByteBuffer) value);
            }
            break;

        case RESPONSE_DATA:
            if (value == null) {
                unsetResponseData();
            } else {
                setResponseData((ByteBuffer) value);
            }
            break;

        case RESULT_SET_VALID:
            if (value == null) {
                unsetResultSetValid();
            } else {
                setResultSetValid((Boolean) value);
            }
            break;

        case ROWS_EFFECTED:
            if (value == null) {
                unsetRowsEffected();
            } else {
                setRowsEffected((Short) value);
            }
            break;

        case MONGOEXCEPTION:
            if (value == null) {
                unsetMongoexception();
            } else {
                setMongoexception((ByteBuffer) value);
            }
            break;

        }
    }

    public Object getFieldValue(_Fields field) {
        switch (field) {
        case REQUEST_ID:
            return getRequestId();

        case RESULT_SET:
            return getResultSet();

        case RESPONSE_DATA:
            return getResponseData();

        case RESULT_SET_VALID:
            return Boolean.valueOf(isResultSetValid());

        case ROWS_EFFECTED:
            return Short.valueOf(getRowsEffected());

        case MONGOEXCEPTION:
            return getMongoexception();

        }
        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 REQUEST_ID:
            return isSetRequestId();
        case RESULT_SET:
            return isSetResultSet();
        case RESPONSE_DATA:
            return isSetResponseData();
        case RESULT_SET_VALID:
            return isSetResultSetValid();
        case ROWS_EFFECTED:
            return isSetRowsEffected();
        case MONGOEXCEPTION:
            return isSetMongoexception();
        }
        throw new IllegalStateException();
    }

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

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

        boolean this_present_requestId = true && this.isSetRequestId();
        boolean that_present_requestId = true && that.isSetRequestId();
        if (this_present_requestId || that_present_requestId) {
            if (!(this_present_requestId && that_present_requestId))
                return false;
            if (!this.requestId.equals(that.requestId))
                return false;
        }

        boolean this_present_resultSet = true && this.isSetResultSet();
        boolean that_present_resultSet = true && that.isSetResultSet();
        if (this_present_resultSet || that_present_resultSet) {
            if (!(this_present_resultSet && that_present_resultSet))
                return false;
            if (!this.resultSet.equals(that.resultSet))
                return false;
        }

        boolean this_present_responseData = true && this.isSetResponseData();
        boolean that_present_responseData = true && that.isSetResponseData();
        if (this_present_responseData || that_present_responseData) {
            if (!(this_present_responseData && that_present_responseData))
                return false;
            if (!this.responseData.equals(that.responseData))
                return false;
        }

        boolean this_present_resultSetValid = true;
        boolean that_present_resultSetValid = true;
        if (this_present_resultSetValid || that_present_resultSetValid) {
            if (!(this_present_resultSetValid && that_present_resultSetValid))
                return false;
            if (this.resultSetValid != that.resultSetValid)
                return false;
        }

        boolean this_present_rowsEffected = true;
        boolean that_present_rowsEffected = true;
        if (this_present_rowsEffected || that_present_rowsEffected) {
            if (!(this_present_rowsEffected && that_present_rowsEffected))
                return false;
            if (this.rowsEffected != that.rowsEffected)
                return false;
        }

        boolean this_present_mongoexception = true && this.isSetMongoexception();
        boolean that_present_mongoexception = true && that.isSetMongoexception();
        if (this_present_mongoexception || that_present_mongoexception) {
            if (!(this_present_mongoexception && that_present_mongoexception))
                return false;
            if (!this.mongoexception.equals(that.mongoexception))
                return false;
        }

        return true;
    }

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

        boolean present_requestId = true && (isSetRequestId());
        builder.append(present_requestId);
        if (present_requestId)
            builder.append(requestId);

        boolean present_resultSet = true && (isSetResultSet());
        builder.append(present_resultSet);
        if (present_resultSet)
            builder.append(resultSet);

        boolean present_responseData = true && (isSetResponseData());
        builder.append(present_responseData);
        if (present_responseData)
            builder.append(responseData);

        boolean present_resultSetValid = true;
        builder.append(present_resultSetValid);
        if (present_resultSetValid)
            builder.append(resultSetValid);

        boolean present_rowsEffected = true;
        builder.append(present_rowsEffected);
        if (present_rowsEffected)
            builder.append(rowsEffected);

        boolean present_mongoexception = true && (isSetMongoexception());
        builder.append(present_mongoexception);
        if (present_mongoexception)
            builder.append(mongoexception);

        return builder.toHashCode();
    }

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

        int lastComparison = 0;

        lastComparison = Boolean.valueOf(isSetRequestId()).compareTo(other.isSetRequestId());
        if (lastComparison != 0) {
            return lastComparison;
        }
        if (isSetRequestId()) {
            lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.requestId, other.requestId);
            if (lastComparison != 0) {
                return lastComparison;
            }
        }
        lastComparison = Boolean.valueOf(isSetResultSet()).compareTo(other.isSetResultSet());
        if (lastComparison != 0) {
            return lastComparison;
        }
        if (isSetResultSet()) {
            lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.resultSet, other.resultSet);
            if (lastComparison != 0) {
                return lastComparison;
            }
        }
        lastComparison = Boolean.valueOf(isSetResponseData()).compareTo(other.isSetResponseData());
        if (lastComparison != 0) {
            return lastComparison;
        }
        if (isSetResponseData()) {
            lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.responseData, other.responseData);
            if (lastComparison != 0) {
                return lastComparison;
            }
        }
        lastComparison = Boolean.valueOf(isSetResultSetValid()).compareTo(other.isSetResultSetValid());
        if (lastComparison != 0) {
            return lastComparison;
        }
        if (isSetResultSetValid()) {
            lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.resultSetValid, other.resultSetValid);
            if (lastComparison != 0) {
                return lastComparison;
            }
        }
        lastComparison = Boolean.valueOf(isSetRowsEffected()).compareTo(other.isSetRowsEffected());
        if (lastComparison != 0) {
            return lastComparison;
        }
        if (isSetRowsEffected()) {
            lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.rowsEffected, other.rowsEffected);
            if (lastComparison != 0) {
                return lastComparison;
            }
        }
        lastComparison = Boolean.valueOf(isSetMongoexception()).compareTo(other.isSetMongoexception());
        if (lastComparison != 0) {
            return lastComparison;
        }
        if (isSetMongoexception()) {
            lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.mongoexception, other.mongoexception);
            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("ResultsWrapper(");
        boolean first = true;

        sb.append("requestId:");
        if (this.requestId == null) {
            sb.append("null");
        } else {
            sb.append(this.requestId);
        }
        first = false;
        if (!first)
            sb.append(", ");
        sb.append("resultSet:");
        if (this.resultSet == null) {
            sb.append("null");
        } else {
            org.apache.thrift.TBaseHelper.toString(this.resultSet, sb);
        }
        first = false;
        if (!first)
            sb.append(", ");
        sb.append("responseData:");
        if (this.responseData == null) {
            sb.append("null");
        } else {
            org.apache.thrift.TBaseHelper.toString(this.responseData, sb);
        }
        first = false;
        if (!first)
            sb.append(", ");
        sb.append("resultSetValid:");
        sb.append(this.resultSetValid);
        first = false;
        if (!first)
            sb.append(", ");
        sb.append("rowsEffected:");
        sb.append(this.rowsEffected);
        first = false;
        if (isSetMongoexception()) {
            if (!first)
                sb.append(", ");
            sb.append("mongoexception:");
            if (this.mongoexception == null) {
                sb.append("null");
            } else {
                org.apache.thrift.TBaseHelper.toString(this.mongoexception, sb);
            }
            first = false;
        }
        sb.append(")");
        return sb.toString();
    }

    public void validate() throws org.apache.thrift.TException {
        // check for required fields
        // 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 ResultsWrapperStandardSchemeFactory implements SchemeFactory {
        public ResultsWrapperStandardScheme getScheme() {
            return new ResultsWrapperStandardScheme();
        }
    }

    private static class ResultsWrapperStandardScheme extends StandardScheme<ResultsWrapper> {

        public void read(org.apache.thrift.protocol.TProtocol iprot, ResultsWrapper 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: // REQUEST_ID
                    if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
                        struct.requestId = iprot.readString();
                        struct.setRequestIdIsSet(true);
                    } else {
                        org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
                    }
                    break;
                case 2: // RESULT_SET
                    if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
                        struct.resultSet = iprot.readBinary();
                        struct.setResultSetIsSet(true);
                    } else {
                        org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
                    }
                    break;
                case 3: // RESPONSE_DATA
                    if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
                        struct.responseData = iprot.readBinary();
                        struct.setResponseDataIsSet(true);
                    } else {
                        org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
                    }
                    break;
                case 4: // RESULT_SET_VALID
                    if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
                        struct.resultSetValid = iprot.readBool();
                        struct.setResultSetValidIsSet(true);
                    } else {
                        org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
                    }
                    break;
                case 5: // ROWS_EFFECTED
                    if (schemeField.type == org.apache.thrift.protocol.TType.I16) {
                        struct.rowsEffected = iprot.readI16();
                        struct.setRowsEffectedIsSet(true);
                    } else {
                        org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
                    }
                    break;
                case 6: // MONGOEXCEPTION
                    if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
                        struct.mongoexception = iprot.readBinary();
                        struct.setMongoexceptionIsSet(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, ResultsWrapper struct)
                throws org.apache.thrift.TException {
            struct.validate();

            oprot.writeStructBegin(STRUCT_DESC);
            if (struct.requestId != null) {
                oprot.writeFieldBegin(REQUEST_ID_FIELD_DESC);
                oprot.writeString(struct.requestId);
                oprot.writeFieldEnd();
            }
            if (struct.resultSet != null) {
                oprot.writeFieldBegin(RESULT_SET_FIELD_DESC);
                oprot.writeBinary(struct.resultSet);
                oprot.writeFieldEnd();
            }
            if (struct.responseData != null) {
                oprot.writeFieldBegin(RESPONSE_DATA_FIELD_DESC);
                oprot.writeBinary(struct.responseData);
                oprot.writeFieldEnd();
            }
            oprot.writeFieldBegin(RESULT_SET_VALID_FIELD_DESC);
            oprot.writeBool(struct.resultSetValid);
            oprot.writeFieldEnd();
            oprot.writeFieldBegin(ROWS_EFFECTED_FIELD_DESC);
            oprot.writeI16(struct.rowsEffected);
            oprot.writeFieldEnd();
            if (struct.mongoexception != null) {
                if (struct.isSetMongoexception()) {
                    oprot.writeFieldBegin(MONGOEXCEPTION_FIELD_DESC);
                    oprot.writeBinary(struct.mongoexception);
                    oprot.writeFieldEnd();
                }
            }
            oprot.writeFieldStop();
            oprot.writeStructEnd();
        }

    }

    private static class ResultsWrapperTupleSchemeFactory implements SchemeFactory {
        public ResultsWrapperTupleScheme getScheme() {
            return new ResultsWrapperTupleScheme();
        }
    }

    private static class ResultsWrapperTupleScheme extends TupleScheme<ResultsWrapper> {

        @Override
        public void write(org.apache.thrift.protocol.TProtocol prot, ResultsWrapper struct)
                throws org.apache.thrift.TException {
            TTupleProtocol oprot = (TTupleProtocol) prot;
            BitSet optionals = new BitSet();
            if (struct.isSetRequestId()) {
                optionals.set(0);
            }
            if (struct.isSetResultSet()) {
                optionals.set(1);
            }
            if (struct.isSetResponseData()) {
                optionals.set(2);
            }
            if (struct.isSetResultSetValid()) {
                optionals.set(3);
            }
            if (struct.isSetRowsEffected()) {
                optionals.set(4);
            }
            if (struct.isSetMongoexception()) {
                optionals.set(5);
            }
            oprot.writeBitSet(optionals, 6);
            if (struct.isSetRequestId()) {
                oprot.writeString(struct.requestId);
            }
            if (struct.isSetResultSet()) {
                oprot.writeBinary(struct.resultSet);
            }
            if (struct.isSetResponseData()) {
                oprot.writeBinary(struct.responseData);
            }
            if (struct.isSetResultSetValid()) {
                oprot.writeBool(struct.resultSetValid);
            }
            if (struct.isSetRowsEffected()) {
                oprot.writeI16(struct.rowsEffected);
            }
            if (struct.isSetMongoexception()) {
                oprot.writeBinary(struct.mongoexception);
            }
        }

        @Override
        public void read(org.apache.thrift.protocol.TProtocol prot, ResultsWrapper struct)
                throws org.apache.thrift.TException {
            TTupleProtocol iprot = (TTupleProtocol) prot;
            BitSet incoming = iprot.readBitSet(6);
            if (incoming.get(0)) {
                struct.requestId = iprot.readString();
                struct.setRequestIdIsSet(true);
            }
            if (incoming.get(1)) {
                struct.resultSet = iprot.readBinary();
                struct.setResultSetIsSet(true);
            }
            if (incoming.get(2)) {
                struct.responseData = iprot.readBinary();
                struct.setResponseDataIsSet(true);
            }
            if (incoming.get(3)) {
                struct.resultSetValid = iprot.readBool();
                struct.setResultSetValidIsSet(true);
            }
            if (incoming.get(4)) {
                struct.rowsEffected = iprot.readI16();
                struct.setRowsEffectedIsSet(true);
            }
            if (incoming.get(5)) {
                struct.mongoexception = iprot.readBinary();
                struct.setMongoexceptionIsSet(true);
            }
        }
    }

}