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

scray.service.qmodel.thriftjava.ScrayTQuery Maven / Gradle / Ivy

The newest version!
/**
 * Autogenerated by Thrift
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 */
package scray.service.qmodel.thriftjava;

import org.apache.commons.lang.builder.HashCodeBuilder;
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;

import org.apache.thrift.*;
import org.apache.thrift.async.*;
import org.apache.thrift.meta_data.*;
import org.apache.thrift.transport.*;
import org.apache.thrift.protocol.*;

// No additional import required for struct/union.

public class ScrayTQuery implements TBase, java.io.Serializable, Cloneable {
  private static final TStruct STRUCT_DESC = new TStruct("ScrayTQuery");

  private static final TField QUERY_INFO_FIELD_DESC = new TField("queryInfo", TType.STRUCT, (short)1);
  private static final TField VALUES_FIELD_DESC = new TField("values", TType.MAP, (short)2);
  private static final TField QUERY_EXPRESSION_FIELD_DESC = new TField("queryExpression", TType.STRING, (short)3);


  public ScrayTQueryInfo queryInfo;
  public Map values;
  public String queryExpression;

  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
  public enum _Fields implements TFieldIdEnum {
    QUERY_INFO((short)1, "queryInfo"),
    VALUES((short)2, "values"),
    QUERY_EXPRESSION((short)3, "queryExpression");
  
    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: // QUERY_INFO
          return QUERY_INFO;
        case 2: // VALUES
          return VALUES;
        case 3: // QUERY_EXPRESSION
          return QUERY_EXPRESSION;
        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, FieldMetaData> metaDataMap;
  static {
    Map<_Fields, FieldMetaData> tmpMap = new EnumMap<_Fields, FieldMetaData>(_Fields.class);
    tmpMap.put(_Fields.QUERY_INFO, new FieldMetaData("queryInfo", TFieldRequirementType.DEFAULT,
      new StructMetaData(TType.STRUCT, ScrayTQueryInfo.class)));
    tmpMap.put(_Fields.VALUES, new FieldMetaData("values", TFieldRequirementType.DEFAULT,
      new MapMetaData(TType.MAP,
            new FieldValueMetaData(TType.STRING),
            new FieldValueMetaData(TType.STRING))));
    tmpMap.put(_Fields.QUERY_EXPRESSION, new FieldMetaData("queryExpression", TFieldRequirementType.DEFAULT,
      new FieldValueMetaData(TType.STRING)));
    metaDataMap = Collections.unmodifiableMap(tmpMap);
    FieldMetaData.addStructMetaDataMap(ScrayTQuery.class, metaDataMap);
  }


  public ScrayTQuery() {
  }

  public ScrayTQuery(
    ScrayTQueryInfo queryInfo,
    Map values,
    String queryExpression)
  {
    this();
    this.queryInfo = queryInfo;
    this.values = values;
    this.queryExpression = queryExpression;
  }

  /**
   * Performs a deep copy on other.
   */
  public ScrayTQuery(ScrayTQuery other) {
    if (other.isSetQueryInfo()) {
      this.queryInfo = new ScrayTQueryInfo(other.queryInfo);
    }
    if (other.isSetValues()) {
      Map __this__values = new HashMap();
      for (Map.Entry other_element : other.values.entrySet()) {
        String other_element_key = other_element.getKey();
        ByteBuffer other_element_value = other_element.getValue();
        String __this__values_copy_key = other_element_key;
        ByteBuffer __this__values_copy_value = TBaseHelper.copyBinary(other_element_value);
        __this__values.put(__this__values_copy_key, __this__values_copy_value);
      }
      this.values = __this__values;
    }
    if (other.isSetQueryExpression()) {
      this.queryExpression = other.queryExpression;
    }
  }

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

  @java.lang.Override
  public void clear() {
    this.queryInfo = null;
    this.values = null;
    this.queryExpression = null;
  }

  public ScrayTQueryInfo getQueryInfo() {
    return this.queryInfo;
  }

