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

com.twitter.flockdb.thrift.ExecuteOperations Maven / Gradle / Ivy

/**
 * Autogenerated by Thrift Compiler (0.8.0)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
package com.twitter.flockdb.thrift;

import org.apache.commons.lang.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 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 ExecuteOperations implements org.apache.thrift.TBase, java.io.Serializable, Cloneable {
  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ExecuteOperations");

  private static final org.apache.thrift.protocol.TField OPERATIONS_FIELD_DESC = new org.apache.thrift.protocol.TField("operations", org.apache.thrift.protocol.TType.LIST, (short)1);
  private static final org.apache.thrift.protocol.TField EXECUTE_AT_FIELD_DESC = new org.apache.thrift.protocol.TField("execute_at", org.apache.thrift.protocol.TType.I32, (short)2);
  private static final org.apache.thrift.protocol.TField PRIORITY_FIELD_DESC = new org.apache.thrift.protocol.TField("priority", org.apache.thrift.protocol.TType.I32, (short)3);

  private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>();
  static {
    schemes.put(StandardScheme.class, new ExecuteOperationsStandardSchemeFactory());
    schemes.put(TupleScheme.class, new ExecuteOperationsTupleSchemeFactory());
  }

  public List operations; // required
  public int execute_at; // optional
  /**
   * 
   * @see Priority
   */
  public Priority priority; // required

  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
  public enum _Fields implements org.apache.thrift.TFieldIdEnum {
    OPERATIONS((short)1, "operations"),
    EXECUTE_AT((short)2, "execute_at"),
    /**
     * 
     * @see Priority
     */
    PRIORITY((short)3, "priority");

    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: // OPERATIONS
          return OPERATIONS;
        case 2: // EXECUTE_AT
          return EXECUTE_AT;
        case 3: // PRIORITY
          return PRIORITY;
        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 __EXECUTE_AT_ISSET_ID = 0;
  private BitSet __isset_bit_vector = new BitSet(1);
  private _Fields optionals[] = {_Fields.EXECUTE_AT};
  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.OPERATIONS, new org.apache.thrift.meta_data.FieldMetaData("operations", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, 
            new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, ExecuteOperation.class))));
    tmpMap.put(_Fields.EXECUTE_AT, new org.apache.thrift.meta_data.FieldMetaData("execute_at", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
    tmpMap.put(_Fields.PRIORITY, new org.apache.thrift.meta_data.FieldMetaData("priority", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, Priority.class)));
    metaDataMap = Collections.unmodifiableMap(tmpMap);
    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(ExecuteOperations.class, metaDataMap);
  }

  public ExecuteOperations() {
  }

  public ExecuteOperations(
    List operations,
    Priority priority)
  {
    this();
    this.operations = operations;
    this.priority = priority;
  }

  /**
   * Performs a deep copy on other.
   */
  public ExecuteOperations(ExecuteOperations other) {
    __isset_bit_vector.clear();
    __isset_bit_vector.or(other.__isset_bit_vector);
    if (other.isSetOperations()) {
      List __this__operations = new ArrayList();
      for (ExecuteOperation other_element : other.operations) {
        __this__operations.add(new ExecuteOperation(other_element));
      }
      this.operations = __this__operations;
    }
    this.execute_at = other.execute_at;
    if (other.isSetPriority()) {
      this.priority = other.priority;
    }
  }

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

  @Override
  public void clear() {
    this.operations = null;
    setExecute_atIsSet(false);
    this.execute_at = 0;
    this.priority = null;
  }

  public int getOperationsSize() {
    return (this.operations == null) ? 0 : this.operations.size();
  }

  public java.util.Iterator getOperationsIterator() {
    return (this.operations == null) ? null : this.operations.iterator();
  }

  public void addToOperations(ExecuteOperation elem) {
    if (this.operations == null) {
      this.operations = new ArrayList();
    }
    this.operations.add(elem);
  }

  public List getOperations() {
    return this.operations;
  }

  public ExecuteOperations setOperations(List operations) {
    this.operations = operations;
    return this;
  }

  public void unsetOperations() {
    this.operations = null;
  }

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

  public void setOperationsIsSet(boolean value) {
    if (!value) {
      this.operations = null;
    }
  }

  public int getExecute_at() {
    return this.execute_at;
  }

  public ExecuteOperations setExecute_at(int execute_at) {
    this.execute_at = execute_at;
    setExecute_atIsSet(true);
    return this;
  }

  public void unsetExecute_at() {
    __isset_bit_vector.clear(__EXECUTE_AT_ISSET_ID);
  }

  /** Returns true if field execute_at is set (has been assigned a value) and false otherwise */
  public boolean isSetExecute_at() {
    return __isset_bit_vector.get(__EXECUTE_AT_ISSET_ID);
  }

  public void setExecute_atIsSet(boolean value) {
    __isset_bit_vector.set(__EXECUTE_AT_ISSET_ID, value);
  }

  /**
   * 
   * @see Priority
   */
  public Priority getPriority() {
    return this.priority;
  }

  /**
   * 
   * @see Priority
   */
  public ExecuteOperations setPriority(Priority priority) {
    this.priority = priority;
    return this;
  }

  public void unsetPriority() {
    this.priority = null;
  }

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

  public void setPriorityIsSet(boolean value) {
    if (!value) {
      this.priority = null;
    }
  }

  public void setFieldValue(_Fields field, Object value) {
    switch (field) {
    case OPERATIONS:
      if (value == null) {
        unsetOperations();
      } else {
        setOperations((List)value);
      }
      break;

    case EXECUTE_AT:
      if (value == null) {
        unsetExecute_at();
      } else {
        setExecute_at((Integer)value);
      }
      break;

    case PRIORITY:
      if (value == null) {
        unsetPriority();
      } else {
        setPriority((Priority)value);
      }
      break;

    }
  }

  public Object getFieldValue(_Fields field) {
    switch (field) {
    case OPERATIONS:
      return getOperations();

    case EXECUTE_AT:
      return Integer.valueOf(getExecute_at());

    case PRIORITY:
      return getPriority();

    }
    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 OPERATIONS:
      return isSetOperations();
    case EXECUTE_AT:
      return isSetExecute_at();
    case PRIORITY:
      return isSetPriority();
    }
    throw new IllegalStateException();
  }

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

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

    boolean this_present_operations = true && this.isSetOperations();
    boolean that_present_operations = true && that.isSetOperations();
    if (this_present_operations || that_present_operations) {
      if (!(this_present_operations && that_present_operations))
        return false;
      if (!this.operations.equals(that.operations))
        return false;
    }

    boolean this_present_execute_at = true && this.isSetExecute_at();
    boolean that_present_execute_at = true && that.isSetExecute_at();
    if (this_present_execute_at || that_present_execute_at) {
      if (!(this_present_execute_at && that_present_execute_at))
        return false;
      if (this.execute_at != that.execute_at)
        return false;
    }

    boolean this_present_priority = true && this.isSetPriority();
    boolean that_present_priority = true && that.isSetPriority();
    if (this_present_priority || that_present_priority) {
      if (!(this_present_priority && that_present_priority))
        return false;
      if (!this.priority.equals(that.priority))
        return false;
    }

    return true;
  }

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

    boolean present_operations = true && (isSetOperations());
    builder.append(present_operations);
    if (present_operations)
      builder.append(operations);

    boolean present_execute_at = true && (isSetExecute_at());
    builder.append(present_execute_at);
    if (present_execute_at)
      builder.append(execute_at);

    boolean present_priority = true && (isSetPriority());
    builder.append(present_priority);
    if (present_priority)
      builder.append(priority.getValue());

    return builder.toHashCode();
  }

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

    int lastComparison = 0;
    ExecuteOperations typedOther = (ExecuteOperations)other;

    lastComparison = Boolean.valueOf(isSetOperations()).compareTo(typedOther.isSetOperations());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetOperations()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.operations, typedOther.operations);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetExecute_at()).compareTo(typedOther.isSetExecute_at());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetExecute_at()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.execute_at, typedOther.execute_at);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetPriority()).compareTo(typedOther.isSetPriority());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetPriority()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.priority, typedOther.priority);
      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("ExecuteOperations(");
    boolean first = true;

    sb.append("operations:");
    if (this.operations == null) {
      sb.append("null");
    } else {
      sb.append(this.operations);
    }
    first = false;
    if (isSetExecute_at()) {
      if (!first) sb.append(", ");
      sb.append("execute_at:");
      sb.append(this.execute_at);
      first = false;
    }
    if (!first) sb.append(", ");
    sb.append("priority:");
    if (this.priority == null) {
      sb.append("null");
    } else {
      sb.append(this.priority);
    }
    first = false;
    sb.append(")");
    return sb.toString();
  }

  public void validate() throws org.apache.thrift.TException {
    // check for required fields
  }

  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_bit_vector = new BitSet(1);
      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 ExecuteOperationsStandardSchemeFactory implements SchemeFactory {
    public ExecuteOperationsStandardScheme getScheme() {
      return new ExecuteOperationsStandardScheme();
    }
  }

  private static class ExecuteOperationsStandardScheme extends StandardScheme {

    public void read(org.apache.thrift.protocol.TProtocol iprot, ExecuteOperations 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: // OPERATIONS
            if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
              {
                org.apache.thrift.protocol.TList _list8 = iprot.readListBegin();
                struct.operations = new ArrayList(_list8.size);
                for (int _i9 = 0; _i9 < _list8.size; ++_i9)
                {
                  ExecuteOperation _elem10; // required
                  _elem10 = new ExecuteOperation();
                  _elem10.read(iprot);
                  struct.operations.add(_elem10);
                }
                iprot.readListEnd();
              }
              struct.setOperationsIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 2: // EXECUTE_AT
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.execute_at = iprot.readI32();
              struct.setExecute_atIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 3: // PRIORITY
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.priority = Priority.findByValue(iprot.readI32());
              struct.setPriorityIsSet(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, ExecuteOperations struct) throws org.apache.thrift.TException {
      struct.validate();

      oprot.writeStructBegin(STRUCT_DESC);
      if (struct.operations != null) {
        oprot.writeFieldBegin(OPERATIONS_FIELD_DESC);
        {
          oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.operations.size()));
          for (ExecuteOperation _iter11 : struct.operations)
          {
            _iter11.write(oprot);
          }
          oprot.writeListEnd();
        }
        oprot.writeFieldEnd();
      }
      if (struct.isSetExecute_at()) {
        oprot.writeFieldBegin(EXECUTE_AT_FIELD_DESC);
        oprot.writeI32(struct.execute_at);
        oprot.writeFieldEnd();
      }
      if (struct.priority != null) {
        oprot.writeFieldBegin(PRIORITY_FIELD_DESC);
        oprot.writeI32(struct.priority.getValue());
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

  }

  private static class ExecuteOperationsTupleSchemeFactory implements SchemeFactory {
    public ExecuteOperationsTupleScheme getScheme() {
      return new ExecuteOperationsTupleScheme();
    }
  }

  private static class ExecuteOperationsTupleScheme extends TupleScheme {

    @Override
    public void write(org.apache.thrift.protocol.TProtocol prot, ExecuteOperations struct) throws org.apache.thrift.TException {
      TTupleProtocol oprot = (TTupleProtocol) prot;
      BitSet optionals = new BitSet();
      if (struct.isSetOperations()) {
        optionals.set(0);
      }
      if (struct.isSetExecute_at()) {
        optionals.set(1);
      }
      if (struct.isSetPriority()) {
        optionals.set(2);
      }
      oprot.writeBitSet(optionals, 3);
      if (struct.isSetOperations()) {
        {
          oprot.writeI32(struct.operations.size());
          for (ExecuteOperation _iter12 : struct.operations)
          {
            _iter12.write(oprot);
          }
        }
      }
      if (struct.isSetExecute_at()) {
        oprot.writeI32(struct.execute_at);
      }
      if (struct.isSetPriority()) {
        oprot.writeI32(struct.priority.getValue());
      }
    }

    @Override
    public void read(org.apache.thrift.protocol.TProtocol prot, ExecuteOperations struct) throws org.apache.thrift.TException {
      TTupleProtocol iprot = (TTupleProtocol) prot;
      BitSet incoming = iprot.readBitSet(3);
      if (incoming.get(0)) {
        {
          org.apache.thrift.protocol.TList _list13 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
          struct.operations = new ArrayList(_list13.size);
          for (int _i14 = 0; _i14 < _list13.size; ++_i14)
          {
            ExecuteOperation _elem15; // required
            _elem15 = new ExecuteOperation();
            _elem15.read(iprot);
            struct.operations.add(_elem15);
          }
        }
        struct.setOperationsIsSet(true);
      }
      if (incoming.get(1)) {
        struct.execute_at = iprot.readI32();
        struct.setExecute_atIsSet(true);
      }
      if (incoming.get(2)) {
        struct.priority = Priority.findByValue(iprot.readI32());
        struct.setPriorityIsSet(true);
      }
    }
  }

}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy