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

org.apache.distributedlog.thrift.service.WriteResponse Maven / Gradle / Ivy

The newest version!
/**
 * Autogenerated by Thrift
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 */
package org.apache.distributedlog.thrift.service;

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

  private static final TField HEADER_FIELD_DESC = new TField("header", TType.STRUCT, (short)1);
  private static final TField DLSN_FIELD_DESC = new TField("dlsn", TType.STRING, (short)2);


  public ResponseHeader header;
  public String dlsn;

  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
  public enum _Fields implements TFieldIdEnum {
    HEADER((short)1, "header"),
    DLSN((short)2, "dlsn");
  
    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: // HEADER
  	return HEADER;
        case 2: // DLSN
  	return DLSN;
        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.HEADER, new FieldMetaData("header", TFieldRequirementType.REQUIRED,
      new StructMetaData(TType.STRUCT, ResponseHeader.class)));
    tmpMap.put(_Fields.DLSN, new FieldMetaData("dlsn", TFieldRequirementType.OPTIONAL,
      new FieldValueMetaData(TType.STRING)));
    metaDataMap = Collections.unmodifiableMap(tmpMap);
    FieldMetaData.addStructMetaDataMap(WriteResponse.class, metaDataMap);
  }


  public WriteResponse() {
  }

  public WriteResponse(
    ResponseHeader header)
  {
    this();
    this.header = header;
  }

  /**
   * Performs a deep copy on other.
   */
  public WriteResponse(WriteResponse other) {
    if (other.isSetHeader()) {
      this.header = new ResponseHeader(other.header);
    }
    if (other.isSetDlsn()) {
      this.dlsn = other.dlsn;
    }
  }

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

  @Override
  public void clear() {
    this.header = null;
    this.dlsn = null;
  }

  public ResponseHeader getHeader() {
    return this.header;
  }

  public WriteResponse setHeader(ResponseHeader header) {
    this.header = header;
    
    return this;
  }

  public void unsetHeader() {
    this.header = null;
  }

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

  public void setHeaderIsSet(boolean value) {
    if (!value) {
      this.header = null;
    }
  }

  public String getDlsn() {
    return this.dlsn;
  }

  public WriteResponse setDlsn(String dlsn) {
    this.dlsn = dlsn;
    
    return this;
  }

  public void unsetDlsn() {
    this.dlsn = null;
  }

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

  public void setDlsnIsSet(boolean value) {
    if (!value) {
      this.dlsn = null;
    }
  }

  public void setFieldValue(_Fields field, Object value) {
    switch (field) {
    case HEADER:
      if (value == null) {
        unsetHeader();
      } else {
        setHeader((ResponseHeader)value);
      }
      break;
    case DLSN:
      if (value == null) {
        unsetDlsn();
      } else {
        setDlsn((String)value);
      }
      break;
    }
  }

  public Object getFieldValue(_Fields field) {
    switch (field) {
    case HEADER:
      return getHeader();
    case DLSN:
      return getDlsn();
    }
    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 HEADER:
      return isSetHeader();
    case DLSN:
      return isSetDlsn();
    }
    throw new IllegalStateException();
  }

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

  public boolean equals(WriteResponse that) {
    if (that == null)
      return false;
    boolean this_present_header = true && this.isSetHeader();
    boolean that_present_header = true && that.isSetHeader();
    if (this_present_header || that_present_header) {
      if (!(this_present_header && that_present_header))
        return false;
      if (!this.header.equals(that.header))
        return false;
    }
    boolean this_present_dlsn = true && this.isSetDlsn();
    boolean that_present_dlsn = true && that.isSetDlsn();
    if (this_present_dlsn || that_present_dlsn) {
      if (!(this_present_dlsn && that_present_dlsn))
        return false;
      if (!this.dlsn.equals(that.dlsn))
        return false;
    }

    return true;
  }

  @Override
  public int hashCode() {
    HashCodeBuilder builder = new HashCodeBuilder();
    boolean present_header = true && (isSetHeader());
    builder.append(present_header);
    if (present_header)
      builder.append(header);
    boolean present_dlsn = true && (isSetDlsn());
    builder.append(present_dlsn);
    if (present_dlsn)
      builder.append(dlsn);
    return builder.toHashCode();
  }

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

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

    lastComparison = Boolean.valueOf(isSetHeader()).compareTo(typedOther.isSetHeader());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetHeader()) {
      lastComparison = TBaseHelper.compareTo(this.header, typedOther.header);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetDlsn()).compareTo(typedOther.isSetDlsn());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetDlsn()) {
      lastComparison = TBaseHelper.compareTo(this.dlsn, typedOther.dlsn);
      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: // HEADER
          if (field.type == TType.STRUCT) {
            this.header = new ResponseHeader();
            this.header.read(iprot);
          } else {
            TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 2: // DLSN
          if (field.type == TType.STRING) {
            this.dlsn = 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.header != null) {
      oprot.writeFieldBegin(HEADER_FIELD_DESC);
      this.header.write(oprot);
      oprot.writeFieldEnd();
    }
    if (this.dlsn != null) {
      if (isSetDlsn()) {
        oprot.writeFieldBegin(DLSN_FIELD_DESC);
        oprot.writeString(this.dlsn);
        oprot.writeFieldEnd();
      }
    }
    oprot.writeFieldStop();
    oprot.writeStructEnd();
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder("WriteResponse(");
    boolean first = true;
    sb.append("header:");
    if (this.header == null) {
      sb.append("null");
    } else {
      sb.append(this.header);
    }
    first = false;
    if (isSetDlsn()) {
      if (!first) sb.append(", ");
      sb.append("dlsn:");
      if (this.dlsn == null) {
        sb.append("null");
      } else {
        sb.append(this.dlsn);
      }
      first = false;
      }
    sb.append(")");
    return sb.toString();
  }

  public void validate() throws TException {
    // check for required fields
    if (header == null) {
      throw new TProtocolException("Required field 'header' was not present! Struct: " + toString());
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy