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

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

  private static final TField HEADER_FIELD_DESC = new TField("header", TType.STRUCT, (short)1);
  private static final TField WRITE_RESPONSES_FIELD_DESC = new TField("writeResponses", TType.LIST, (short)2);


  public ResponseHeader header;
  public List writeResponses;

  /** 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"),
    WRITE_RESPONSES((short)2, "writeResponses");
  
    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: // WRITE_RESPONSES
  	return WRITE_RESPONSES;
        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.WRITE_RESPONSES, new FieldMetaData("writeResponses", TFieldRequirementType.OPTIONAL,
      new ListMetaData(TType.LIST,
                new StructMetaData(TType.STRUCT, WriteResponse.class))));
    metaDataMap = Collections.unmodifiableMap(tmpMap);
    FieldMetaData.addStructMetaDataMap(BulkWriteResponse.class, metaDataMap);
  }


  public BulkWriteResponse() {
  }

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

  /**
   * Performs a deep copy on other.
   */
  public BulkWriteResponse(BulkWriteResponse other) {
    if (other.isSetHeader()) {
      this.header = new ResponseHeader(other.header);
    }
    if (other.isSetWriteResponses()) {
      List __this__writeResponses = new ArrayList();
      for (WriteResponse other_element : other.writeResponses) {
        __this__writeResponses.add(new WriteResponse(other_element));
      }
      this.writeResponses = __this__writeResponses;
    }
  }

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

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

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

  public BulkWriteResponse 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 int getWriteResponsesSize() {
    return (this.writeResponses == null) ? 0 : this.writeResponses.size();
  }

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

  public void addToWriteResponses(WriteResponse elem) {
    if (this.writeResponses == null) {
      this.writeResponses = new ArrayList();
    }
    this.writeResponses.add(elem);
  }

  public List getWriteResponses() {
    return this.writeResponses;
  }

  public BulkWriteResponse setWriteResponses(List writeResponses) {
    this.writeResponses = writeResponses;
    
    return this;
  }

  public void unsetWriteResponses() {
    this.writeResponses = null;
  }

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

  public void setWriteResponsesIsSet(boolean value) {
    if (!value) {
      this.writeResponses = null;
    }
  }

  public void setFieldValue(_Fields field, Object value) {
    switch (field) {
    case HEADER:
      if (value == null) {
        unsetHeader();
      } else {
        setHeader((ResponseHeader)value);
      }
      break;
    case WRITE_RESPONSES:
      if (value == null) {
        unsetWriteResponses();
      } else {
        setWriteResponses((List)value);
      }
      break;
    }
  }

  public Object getFieldValue(_Fields field) {
    switch (field) {
    case HEADER:
      return getHeader();
    case WRITE_RESPONSES:
      return getWriteResponses();
    }
    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 WRITE_RESPONSES:
      return isSetWriteResponses();
    }
    throw new IllegalStateException();
  }

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

  public boolean equals(BulkWriteResponse 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_writeResponses = true && this.isSetWriteResponses();
    boolean that_present_writeResponses = true && that.isSetWriteResponses();
    if (this_present_writeResponses || that_present_writeResponses) {
      if (!(this_present_writeResponses && that_present_writeResponses))
        return false;
      if (!this.writeResponses.equals(that.writeResponses))
        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_writeResponses = true && (isSetWriteResponses());
    builder.append(present_writeResponses);
    if (present_writeResponses)
      builder.append(writeResponses);
    return builder.toHashCode();
  }

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

    int lastComparison = 0;
    BulkWriteResponse typedOther = (BulkWriteResponse)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(isSetWriteResponses()).compareTo(typedOther.isSetWriteResponses());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetWriteResponses()) {
      lastComparison = TBaseHelper.compareTo(this.writeResponses, typedOther.writeResponses);
      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: // WRITE_RESPONSES
          if (field.type == TType.LIST) {
            {
            TList _list0 = iprot.readListBegin();
            this.writeResponses = new ArrayList(_list0.size);
            for (int _i1 = 0; _i1 < _list0.size; ++_i1)
            {
              WriteResponse _elem2;
              _elem2 = new WriteResponse();
              _elem2.read(iprot);
              this.writeResponses.add(_elem2);
            }
            iprot.readListEnd();
            }
          } 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.writeResponses != null) {
      if (isSetWriteResponses()) {
        oprot.writeFieldBegin(WRITE_RESPONSES_FIELD_DESC);
        {
          oprot.writeListBegin(new TList(TType.STRUCT, this.writeResponses.size()));
          for (WriteResponse _iter3 : this.writeResponses)
          {
            _iter3.write(oprot);
          }
          oprot.writeListEnd();
        }
        oprot.writeFieldEnd();
      }
    }
    oprot.writeFieldStop();
    oprot.writeStructEnd();
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder("BulkWriteResponse(");
    boolean first = true;
    sb.append("header:");
    if (this.header == null) {
      sb.append("null");
    } else {
      sb.append(this.header);
    }
    first = false;
    if (isSetWriteResponses()) {
      if (!first) sb.append(", ");
      sb.append("writeResponses:");
      if (this.writeResponses == null) {
        sb.append("null");
      } else {
        sb.append(this.writeResponses);
      }
      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