  public ScrayTQuery setQueryInfo(ScrayTQueryInfo queryInfo) {
    this.queryInfo = queryInfo;
    
    return this;
  }

  public void unsetQueryInfo() {
    this.queryInfo = null;
  }

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

  public void setQueryInfoIsSet(boolean value) {
    if (!value) {
      this.queryInfo = null;
    }
  }

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

  public void putToValues(String key, ByteBuffer val) {
    if (this.values == null) {
      this.values = new HashMap();
    }
    this.values.put(key, val);
  }

  public Map getValues() {
    return this.values;
  }

  public ScrayTQuery setValues(Map values) {
    this.values = values;
    
    return this;
  }

  public void unsetValues() {
    this.values = null;
  }

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

  public void setValuesIsSet(boolean value) {
    if (!value) {
      this.values = null;
    }
  }

  public String getQueryExpression() {
    return this.queryExpression;
  }

  public ScrayTQuery setQueryExpression(String queryExpression) {
    this.queryExpression = queryExpression;
    
    return this;
  }

  public void unsetQueryExpression() {
    this.queryExpression = null;
  }

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

  public void setQueryExpressionIsSet(boolean value) {
    if (!value) {
      this.queryExpression = null;
    }
  }

  public void setFieldValue(_Fields field, Object value) {
    switch (field) {
    case QUERY_INFO:
      if (value == null) {
        unsetQueryInfo();
      } else {
        setQueryInfo((ScrayTQueryInfo)value);
      }
      break;
    case VALUES:
      if (value == null) {
        unsetValues();
      } else {
        setValues((Map)value);
      }
      break;
    case QUERY_EXPRESSION:
      if (value == null) {
        unsetQueryExpression();
      } else {
        setQueryExpression((String)value);
      }
      break;
    }
  }

  public Object getFieldValue(_Fields field) {
    switch (field) {
    case QUERY_INFO:
      return getQueryInfo();
    case VALUES:
      return getValues();
    case QUERY_EXPRESSION:
      return getQueryExpression();
    }
    throw new IllegalStateException();
  }

  /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
  public boolean isSet(_Fields field) {
    if (field == null) {
      throw new IllegalArgumentException();
    }

    switch (field) {
    case QUERY_INFO:
      return isSetQueryInfo();
    case VALUES:
      return isSetValues();
    case QUERY_EXPRESSION:
      return isSetQueryExpression();
    }
    throw new IllegalStateException();
  }

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

  public boolean equals(ScrayTQuery that) {
    if (that == null)
      return false;
    boolean this_present_queryInfo = true && this.isSetQueryInfo();
    boolean that_present_queryInfo = true && that.isSetQueryInfo();
    if (this_present_queryInfo || that_present_queryInfo) {
      if (!(this_present_queryInfo && that_present_queryInfo))
        return false;
      if (!this.queryInfo.equals(that.queryInfo))
        return false;
    }
    boolean this_present_values = true && this.isSetValues();
    boolean that_present_values = true && that.isSetValues();
    if (this_present_values || that_present_values) {
      if (!(this_present_values && that_present_values))
        return false;
      if (!this.values.equals(that.values))
        return false;
    }
    boolean this_present_queryExpression = true && this.isSetQueryExpression();
    boolean that_present_queryExpression = true && that.isSetQueryExpression();
    if (this_present_queryExpression || that_present_queryExpression) {
      if (!(this_present_queryExpression && that_present_queryExpression))
        return false;
      if (!this.queryExpression.equals(that.queryExpression))
        return false;
    }

    return true;
  }

  @java.lang.Override
  public int hashCode() {
    HashCodeBuilder builder = new HashCodeBuilder();
    boolean present_queryInfo = true && (isSetQueryInfo());
    builder.append(present_queryInfo);
    if (present_queryInfo)
      builder.append(queryInfo);
    boolean present_values = true && (isSetValues());
    builder.append(present_values);
    if (present_values)
      builder.append(values);
    boolean present_queryExpression = true && (isSetQueryExpression());
    builder.append(present_queryExpression);
    if (present_queryExpression)
      builder.append(queryExpression);
    return builder.toHashCode();
  }

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

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

