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

org.apache.distributedlog.benchmark.thrift.Message Maven / Gradle / Ivy

/**
 * Autogenerated by Thrift
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 */
package org.apache.distributedlog.benchmark.thrift;

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 Message implements TBase, java.io.Serializable, Cloneable {
  private static final TStruct STRUCT_DESC = new TStruct("Message");

  private static final TField PUBLISH_TIME_FIELD_DESC = new TField("publishTime", TType.I64, (short)1);
  private static final TField PAY_LOAD_FIELD_DESC = new TField("payLoad", TType.STRING, (short)2);


  public long publishTime;
  public ByteBuffer payLoad;

  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
  public enum _Fields implements TFieldIdEnum {
    PUBLISH_TIME((short)1, "publishTime"),
    PAY_LOAD((short)2, "payLoad");
  
    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: // PUBLISH_TIME
  	return PUBLISH_TIME;
        case 2: // PAY_LOAD
  	return PAY_LOAD;
        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 __PUBLISHTIME_ISSET_ID = 0;
  private BitSet __isset_bit_vector = new BitSet(1);

  public static final Map<_Fields, FieldMetaData> metaDataMap;
  static {
    Map<_Fields, FieldMetaData> tmpMap = new EnumMap<_Fields, FieldMetaData>(_Fields.class);
    tmpMap.put(_Fields.PUBLISH_TIME, new FieldMetaData("publishTime", TFieldRequirementType.DEFAULT,
      new FieldValueMetaData(TType.I64)));
    tmpMap.put(_Fields.PAY_LOAD, new FieldMetaData("payLoad", TFieldRequirementType.DEFAULT,
      new FieldValueMetaData(TType.STRING)));
    metaDataMap = Collections.unmodifiableMap(tmpMap);
    FieldMetaData.addStructMetaDataMap(Message.class, metaDataMap);
  }


  public Message() {
  }

  public Message(
    long publishTime,
    ByteBuffer payLoad)
  {
    this();
    this.publishTime = publishTime;
    setPublishTimeIsSet(true);
    this.payLoad = payLoad;
  }

  /**
   * Performs a deep copy on other.
   */
  public Message(Message other) {
    __isset_bit_vector.clear();
    __isset_bit_vector.or(other.__isset_bit_vector);
    this.publishTime = other.publishTime;
    if (other.isSetPayLoad()) {
      this.payLoad = TBaseHelper.copyBinary(other.payLoad);
    }
  }

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

  @Override
  public void clear() {
    setPublishTimeIsSet(false);
    this.publishTime = 0;
    this.payLoad = null;
  }

  public long getPublishTime() {
    return this.publishTime;
  }

  public Message setPublishTime(long publishTime) {
    this.publishTime = publishTime;
    setPublishTimeIsSet(true);

    return this;
  }

  public void unsetPublishTime() {
  __isset_bit_vector.clear(__PUBLISHTIME_ISSET_ID);
  }

  /** Returns true if field publishTime is set (has been asigned a value) and false otherwise */
  public boolean isSetPublishTime() {
    return __isset_bit_vector.get(__PUBLISHTIME_ISSET_ID);
  }

  public void setPublishTimeIsSet(boolean value) {
    __isset_bit_vector.set(__PUBLISHTIME_ISSET_ID, value);
  }

  public byte[] getPayLoad() {
    setPayLoad(TBaseHelper.rightSize(payLoad));
    return payLoad.array();
  }

  public ByteBuffer BufferForPayLoad() {
    return payLoad;
  }

  public Message setPayLoad(byte[] payLoad) {
    setPayLoad(ByteBuffer.wrap(payLoad));
    return this;
  }

  public Message setPayLoad(ByteBuffer payLoad) {
    this.payLoad = payLoad;
    
    return this;
  }

  public void unsetPayLoad() {
    this.payLoad = null;
  }

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

  public void setPayLoadIsSet(boolean value) {
    if (!value) {
      this.payLoad = null;
    }
  }

  public void setFieldValue(_Fields field, Object value) {
    switch (field) {
    case PUBLISH_TIME:
      if (value == null) {
        unsetPublishTime();
      } else {
        setPublishTime((Long)value);
      }
      break;
    case PAY_LOAD:
      if (value == null) {
        unsetPayLoad();
      } else {
        setPayLoad((ByteBuffer)value);
      }
      break;
    }
  }

  public Object getFieldValue(_Fields field) {
    switch (field) {
    case PUBLISH_TIME:
      return new Long(getPublishTime());
    case PAY_LOAD:
      return getPayLoad();
    }
    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 PUBLISH_TIME:
      return isSetPublishTime();
    case PAY_LOAD:
      return isSetPayLoad();
    }
    throw new IllegalStateException();
  }

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

  public boolean equals(Message that) {
    if (that == null)
      return false;
    boolean this_present_publishTime = true;
    boolean that_present_publishTime = true;
    if (this_present_publishTime || that_present_publishTime) {
      if (!(this_present_publishTime && that_present_publishTime))
        return false;
      if (this.publishTime != that.publishTime)
        return false;
    }
    boolean this_present_payLoad = true && this.isSetPayLoad();
    boolean that_present_payLoad = true && that.isSetPayLoad();
    if (this_present_payLoad || that_present_payLoad) {
      if (!(this_present_payLoad && that_present_payLoad))
        return false;
      if (!this.payLoad.equals(that.payLoad))
        return false;
    }

    return true;
  }

  @Override
  public int hashCode() {
    HashCodeBuilder builder = new HashCodeBuilder();
    boolean present_publishTime = true;
    builder.append(present_publishTime);
    if (present_publishTime)
      builder.append(publishTime);
    boolean present_payLoad = true && (isSetPayLoad());
    builder.append(present_payLoad);
    if (present_payLoad)
      builder.append(payLoad);
    return builder.toHashCode();
  }

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

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

    lastComparison = Boolean.valueOf(isSetPublishTime()).compareTo(typedOther.isSetPublishTime());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetPublishTime()) {
      lastComparison = TBaseHelper.compareTo(this.publishTime, typedOther.publishTime);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetPayLoad()).compareTo(typedOther.isSetPayLoad());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetPayLoad()) {
      lastComparison = TBaseHelper.compareTo(this.payLoad, typedOther.payLoad);
      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: // PUBLISH_TIME
          if (field.type == TType.I64) {
            this.publishTime = iprot.readI64();
            setPublishTimeIsSet(true);
          } else {
            TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 2: // PAY_LOAD
          if (field.type == TType.STRING) {
            this.payLoad = iprot.readBinary();
          } 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);
    oprot.writeFieldBegin(PUBLISH_TIME_FIELD_DESC);
    oprot.writeI64(this.publishTime);
    oprot.writeFieldEnd();
    if (this.payLoad != null) {
      oprot.writeFieldBegin(PAY_LOAD_FIELD_DESC);
      oprot.writeBinary(this.payLoad);
      oprot.writeFieldEnd();
    }
    oprot.writeFieldStop();
    oprot.writeStructEnd();
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder("Message(");
    boolean first = true;
    sb.append("publishTime:");
    sb.append(this.publishTime);
    first = false;
    if (!first) sb.append(", ");
    sb.append("payLoad:");
    if (this.payLoad == null) {
      sb.append("null");
    } else {
      TBaseHelper.toString(this.payLoad, sb);
    }
    first = false;
    sb.append(")");
    return sb.toString();
  }

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy