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

com.xiaomi.infra.galaxy.sds.thrift.Request 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 Request extends libthrift091.TUnion {
  private static final libthrift091.protocol.TStruct STRUCT_DESC = new libthrift091.protocol.TStruct("Request");
  private static final libthrift091.protocol.TField GET_REQUEST_FIELD_DESC = new libthrift091.protocol.TField("getRequest", libthrift091.protocol.TType.STRUCT, (short)1);
  private static final libthrift091.protocol.TField PUT_REQUEST_FIELD_DESC = new libthrift091.protocol.TField("putRequest", libthrift091.protocol.TType.STRUCT, (short)2);
  private static final libthrift091.protocol.TField INCREMENT_REQUEST_FIELD_DESC = new libthrift091.protocol.TField("incrementRequest", libthrift091.protocol.TType.STRUCT, (short)3);
  private static final libthrift091.protocol.TField REMOVE_REQUEST_FIELD_DESC = new libthrift091.protocol.TField("removeRequest", 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_REQUEST((short)1, "getRequest"),
    /**
     * 写入操作,不支持条件
     */
    PUT_REQUEST((short)2, "putRequest"),
    /**
     * 自增操作
     */
    INCREMENT_REQUEST((short)3, "incrementRequest"),
    /**
     * 删除操作,不支持条件
     */
    REMOVE_REQUEST((short)4, "removeRequest");

    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_REQUEST
          return GET_REQUEST;
        case 2: // PUT_REQUEST
          return PUT_REQUEST;
        case 3: // INCREMENT_REQUEST
          return INCREMENT_REQUEST;
        case 4: // REMOVE_REQUEST
          return REMOVE_REQUEST;
        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_REQUEST, new libthrift091.meta_data.FieldMetaData("getRequest", libthrift091.TFieldRequirementType.OPTIONAL, 
        new libthrift091.meta_data.StructMetaData(libthrift091.protocol.TType.STRUCT, GetRequest.class)));
    tmpMap.put(_Fields.PUT_REQUEST, new libthrift091.meta_data.FieldMetaData("putRequest", libthrift091.TFieldRequirementType.OPTIONAL, 
        new libthrift091.meta_data.StructMetaData(libthrift091.protocol.TType.STRUCT, PutRequest.class)));
    tmpMap.put(_Fields.INCREMENT_REQUEST, new libthrift091.meta_data.FieldMetaData("incrementRequest", libthrift091.TFieldRequirementType.OPTIONAL, 
        new libthrift091.meta_data.StructMetaData(libthrift091.protocol.TType.STRUCT, IncrementRequest.class)));
    tmpMap.put(_Fields.REMOVE_REQUEST, new libthrift091.meta_data.FieldMetaData("removeRequest", libthrift091.TFieldRequirementType.OPTIONAL, 
        new libthrift091.meta_data.StructMetaData(libthrift091.protocol.TType.STRUCT, RemoveRequest.class)));
    metaDataMap = Collections.unmodifiableMap(tmpMap);
    libthrift091.meta_data.FieldMetaData.addStructMetaDataMap(Request.class, metaDataMap);
  }

  public Request() {
    super();
  }

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

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

  public static Request getRequest(GetRequest value) {
    Request x = new Request();
    x.setGetRequest(value);
    return x;
  }

  public static Request putRequest(PutRequest value) {
    Request x = new Request();
    x.setPutRequest(value);
    return x;
  }

  public static Request incrementRequest(IncrementRequest value) {
    Request x = new Request();
    x.setIncrementRequest(value);
    return x;
  }

  public static Request removeRequest(RemoveRequest value) {
    Request x = new Request();
    x.setRemoveRequest(value);
    return x;
  }


  @Override
  protected void checkType(_Fields setField, Object value) throws ClassCastException {
    switch (setField) {
      case GET_REQUEST:
        if (value instanceof GetRequest) {
          break;
        }
        throw new ClassCastException("Was expecting value of type GetRequest for field 'getRequest', but got " + value.getClass().getSimpleName());
      case PUT_REQUEST:
        if (value instanceof PutRequest) {
          break;
        }
        throw new ClassCastException("Was expecting value of type PutRequest for field 'putRequest', but got " + value.getClass().getSimpleName());
      case INCREMENT_REQUEST:
        if (value instanceof IncrementRequest) {
          break;
        }
        throw new ClassCastException("Was expecting value of type IncrementRequest for field 'incrementRequest', but got " + value.getClass().getSimpleName());
      case REMOVE_REQUEST:
        if (value instanceof RemoveRequest) {
          break;
        }
        throw new ClassCastException("Was expecting value of type RemoveRequest for field 'removeRequest', 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_REQUEST:
          if (field.type == GET_REQUEST_FIELD_DESC.type) {
            GetRequest getRequest;
            getRequest = new GetRequest();
            getRequest.read(iprot);
            return getRequest;
          } else {
            libthrift091.protocol.TProtocolUtil.skip(iprot, field.type);
            return null;
          }
        case PUT_REQUEST:
          if (field.type == PUT_REQUEST_FIELD_DESC.type) {
            PutRequest putRequest;
            putRequest = new PutRequest();
            putRequest.read(iprot);
            return putRequest;
          } else {
            libthrift091.protocol.TProtocolUtil.skip(iprot, field.type);
            return null;
          }
        case INCREMENT_REQUEST:
          if (field.type == INCREMENT_REQUEST_FIELD_DESC.type) {
            IncrementRequest incrementRequest;
            incrementRequest = new IncrementRequest();
            incrementRequest.read(iprot);
            return incrementRequest;
          } else {
            libthrift091.protocol.TProtocolUtil.skip(iprot, field.type);
            return null;
          }
        case REMOVE_REQUEST:
          if (field.type == REMOVE_REQUEST_FIELD_DESC.type) {
            RemoveRequest removeRequest;
            removeRequest = new RemoveRequest();
            removeRequest.read(iprot);
            return removeRequest;
          } 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_REQUEST:
        GetRequest getRequest = (GetRequest)value_;
        getRequest.write(oprot);
        return;
      case PUT_REQUEST:
        PutRequest putRequest = (PutRequest)value_;
        putRequest.write(oprot);
        return;
      case INCREMENT_REQUEST:
        IncrementRequest incrementRequest = (IncrementRequest)value_;
        incrementRequest.write(oprot);
        return;
      case REMOVE_REQUEST:
        RemoveRequest removeRequest = (RemoveRequest)value_;
        removeRequest.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_REQUEST:
          GetRequest getRequest;
          getRequest = new GetRequest();
          getRequest.read(iprot);
          return getRequest;
        case PUT_REQUEST:
          PutRequest putRequest;
          putRequest = new PutRequest();
          putRequest.read(iprot);
          return putRequest;
        case INCREMENT_REQUEST:
          IncrementRequest incrementRequest;
          incrementRequest = new IncrementRequest();
          incrementRequest.read(iprot);
          return incrementRequest;
        case REMOVE_REQUEST:
          RemoveRequest removeRequest;
          removeRequest = new RemoveRequest();
          removeRequest.read(iprot);
          return removeRequest;
        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_REQUEST:
        GetRequest getRequest = (GetRequest)value_;
        getRequest.write(oprot);
        return;
      case PUT_REQUEST:
        PutRequest putRequest = (PutRequest)value_;
        putRequest.write(oprot);
        return;
      case INCREMENT_REQUEST:
        IncrementRequest incrementRequest = (IncrementRequest)value_;
        incrementRequest.write(oprot);
        return;
      case REMOVE_REQUEST:
        RemoveRequest removeRequest = (RemoveRequest)value_;
        removeRequest.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_REQUEST:
        return GET_REQUEST_FIELD_DESC;
      case PUT_REQUEST:
        return PUT_REQUEST_FIELD_DESC;
      case INCREMENT_REQUEST:
        return INCREMENT_REQUEST_FIELD_DESC;
      case REMOVE_REQUEST:
        return REMOVE_REQUEST_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 GetRequest getGetRequest() {
    if (getSetField() == _Fields.GET_REQUEST) {
      return (GetRequest)getFieldValue();
    } else {
      throw new RuntimeException("Cannot get field 'getRequest' because union is currently set to " + getFieldDesc(getSetField()).name);
    }
  }

  /**
   * 随机读操作
   */
  public void setGetRequest(GetRequest value) {
    if (value == null) throw new NullPointerException();
    setField_ = _Fields.GET_REQUEST;
    value_ = value;
  }

  /**
   * 写入操作,不支持条件
   */
  public PutRequest getPutRequest() {
    if (getSetField() == _Fields.PUT_REQUEST) {
      return (PutRequest)getFieldValue();
    } else {
      throw new RuntimeException("Cannot get field 'putRequest' because union is currently set to " + getFieldDesc(getSetField()).name);
    }
  }

  /**
   * 写入操作,不支持条件
   */
  public void setPutRequest(PutRequest value) {
    if (value == null) throw new NullPointerException();
    setField_ = _Fields.PUT_REQUEST;
    value_ = value;
  }

  /**
   * 自增操作
   */
  public IncrementRequest getIncrementRequest() {
    if (getSetField() == _Fields.INCREMENT_REQUEST) {
      return (IncrementRequest)getFieldValue();
    } else {
      throw new RuntimeException("Cannot get field 'incrementRequest' because union is currently set to " + getFieldDesc(getSetField()).name);
    }
  }

  /**
   * 自增操作
   */
  public void setIncrementRequest(IncrementRequest value) {
    if (value == null) throw new NullPointerException();
    setField_ = _Fields.INCREMENT_REQUEST;
    value_ = value;
  }

  /**
   * 删除操作,不支持条件
   */
  public RemoveRequest getRemoveRequest() {
    if (getSetField() == _Fields.REMOVE_REQUEST) {
      return (RemoveRequest)getFieldValue();
    } else {
      throw new RuntimeException("Cannot get field 'removeRequest' because union is currently set to " + getFieldDesc(getSetField()).name);
    }
  }

  /**
   * 删除操作,不支持条件
   */
  public void setRemoveRequest(RemoveRequest value) {
    if (value == null) throw new NullPointerException();
    setField_ = _Fields.REMOVE_REQUEST;
    value_ = value;
  }

  public boolean isSetGetRequest() {
    return setField_ == _Fields.GET_REQUEST;
  }


  public boolean isSetPutRequest() {
    return setField_ == _Fields.PUT_REQUEST;
  }


  public boolean isSetIncrementRequest() {
    return setField_ == _Fields.INCREMENT_REQUEST;
  }


  public boolean isSetRemoveRequest() {
    return setField_ == _Fields.REMOVE_REQUEST;
  }


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

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

  @Override
  public int compareTo(Request 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);
    }
  }


}