    lastComparison = Boolean.valueOf(isSetQueryInfo()).compareTo(typedOther.isSetQueryInfo());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetQueryInfo()) {
      lastComparison = TBaseHelper.compareTo(this.queryInfo, typedOther.queryInfo);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetValues()).compareTo(typedOther.isSetValues());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetValues()) {
      lastComparison = TBaseHelper.compareTo(this.values, typedOther.values);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetQueryExpression()).compareTo(typedOther.isSetQueryExpression());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetQueryExpression()) {
      lastComparison = TBaseHelper.compareTo(this.queryExpression, typedOther.queryExpression);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    return 0;
  }

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


  public void read(TProtocol iprot) throws TException {
    TField field;
    iprot.readStructBegin();
    while (true)
    {
      field = iprot.readFieldBegin();
      if (field.type == TType.STOP) {
        break;
      }
      switch (field.id) {
        case 1: // QUERY_INFO
          if (field.type == TType.STRUCT) {
            this.queryInfo = new ScrayTQueryInfo();
            this.queryInfo.read(iprot);
          } else {
            TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 2: // VALUES
          if (field.type == TType.MAP) {
            {
            TMap _map4 = iprot.readMapBegin();
            this.values = new HashMap(2*_map4.size);
            for (int _i5 = 0; _i5 < _map4.size; ++_i5)
            {
              String _key6;
              ByteBuffer _val7;
              _key6 = iprot.readString();
              _val7 = iprot.readBinary();
              this.values.put(_key6, _val7);
            }
            iprot.readMapEnd();
            }
          } else {
            TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 3: // QUERY_EXPRESSION
          if (field.type == TType.STRING) {
            this.queryExpression = iprot.readString();
          } else {
            TProtocolUtil.skip(iprot, field.type);
          }
          break;
        default:
          TProtocolUtil.skip(iprot, field.type);
      }
      iprot.readFieldEnd();
    }
    iprot.readStructEnd();

    // check for required fields of primitive type, which can't be checked in the validate method
    validate();
  }

  public void write(TProtocol oprot) throws TException {
    validate();
    
    oprot.writeStructBegin(STRUCT_DESC);
    if (this.queryInfo != null) {
      oprot.writeFieldBegin(QUERY_INFO_FIELD_DESC);
      this.queryInfo.write(oprot);
      oprot.writeFieldEnd();
    }
    if (this.values != null) {
      oprot.writeFieldBegin(VALUES_FIELD_DESC);
      {
        oprot.writeMapBegin(new TMap(TType.STRING, TType.STRING, this.values.size()));
        for (Map.Entry _iter8 : this.values.entrySet())
        {
          oprot.writeString(_iter8.getKey());
          oprot.writeBinary(_iter8.getValue());
        }
        oprot.writeMapEnd();
      }
      oprot.writeFieldEnd();
    }
    if (this.queryExpression != null) {
      oprot.writeFieldBegin(QUERY_EXPRESSION_FIELD_DESC);
      oprot.writeString(this.queryExpression);
      oprot.writeFieldEnd();
    }
    oprot.writeFieldStop();
    oprot.writeStructEnd();
  }

  @java.lang.Override
  public String toString() {
    StringBuilder sb = new StringBuilder("ScrayTQuery(");
    boolean first = true;
    sb.append("queryInfo:");
    if (this.queryInfo == null) {
      sb.append("null");
    } else {
      sb.append(this.queryInfo);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("values:");
    if (this.values == null) {
      sb.append("null");
    } else {
      sb.append(this.values);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("queryExpression:");
    if (this.queryExpression == null) {
      sb.append("null");
    } else {
      sb.append(this.queryExpression);
    }
    first = false;
    sb.append(")");
    return sb.toString();
  }

  public void validate() throws TException {
    // check for required fields
  }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy