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

com.twitter.elephantbird.pig.test.thrift.Name Maven / Gradle / Ivy

There is a newer version: 4.17
Show newest version
/**
 * Autogenerated by Thrift
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 */
package com.twitter.elephantbird.pig.test.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.*;

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

  private static final TField FIRST_NAME_FIELD_DESC = new TField("first_name", TType.STRING, (short)1);
  private static final TField LAST_NAME_FIELD_DESC = new TField("last_name", TType.STRING, (short)2);

  public String first_name;
  public String last_name;

  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
  public enum _Fields implements TFieldIdEnum {
    FIRST_NAME((short)1, "first_name"),
    LAST_NAME((short)2, "last_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: // FIRST_NAME
          return FIRST_NAME;
        case 2: // LAST_NAME
          return LAST_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, FieldMetaData> metaDataMap;
  static {
    Map<_Fields, FieldMetaData> tmpMap = new EnumMap<_Fields, FieldMetaData>(_Fields.class);
    tmpMap.put(_Fields.FIRST_NAME, new FieldMetaData("first_name", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.STRING)));
    tmpMap.put(_Fields.LAST_NAME, new FieldMetaData("last_name", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.STRING)));
    metaDataMap = Collections.unmodifiableMap(tmpMap);
    FieldMetaData.addStructMetaDataMap(Name.class, metaDataMap);
  }

  public Name() {
  }

  public Name(
    String first_name,
    String last_name)
  {
    this();
    this.first_name = first_name;
    this.last_name = last_name;
  }

  /**
   * Performs a deep copy on other.
   */
  public Name(Name other) {
    if (other.isSetFirst_name()) {
      this.first_name = other.first_name;
    }
    if (other.isSetLast_name()) {
      this.last_name = other.last_name;
    }
  }

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

  @Override
  public void clear() {
    this.first_name = null;
    this.last_name = null;
  }

  public String getFirst_name() {
    return this.first_name;
  }

  public Name setFirst_name(String first_name) {
    this.first_name = first_name;
    return this;
  }

  public void unsetFirst_name() {
    this.first_name = null;
  }

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

  public void setFirst_nameIsSet(boolean value) {
    if (!value) {
      this.first_name = null;
    }
  }

  public String getLast_name() {
    return this.last_name;
  }

  public Name setLast_name(String last_name) {
    this.last_name = last_name;
    return this;
  }

  public void unsetLast_name() {
    this.last_name = null;
  }

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

  public void setLast_nameIsSet(boolean value) {
    if (!value) {
      this.last_name = null;
    }
  }

  public void setFieldValue(_Fields field, Object value) {
    switch (field) {
    case FIRST_NAME:
      if (value == null) {
        unsetFirst_name();
      } else {
        setFirst_name((String)value);
      }
      break;

    case LAST_NAME:
      if (value == null) {
        unsetLast_name();
      } else {
        setLast_name((String)value);
      }
      break;

    }
  }

  public Object getFieldValue(_Fields field) {
    switch (field) {
    case FIRST_NAME:
      return getFirst_name();

    case LAST_NAME:
      return getLast_name();

    }
    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 FIRST_NAME:
      return isSetFirst_name();
    case LAST_NAME:
      return isSetLast_name();
    }
    throw new IllegalStateException();
  }

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

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

    boolean this_present_first_name = true && this.isSetFirst_name();
    boolean that_present_first_name = true && that.isSetFirst_name();
    if (this_present_first_name || that_present_first_name) {
      if (!(this_present_first_name && that_present_first_name))
        return false;
      if (!this.first_name.equals(that.first_name))
        return false;
    }

    boolean this_present_last_name = true && this.isSetLast_name();
    boolean that_present_last_name = true && that.isSetLast_name();
    if (this_present_last_name || that_present_last_name) {
      if (!(this_present_last_name && that_present_last_name))
        return false;
      if (!this.last_name.equals(that.last_name))
        return false;
    }

    return true;
  }

  @Override
  public int hashCode() {
    HashCodeBuilder builder = new HashCodeBuilder();

    boolean present_first_name = true && (isSetFirst_name());
    builder.append(present_first_name);
    if (present_first_name)
      builder.append(first_name);

    boolean present_last_name = true && (isSetLast_name());
    builder.append(present_last_name);
    if (present_last_name)
      builder.append(last_name);

    return builder.toHashCode();
  }

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

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

    lastComparison = Boolean.valueOf(isSetFirst_name()).compareTo(typedOther.isSetFirst_name());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetFirst_name()) {
      lastComparison = TBaseHelper.compareTo(this.first_name, typedOther.first_name);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetLast_name()).compareTo(typedOther.isSetLast_name());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetLast_name()) {
      lastComparison = TBaseHelper.compareTo(this.last_name, typedOther.last_name);
      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: // FIRST_NAME
          if (field.type == TType.STRING) {
            this.first_name = iprot.readString();
          } else { 
            TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 2: // LAST_NAME
          if (field.type == TType.STRING) {
            this.last_name = 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.first_name != null) {
      oprot.writeFieldBegin(FIRST_NAME_FIELD_DESC);
      oprot.writeString(this.first_name);
      oprot.writeFieldEnd();
    }
    if (this.last_name != null) {
      oprot.writeFieldBegin(LAST_NAME_FIELD_DESC);
      oprot.writeString(this.last_name);
      oprot.writeFieldEnd();
    }
    oprot.writeFieldStop();
    oprot.writeStructEnd();
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder("Name(");
    boolean first = true;

    sb.append("first_name:");
    if (this.first_name == null) {
      sb.append("null");
    } else {
      sb.append(this.first_name);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("last_name:");
    if (this.last_name == null) {
      sb.append("null");
    } else {
      sb.append(this.last_name);
    }
    first = false;
    sb.append(")");
    return sb.toString();
  }

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

}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy