Subversion Repositories SmartDukaan

Rev

Blame | Last modification | View Log | RSS feed

/**
 * Autogenerated by Thrift
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 */
package in.shop2020.model.v1.user;

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.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

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

/**
 * All the social handles
 */
public class SocialHandles implements TBase<SocialHandles._Fields>, java.io.Serializable, Cloneable, Comparable<SocialHandles> {
  private static final TStruct STRUCT_DESC = new TStruct("SocialHandles");

  private static final TField FACEBOOK_FIELD_DESC = new TField("facebook", TType.STRING, (short)1);
  private static final TField OPENSOCIAL_FIELD_DESC = new TField("opensocial", TType.STRING, (short)2);
  private static final TField TWITTER_FIELD_DESC = new TField("twitter", TType.STRING, (short)3);

  private String facebook;
  private String opensocial;
  private String twitter;

  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
  public enum _Fields implements TFieldIdEnum {
    FACEBOOK((short)1, "facebook"),
    OPENSOCIAL((short)2, "opensocial"),
    TWITTER((short)3, "twitter");

    private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
    private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();

    static {
      for (_Fields field : EnumSet.allOf(_Fields.class)) {
        byId.put((int)field._thriftId, field);
        byName.put(field.getFieldName(), field);
      }
    }

    /**
     * Find the _Fields constant that matches fieldId, or null if its not found.
     */
    public static _Fields findByThriftId(int fieldId) {
      return byId.get(fieldId);
    }

