All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.xiaomi.infra.galaxy.sds.thrift.Result Maven / Gradle / Ivy

There is a newer version: 1.3.2
Show newest version
/**
 * Autogenerated by Thrift Compiler (0.9.2)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
package com.xiaomi.infra.galaxy.sds.thrift;

import libthrift091.scheme.IScheme;
import libthrift091.scheme.SchemeFactory;
import libthrift091.scheme.StandardScheme;

import libthrift091.scheme.TupleScheme;
import libthrift091.protocol.TTupleProtocol;
import libthrift091.protocol.TProtocolException;
import libthrift091.EncodingUtils;
import libthrift091.TException;
import libthrift091.async.AsyncMethodCallback;
import libthrift091.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 javax.annotation.Generated;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
public class Result extends libthrift091.TUnion {
  private static final libthrift091.protocol.TStruct STRUCT_DESC = new libthrift091.protocol.TStruct("Result");
  private static final libthrift091.protocol.TField GET_RESULT_FIELD_DESC = new libthrift091.protocol.TField("getResult", libthrift091.protocol.TType.STRUCT, (short)1);
  private static final libthrift091.protocol.TField PUT_RESULT_FIELD_DESC = new libthrift091.protocol.TField("putResult", libthrift091.protocol.TType.STRUCT, (short)2);
  private static final libthrift091.protocol.TField INCREMENT_RESULT_FIELD_DESC = new libthrift091.protocol.TField("incrementResult", libthrift091.protocol.TType.STRUCT, (short)3);
  private static final libthrift091.protocol.TField REMOVE_RESULT_FIELD_DESC = new libthrift091.protocol.TField("removeResult", libthrift091.protocol.TType.STRUCT, (short)4);

  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
  public enum _Fields implements libthrift091.TFieldIdEnum {
    GET_RESULT((short)1, "getResult"),
    PUT_RESULT((short)2, "putResult"),
    INCREMENT_RESULT((short)3, "incrementResult"),
    REMOVE_RESULT((short)4, "removeResult");

    private static final Map byName = new HashMap();

    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: // GET_RESULT
          return GET_RESULT;
        case 2: // PUT_RESULT
          return PUT_RESULT;
        case 3: // INCREMENT_RESULT
          return INCREMENT_RESULT;
        case 4: // REMOVE_RESULT
          return REMOVE_RESULT;
        default:
          return null;
      }
    }

    /**
     * Find the _Fields constant that matches fieldId, throwing an exception
     * if it is not found.
     */
    public static _Fields findByThriftIdOrThrow(int fieldId) {
      _Fields fields = findByThriftId(fieldId);
      if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
      return fields;
    }

    /**
     * Find the _Fields constant that matches name, or null if its not found.
     */
    public static _Fields findByName(String name) {
      return byName.get(name);
    }

    private final short _thriftId;
    private final String _fieldName;

    _Fields(short thriftId, String fieldName) {
      _thriftId = thriftId;
      _fieldName = fieldName;
    }

    public short getThriftFieldId() {
      return _thriftId;
    }

    public String getFieldName() {
      return _fieldName;
    }
  }

  public static final Map<_Fields, libthrift091.meta_data.FieldMetaData> metaDataMap;
  static {
    Map<_Fields, libthrift091.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, libthrift091.meta_data.FieldMetaData>(_Fields.class);
    tmpMap.put(_Fields.GET_RESULT, new libthrift091.meta_data.FieldMetaData("getResult", libthrift091.TFieldRequirementType.OPTIONAL, 
        new libthrift091.meta_data.StructMetaData(libthrift091.protocol.TType.STRUCT, GetResult.class)));
    tmpMap.put(_Fields.PUT_RESULT, new libthrift091.meta_data.FieldMetaData("putResult", libthrift091.TFieldRequirementType.OPTIONAL, 
        new libthrift091.meta_data.StructMetaData(libthrift091.protocol.TType.STRUCT, PutResult.class)));
    tmpMap.put(_Fields.INCREMENT_RESULT, new libthrift091.meta_data.FieldMetaData("incrementResult", libthrift091.TFieldRequirementType.OPTIONAL, 
        new libthrift091.meta_data.StructMetaData(libthrift091.protocol.TType.STRUCT, IncrementResult.class)));
    tmpMap.put(_Fields.REMOVE_RESULT, new libthrift091.meta_data.FieldMetaData("removeResult", libthrift091.TFieldRequirementType.OPTIONAL, 
        new libthrift091.meta_data.StructMetaData(libthrift091.protocol.TType.STRUCT, RemoveResult.class)));
    metaDataMap = Collections.unmodifiableMap(tmpMap);
    libthrift091.meta_data.FieldMetaData.addStructMetaDataMap(Result.class, metaDataMap);
  }

  public Result() {
    super();
  }

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

  public Result(Result other) {
    super(other);
  }
  public Result deepCopy() {
    return new Result(this);
  }

  public static Result getResult(GetResult value) {
    Result x = new Result();
    x.setGetResult(value);
    return x;
  }

  public static Result putResult(PutResult value) {
    Result x = new Result();
    x.setPutResult(value);
    return x;
  }

  public static Result incrementResult(IncrementResult value) {
    Result x = new Result();
    x.setIncrementResult(value);
    return x;
  }

  public static Result removeResult(RemoveResult value) {
    Result x = new Result();
    x.setRemoveResult(value);
    return x;
  }


  @Override
  protected void checkType(_Fields setField, Object value) throws ClassCastException {
    switch (setField) {
      case GET_RESULT:
        if (value instanceof GetResult) {
          break;
        }
        throw new ClassCastException("Was expecting value of type GetResult for field 'getResult', but got " + value.getClass().getSimpleName());
      case PUT_RESULT:
        if (value instanceof PutResult) {
          break;
        }
        throw new ClassCastException("Was expecting value of type PutResult for field 'putResult', but got " + value.getClass().getSimpleName());
      case INCREMENT_RESULT:
        if (value instanceof IncrementResult) {
          break;
        }
        throw new ClassCastException("Was expecting value of type IncrementResult for field 'incrementResult', but got " + value.getClass().getSimpleName());
      case REMOVE_RESULT:
        if (value instanceof RemoveResult) {
          break;
        }
        throw new ClassCastException("Was expecting value of type RemoveResult for field 'removeResult', but got " + value.getClass().getSimpleName());
      default:
        throw new IllegalArgumentException("Unknown field id " + setField);
    }
  }

  @Override
  protected Object standardSchemeReadValue(libthrift091.protocol.TProtocol iprot, libthrift091.protocol.TField field) throws libthrift091.TException {
    _Fields setField = _Fields.findByThriftId(field.id);
    if (setField != null) {
      switch (setField) {
        case GET_RESULT:
          if (field.type == GET_RESULT_FIELD_DESC.type) {
            GetResult getResult;
            getResult = new GetResult();
            getResult.read(iprot);
            return getResult;
          } else {
            libthrift091.protocol.TProtocolUtil.skip(iprot, field.type);
            return null;
          }
        case PUT_RESULT:
          if (field.type == PUT_RESULT_FIELD_DESC.type) {
            PutResult putResult;
            putResult = new PutResult();
            putResult.read(iprot);
            return putResult;
          } else {
            libthrift091.protocol.TProtocolUtil.skip(iprot, field.type);
            return null;
          }
        case INCREMENT_RESULT:
          if (field.type == INCREMENT_RESULT_FIELD_DESC.type) {
            IncrementResult incrementResult;
            incrementResult = new IncrementResult();
            incrementResult.read(iprot);
            return incrementResult;
          } else {
            libthrift091.protocol.TProtocolUtil.skip(iprot, field.type);
            return null;
          }
        case REMOVE_RESULT:
          if (field.type == REMOVE_RESULT_FIELD_DESC.type) {
            RemoveResult removeResult;
            removeResult = new RemoveResult();
            removeResult.read(iprot);
            return removeResult;
          } else {
            libthrift091.protocol.TProtocolUtil.skip(iprot, field.type);
            return null;
          }
        default:
          throw new IllegalStateException("setField wasn't null, but didn't match any of the case statements!");
      }
    } else {
      libthrift091.protocol.TProtocolUtil.skip(iprot, field.type);
      return null;
    }
  }

  @Override
  protected void standardSchemeWriteValue(libthrift091.protocol.TProtocol oprot) throws libthrift091.TException {
    switch (setField_) {
      case GET_RESULT:
        GetResult getResult = (GetResult)value_;
        getResult.write(oprot);
        return;
      case PUT_RESULT:
        PutResult putResult = (PutResult)value_;
        putResult.write(oprot);
        return;
      case INCREMENT_RESULT:
        IncrementResult incrementResult = (IncrementResult)value_;
        incrementResult.write(oprot);
        return;
      case REMOVE_RESULT:
        RemoveResult removeResult = (RemoveResult)value_;
        removeResult.write(oprot);
        return;
      default:
        throw new IllegalStateException("Cannot write union with unknown field " + setField_);
    }
  }

  @Override
  protected Object tupleSchemeReadValue(libthrift091.protocol.TProtocol iprot, short fieldID) throws libthrift091.TException {
    _Fields setField = _Fields.findByThriftId(fieldID);
    if (setField != null) {
      switch (setField) {
        case GET_RESULT:
          GetResult getResult;
          getResult = new GetResult();
          getResult.read(iprot);
          return getResult;
        case PUT_RESULT:
          PutResult putResult;
          putResult = new PutResult();
          putResult.read(iprot);
          return putResult;
        case INCREMENT_RESULT:
          IncrementResult incrementResult;
          incrementResult = new IncrementResult();
          incrementResult.read(iprot);
          return incrementResult;
        case REMOVE_RESULT:
          RemoveResult removeResult;
          removeResult = new RemoveResult();
          removeResult.read(iprot);
          return removeResult;
        default:
          throw new IllegalStateException("setField wasn't null, but didn't match any of the case statements!");
      }
    } else {
      throw new TProtocolException("Couldn't find a field with field id " + fieldID);
    }
  }

  @Override
  protected void tupleSchemeWriteValue(libthrift091.protocol.TProtocol oprot) throws libthrift091.TException {
    switch (setField_) {
      case GET_RESULT:
        GetResult getResult = (GetResult)value_;
        getResult.write(oprot);
        return;
      case PUT_RESULT:
        PutResult putResult = (PutResult)value_;
        putResult.write(oprot);
        return;
      case INCREMENT_RESULT:
        IncrementResult incrementResult = (IncrementResult)value_;
        incrementResult.write(oprot);
        return;
      case REMOVE_RESULT:
        RemoveResult removeResult = (RemoveResult)value_;
        removeResult.write(oprot);
        return;
      default:
        throw new IllegalStateException("Cannot write union with unknown field " + setField_);
    }
  }

  @Override
  protected libthrift091.protocol.TField getFieldDesc(_Fields setField) {
    switch (setField) {
      case GET_RESULT:
        return GET_RESULT_FIELD_DESC;
      case PUT_RESULT:
        return PUT_RESULT_FIELD_DESC;
      case INCREMENT_RESULT:
        return INCREMENT_RESULT_FIELD_DESC;
      case REMOVE_RESULT:
        return REMOVE_RESULT_FIELD_DESC;
      default:
        throw new IllegalArgumentException("Unknown field id " + setField);
    }
  }

  @Override
  protected libthrift091.protocol.TStruct getStructDesc() {
    return STRUCT_DESC;
  }

  @Override
  protected _Fields enumForId(short id) {
    return _Fields.findByThriftIdOrThrow(id);
  }

  public _Fields fieldForId(int fieldId) {
    return _Fields.findByThriftId(fieldId);
  }


  public GetResult getGetResult() {
    if (getSetField() == _Fields.GET_RESULT) {
      return (GetResult)getFieldValue();
    } else {
      throw new RuntimeException("Cannot get field 'getResult' because union is currently set to " + getFieldDesc(getSetField()).name);
    }
  }

  public void setGetResult(GetResult value) {
    if (value == null) throw new NullPointerException();
    setField_ = _Fields.GET_RESULT;
    value_ = value;
  }

  public PutResult getPutResult() {
    if (getSetField() == _Fields.PUT_RESULT) {
      return (PutResult)getFieldValue();
    } else {
      throw new RuntimeException("Cannot get field 'putResult' because union is currently set to " + getFieldDesc(getSetField()).name);
    }
  }

  public void setPutResult(PutResult value) {
    if (value == null) throw new NullPointerException();
    setField_ = _Fields.PUT_RESULT;
    value_ = value;
  }

  public IncrementResult getIncrementResult() {
    if (getSetField() == _Fields.INCREMENT_RESULT) {
      return (IncrementResult)getFieldValue();
    } else {
      throw new RuntimeException("Cannot get field 'incrementResult' because union is currently set to " + getFieldDesc(getSetField()).name);
    }
  }

  public void setIncrementResult(IncrementResult value) {
    if (value == null) throw new NullPointerException();
    setField_ = _Fields.INCREMENT_RESULT;
    value_ = value;
  }

  public RemoveResult getRemoveResult() {
    if (getSetField() == _Fields.REMOVE_RESULT) {
      return (RemoveResult)getFieldValue();
    } else {
      throw new RuntimeException("Cannot get field 'removeResult' because union is currently set to " + getFieldDesc(getSetField()).name);
    }
  }

  public void setRemoveResult(RemoveResult value) {
    if (value == null) throw new NullPointerException();
    setField_ = _Fields.REMOVE_RESULT;
    value_ = value;
  }

  public boolean isSetGetResult() {
    return setField_ == _Fields.GET_RESULT;
  }


  public boolean isSetPutResult() {
    return setField_ == _Fields.PUT_RESULT;
  }


  public boolean isSetIncrementResult() {
    return setField_ == _Fields.INCREMENT_RESULT;
  }


  public boolean isSetRemoveResult() {
    return setField_ == _Fields.REMOVE_RESULT;
  }


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

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

  @Override
  public int compareTo(Result other) {
    int lastComparison = libthrift091.TBaseHelper.compareTo(getSetField(), other.getSetField());
    if (lastComparison == 0) {
      return libthrift091.TBaseHelper.compareTo(getFieldValue(), other.getFieldValue());
    }
    return lastComparison;
  }


  @Override
  public int hashCode() {
    List list = new ArrayList();
    list.add(this.getClass().getName());
    libthrift091.TFieldIdEnum setField = getSetField();
    if (setField != null) {
      list.add(setField.getThriftFieldId());
      Object value = getFieldValue();
      if (value instanceof libthrift091.TEnum) {
        list.add(((libthrift091.TEnum)getFieldValue()).getValue());
      } else {
        list.add(value);
      }
    }
    return list.hashCode();
  }
  private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
    try {
      write(new libthrift091.protocol.TCompactProtocol(new libthrift091.transport.TIOStreamTransport(out)));
    } catch (libthrift091.TException te) {
      throw new java.io.IOException(te);
    }
  }


  private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
    try {
      read(new libthrift091.protocol.TCompactProtocol(new libthrift091.transport.TIOStreamTransport(in)));
    } catch (libthrift091.TException te) {
      throw new java.io.IOException(te);
    }
  }


}