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

tech.aroma.thrift.reactions.Reaction Maven / Gradle / Ivy

Go to download

Part of the Aroma Project. This project contains the Service and Model Definitions. From this the Server and Client interfaces are generated for the Aroma Service.

There is a newer version: 2.2
Show newest version
/**
 * Autogenerated by Thrift Compiler (0.9.3)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
package tech.aroma.thrift.reactions;

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 javax.annotation.Generated;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
@Generated(value = "Autogenerated by Thrift Compiler (0.9.3)", date = "2016-05-10")
public class Reaction implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable {
  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Reaction");

  private static final org.apache.thrift.protocol.TField MATCHERS_FIELD_DESC = new org.apache.thrift.protocol.TField("matchers", org.apache.thrift.protocol.TType.LIST, (short)1);
  private static final org.apache.thrift.protocol.TField ACTIONS_FIELD_DESC = new org.apache.thrift.protocol.TField("actions", org.apache.thrift.protocol.TType.LIST, (short)2);
  private static final org.apache.thrift.protocol.TField NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("name", org.apache.thrift.protocol.TType.STRING, (short)3);

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

  public List matchers; // required
  public List actions; // required
  public String name; // 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 {
    MATCHERS((short)1, "matchers"),
    ACTIONS((short)2, "actions"),
    NAME((short)3, "name");

    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: // MATCHERS
          return MATCHERS;
        case 2: // ACTIONS
          return ACTIONS;
        case 3: // NAME
          return NAME;
        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
  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.MATCHERS, new org.apache.thrift.meta_data.FieldMetaData("matchers", 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, AromaMatcher.class))));
    tmpMap.put(_Fields.ACTIONS, new org.apache.thrift.meta_data.FieldMetaData("actions", 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, AromaAction.class))));
    tmpMap.put(_Fields.NAME, new org.apache.thrift.meta_data.FieldMetaData("name", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    metaDataMap = Collections.unmodifiableMap(tmpMap);
    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Reaction.class, metaDataMap);
  }

  public Reaction() {
    this.matchers = new ArrayList();

    this.actions = new ArrayList();

  }

  public Reaction(
    List matchers,
    List actions,
    String name)
  {
    this();
    this.matchers = matchers;
    this.actions = actions;
    this.name = name;
  }

  /**
   * Performs a deep copy on other.
   */
  public Reaction(Reaction other) {
    if (other.isSetMatchers()) {
      List __this__matchers = new ArrayList(other.matchers.size());
      for (AromaMatcher other_element : other.matchers) {
        __this__matchers.add(new AromaMatcher(other_element));
      }
      this.matchers = __this__matchers;
    }
    if (other.isSetActions()) {
      List __this__actions = new ArrayList(other.actions.size());
      for (AromaAction other_element : other.actions) {
        __this__actions.add(new AromaAction(other_element));
      }
      this.actions = __this__actions;
    }
    if (other.isSetName()) {
      this.name = other.name;
    }
  }

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

  @Override
  public void clear() {
    this.matchers = new ArrayList();

    this.actions = new ArrayList();

    this.name = null;
  }

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

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

  public void addToMatchers(AromaMatcher elem) {
    if (this.matchers == null) {
      this.matchers = new ArrayList();
    }
    this.matchers.add(elem);
  }

  public List getMatchers() {
    return this.matchers;
  }

  public Reaction setMatchers(List matchers) {
    this.matchers = matchers;
    return this;
  }

  public void unsetMatchers() {
    this.matchers = null;
  }

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

  public void setMatchersIsSet(boolean value) {
    if (!value) {
      this.matchers = null;
    }
  }

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

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

  public void addToActions(AromaAction elem) {
    if (this.actions == null) {
      this.actions = new ArrayList();
    }
    this.actions.add(elem);
  }

  public List getActions() {
    return this.actions;
  }

  public Reaction setActions(List actions) {
    this.actions = actions;
    return this;
  }

  public void unsetActions() {
    this.actions = null;
  }

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

  public void setActionsIsSet(boolean value) {
    if (!value) {
      this.actions = null;
    }
  }

  public String getName() {
    return this.name;
  }

  public Reaction setName(String name) {
    this.name = name;
    return this;
  }

  public void unsetName() {
    this.name = null;
  }

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

  public void setNameIsSet(boolean value) {
    if (!value) {
      this.name = null;
    }
  }

  public void setFieldValue(_Fields field, Object value) {
    switch (field) {
    case MATCHERS:
      if (value == null) {
        unsetMatchers();
      } else {
        setMatchers((List)value);
      }
      break;

    case ACTIONS:
      if (value == null) {
        unsetActions();
      } else {
        setActions((List)value);
      }
      break;

    case NAME:
      if (value == null) {
        unsetName();
      } else {
        setName((String)value);
      }
      break;

    }
  }

  public Object getFieldValue(_Fields field) {
    switch (field) {
    case MATCHERS:
      return getMatchers();

    case ACTIONS:
      return getActions();

    case NAME:
      return getName();

    }
    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 MATCHERS:
      return isSetMatchers();
    case ACTIONS:
      return isSetActions();
    case NAME:
      return isSetName();
    }
    throw new IllegalStateException();
  }

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

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

    boolean this_present_matchers = true && this.isSetMatchers();
    boolean that_present_matchers = true && that.isSetMatchers();
    if (this_present_matchers || that_present_matchers) {
      if (!(this_present_matchers && that_present_matchers))
        return false;
      if (!this.matchers.equals(that.matchers))
        return false;
    }

    boolean this_present_actions = true && this.isSetActions();
    boolean that_present_actions = true && that.isSetActions();
    if (this_present_actions || that_present_actions) {
      if (!(this_present_actions && that_present_actions))
        return false;
      if (!this.actions.equals(that.actions))
        return false;
    }

    boolean this_present_name = true && this.isSetName();
    boolean that_present_name = true && that.isSetName();
    if (this_present_name || that_present_name) {
      if (!(this_present_name && that_present_name))
        return false;
      if (!this.name.equals(that.name))
        return false;
    }

    return true;
  }

  @Override
  public int hashCode() {
    List list = new ArrayList();

    boolean present_matchers = true && (isSetMatchers());
    list.add(present_matchers);
    if (present_matchers)
      list.add(matchers);

    boolean present_actions = true && (isSetActions());
    list.add(present_actions);
    if (present_actions)
      list.add(actions);

    boolean present_name = true && (isSetName());
    list.add(present_name);
    if (present_name)
      list.add(name);

    return list.hashCode();
  }

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

    int lastComparison = 0;

    lastComparison = Boolean.valueOf(isSetMatchers()).compareTo(other.isSetMatchers());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetMatchers()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.matchers, other.matchers);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetActions()).compareTo(other.isSetActions());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetActions()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.actions, other.actions);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetName()).compareTo(other.isSetName());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetName()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.name, other.name);
      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("Reaction(");
    boolean first = true;

    sb.append("matchers:");
    if (this.matchers == null) {
      sb.append("null");
    } else {
      sb.append(this.matchers);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("actions:");
    if (this.actions == null) {
      sb.append("null");
    } else {
      sb.append(this.actions);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("name:");
    if (this.name == null) {
      sb.append("null");
    } else {
      sb.append(this.name);
    }
    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 {
      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 ReactionStandardSchemeFactory implements SchemeFactory {
    public ReactionStandardScheme getScheme() {
      return new ReactionStandardScheme();
    }
  }

  private static class ReactionStandardScheme extends StandardScheme {

    public void read(org.apache.thrift.protocol.TProtocol iprot, Reaction 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: // MATCHERS
            if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
              {
                org.apache.thrift.protocol.TList _list16 = iprot.readListBegin();
                struct.matchers = new ArrayList(_list16.size);
                AromaMatcher _elem17;
                for (int _i18 = 0; _i18 < _list16.size; ++_i18)
                {
                  _elem17 = new AromaMatcher();
                  _elem17.read(iprot);
                  struct.matchers.add(_elem17);
                }
                iprot.readListEnd();
              }
              struct.setMatchersIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 2: // ACTIONS
            if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
              {
                org.apache.thrift.protocol.TList _list19 = iprot.readListBegin();
                struct.actions = new ArrayList(_list19.size);
                AromaAction _elem20;
                for (int _i21 = 0; _i21 < _list19.size; ++_i21)
                {
                  _elem20 = new AromaAction();
                  _elem20.read(iprot);
                  struct.actions.add(_elem20);
                }
                iprot.readListEnd();
              }
              struct.setActionsIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 3: // NAME
            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
              struct.name = iprot.readString();
              struct.setNameIsSet(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, Reaction struct) throws org.apache.thrift.TException {
      struct.validate();

      oprot.writeStructBegin(STRUCT_DESC);
      if (struct.matchers != null) {
        oprot.writeFieldBegin(MATCHERS_FIELD_DESC);
        {
          oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.matchers.size()));
          for (AromaMatcher _iter22 : struct.matchers)
          {
            _iter22.write(oprot);
          }
          oprot.writeListEnd();
        }
        oprot.writeFieldEnd();
      }
      if (struct.actions != null) {
        oprot.writeFieldBegin(ACTIONS_FIELD_DESC);
        {
          oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.actions.size()));
          for (AromaAction _iter23 : struct.actions)
          {
            _iter23.write(oprot);
          }
          oprot.writeListEnd();
        }
        oprot.writeFieldEnd();
      }
      if (struct.name != null) {
        oprot.writeFieldBegin(NAME_FIELD_DESC);
        oprot.writeString(struct.name);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

  }

  private static class ReactionTupleSchemeFactory implements SchemeFactory {
    public ReactionTupleScheme getScheme() {
      return new ReactionTupleScheme();
    }
  }

  private static class ReactionTupleScheme extends TupleScheme {

    @Override
    public void write(org.apache.thrift.protocol.TProtocol prot, Reaction struct) throws org.apache.thrift.TException {
      TTupleProtocol oprot = (TTupleProtocol) prot;
      BitSet optionals = new BitSet();
      if (struct.isSetMatchers()) {
        optionals.set(0);
      }
      if (struct.isSetActions()) {
        optionals.set(1);
      }
      if (struct.isSetName()) {
        optionals.set(2);
      }
      oprot.writeBitSet(optionals, 3);
      if (struct.isSetMatchers()) {
        {
          oprot.writeI32(struct.matchers.size());
          for (AromaMatcher _iter24 : struct.matchers)
          {
            _iter24.write(oprot);
          }
        }
      }
      if (struct.isSetActions()) {
        {
          oprot.writeI32(struct.actions.size());
          for (AromaAction _iter25 : struct.actions)
          {
            _iter25.write(oprot);
          }
        }
      }
      if (struct.isSetName()) {
        oprot.writeString(struct.name);
      }
    }

    @Override
    public void read(org.apache.thrift.protocol.TProtocol prot, Reaction struct) throws org.apache.thrift.TException {
      TTupleProtocol iprot = (TTupleProtocol) prot;
      BitSet incoming = iprot.readBitSet(3);
      if (incoming.get(0)) {
        {
          org.apache.thrift.protocol.TList _list26 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
          struct.matchers = new ArrayList(_list26.size);
          AromaMatcher _elem27;
          for (int _i28 = 0; _i28 < _list26.size; ++_i28)
          {
            _elem27 = new AromaMatcher();
            _elem27.read(iprot);
            struct.matchers.add(_elem27);
          }
        }
        struct.setMatchersIsSet(true);
      }
      if (incoming.get(1)) {
        {
          org.apache.thrift.protocol.TList _list29 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
          struct.actions = new ArrayList(_list29.size);
          AromaAction _elem30;
          for (int _i31 = 0; _i31 < _list29.size; ++_i31)
          {
            _elem30 = new AromaAction();
            _elem30.read(iprot);
            struct.actions.add(_elem30);
          }
        }
        struct.setActionsIsSet(true);
      }
      if (incoming.get(2)) {
        struct.name = iprot.readString();
        struct.setNameIsSet(true);
      }
    }
  }

}