    /**
     * 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 = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
    put(_Fields.FACEBOOK, new FieldMetaData("facebook", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.STRING)));
    put(_Fields.OPENSOCIAL, new FieldMetaData("opensocial", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.STRING)));
    put(_Fields.TWITTER, new FieldMetaData("twitter", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.STRING)));
  }});

  static {
    FieldMetaData.addStructMetaDataMap(SocialHandles.class, metaDataMap);
  }

  public SocialHandles() {
  }

  public SocialHandles(
    String facebook,
    String opensocial,
    String twitter)
  {
    this();
    this.facebook = facebook;
    this.opensocial = opensocial;
    this.twitter = twitter;
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public SocialHandles(SocialHandles other) {
    if (other.isSetFacebook()) {
      this.facebook = other.facebook;
    }
    if (other.isSetOpensocial()) {
      this.opensocial = other.opensocial;
    }
    if (other.isSetTwitter()) {
      this.twitter = other.twitter;
    }
  }

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

  @Deprecated
  public SocialHandles clone() {
    return new SocialHandles(this);
  }

  public String getFacebook() {
    return this.facebook;
  }

  public SocialHandles setFacebook(String facebook) {
    this.facebook = facebook;
    return this;
  }

  public void unsetFacebook() {
    this.facebook = null;
  }

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

  public void setFacebookIsSet(boolean value) {
    if (!value) {
      this.facebook = null;
    }
  }

  public String getOpensocial() {
    return this.opensocial;
  }

  public SocialHandles setOpensocial(String opensocial) {
    this.opensocial = opensocial;
    return this;
  }

  public void unsetOpensocial() {
    this.opensocial = null;
  }

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

  public void setOpensocialIsSet(boolean value) {
    if (!value) {
      this.opensocial = null;
    }
  }

  public String getTwitter() {
    return this.twitter;
  }

  public SocialHandles setTwitter(String twitter) {
    this.twitter = twitter;
    return this;
  }

  public void unsetTwitter() {
    this.twitter = null;
  }

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

  public void setTwitterIsSet(boolean value) {
    if (!value) {
      this.twitter = null;
    }
  }

  public void setFieldValue(_Fields field, Object value) {
    switch (field) {
    case FACEBOOK:
      if (value == null) {
        unsetFacebook();
      } else {
        setFacebook((String)value);
      }
      break;

    case OPENSOCIAL:
      if (value == null) {
        unsetOpensocial();
      } else {
        setOpensocial((String)value);
      }
      break;

    case TWITTER:
      if (value == null) {
        unsetTwitter();
      } else {
        setTwitter((String)value);
      }
      break;

    }
  }

  public void setFieldValue(int fieldID, Object value) {
    setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
  }

  public Object getFieldValue(_Fields field) {
    switch (field) {
    case FACEBOOK:
      return getFacebook();

    case OPENSOCIAL:
      return getOpensocial();

    case TWITTER:
      return getTwitter();

    }
    throw new IllegalStateException();
  }

  public Object getFieldValue(int fieldId) {
    return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
  }

  /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
  public boolean isSet(_Fields field) {
    switch (field) {
    case FACEBOOK:
      return isSetFacebook();
    case OPENSOCIAL:
      return isSetOpensocial();
    case TWITTER:
      return isSetTwitter();
    }
    throw new IllegalStateException();
  }

  public boolean isSet(int fieldID) {
    return isSet(_Fields.findByThriftIdOrThrow(fieldID));
  }

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

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

    boolean this_present_facebook = true && this.isSetFacebook();
    boolean that_present_facebook = true && that.isSetFacebook();
    if (this_present_facebook || that_present_facebook) {
      if (!(this_present_facebook && that_present_facebook))
        return false;
      if (!this.facebook.equals(that.facebook))
        return false;
    }

    boolean this_present_opensocial = true && this.isSetOpensocial();
    boolean that_present_opensocial = true && that.isSetOpensocial();
    if (this_present_opensocial || that_present_opensocial) {
      if (!(this_present_opensocial && that_present_opensocial))
        return false;
      if (!this.opensocial.equals(that.opensocial))
        return false;
    }

    boolean this_present_twitter = true && this.isSetTwitter();
    boolean that_present_twitter = true && that.isSetTwitter();
    if (this_present_twitter || that_present_twitter) {
      if (!(this_present_twitter && that_present_twitter))
        return false;
      if (!this.twitter.equals(that.twitter))
        return false;
    }

    return true;
  }

  @Override
  public int hashCode() {
    return 0;
  }

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

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

    lastComparison = Boolean.valueOf(isSetFacebook()).compareTo(isSetFacebook());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(facebook, typedOther.facebook);
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetOpensocial()).compareTo(isSetOpensocial());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(opensocial, typedOther.opensocial);
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetTwitter()).compareTo(isSetTwitter());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(twitter, typedOther.twitter);
    if (lastComparison != 0) {
      return lastComparison;
    }
    return 0;
  }

  public void read(TProtocol iprot) throws TException {
    TField field;
    iprot.readStructBegin();
    while (true)
    {
      field = iprot.readFieldBegin();
      if (field.type == TType.STOP) { 
        break;
      }
      _Fields fieldId = _Fields.findByThriftId(field.id);
      if (fieldId == null) {
        TProtocolUtil.skip(iprot, field.type);
      } else {
        switch (fieldId) {
          case FACEBOOK:
            if (field.type == TType.STRING) {
              this.facebook = iprot.readString();
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case OPENSOCIAL:
            if (field.type == TType.STRING) {
              this.opensocial = iprot.readString();
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case TWITTER:
            if (field.type == TType.STRING) {
              this.twitter = iprot.readString();
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
        }
        iprot.readFieldEnd();
      }
    }
    iprot.readStructEnd();
    validate();
  }

  public void write(TProtocol oprot) throws TException {
    validate();

    oprot.writeStructBegin(STRUCT_DESC);
    if (this.facebook != null) {
      oprot.writeFieldBegin(FACEBOOK_FIELD_DESC);
      oprot.writeString(this.facebook);
      oprot.writeFieldEnd();
    }
    if (this.opensocial != null) {
      oprot.writeFieldBegin(OPENSOCIAL_FIELD_DESC);
      oprot.writeString(this.opensocial);
      oprot.writeFieldEnd();
    }
    if (this.twitter != null) {
      oprot.writeFieldBegin(TWITTER_FIELD_DESC);
      oprot.writeString(this.twitter);
      oprot.writeFieldEnd();
    }
    oprot.writeFieldStop();
    oprot.writeStructEnd();
  }

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

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

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

}