com.evernote.edam.type.Tag Maven / Gradle / Ivy
The newest version!
/**
* Autogenerated by Thrift
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
*/
package com.evernote.edam.type;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.Set;
import java.util.HashSet;
import com.evernote.thrift.*;
import com.evernote.thrift.protocol.*;
/**
* A tag within a user's account is a unique name which may be organized
* a simple hierarchy.
*
* - guid
* - The unique identifier of this tag. Will be set by the service,
* so may be omitted by the client when creating the Tag.
*
* Length: EDAM_GUID_LEN_MIN - EDAM_GUID_LEN_MAX
*
* Regex: EDAM_GUID_REGEX
*
*
* - name
* - A sequence of characters representing the tag's identifier.
* Case is preserved, but is ignored for comparisons.
* This means that an account may only have one tag with a given name, via
* case-insensitive comparison, so an account may not have both "food" and
* "Food" tags.
* May not contain a comma (','), and may not begin or end with a space.
*
* Length: EDAM_TAG_NAME_LEN_MIN - EDAM_TAG_NAME_LEN_MAX
*
* Regex: EDAM_TAG_NAME_REGEX
*
*
* - parentGuid
* - If this is set, then this is the GUID of the tag that
* holds this tag within the tag organizational hierarchy. If this is
* not set, then the tag has no parent and it is a "top level" tag.
* Cycles are not allowed (e.g. a->parent->parent == a) and will be
* rejected by the service.
*
* Length: EDAM_GUID_LEN_MIN - EDAM_GUID_LEN_MAX
*
* Regex: EDAM_GUID_REGEX
*
*
* - updateSequenceNum
* - A number identifying the last transaction to
* modify the state of this object. The USN values are sequential within an
* account, and can be used to compare the order of modifications within the
* service.
*
*
*/
public class Tag implements TBase, java.io.Serializable, Cloneable {
private static final TStruct STRUCT_DESC = new TStruct("Tag");
private static final TField GUID_FIELD_DESC = new TField("guid", TType.STRING, (short)1);
private static final TField NAME_FIELD_DESC = new TField("name", TType.STRING, (short)2);
private static final TField PARENT_GUID_FIELD_DESC = new TField("parentGuid", TType.STRING, (short)3);
private static final TField UPDATE_SEQUENCE_NUM_FIELD_DESC = new TField("updateSequenceNum", TType.I32, (short)4);
private String guid;
private String name;
private String parentGuid;
private int updateSequenceNum;
// isset id assignments
private static final int __UPDATESEQUENCENUM_ISSET_ID = 0;
private boolean[] __isset_vector = new boolean[1];
public Tag() {
}
/**
* Performs a deep copy on other.
*/
public Tag(Tag other) {
System.arraycopy(other.__isset_vector, 0, __isset_vector, 0, other.__isset_vector.length);
if (other.isSetGuid()) {
this.guid = other.guid;
}
if (other.isSetName()) {
this.name = other.name;
}
if (other.isSetParentGuid()) {
this.parentGuid = other.parentGuid;
}
this.updateSequenceNum = other.updateSequenceNum;
}
public Tag deepCopy() {
return new Tag(this);
}
public void clear() {
this.guid = null;
this.name = null;
this.parentGuid = null;
setUpdateSequenceNumIsSet(false);
this.updateSequenceNum = 0;
}
public String getGuid() {
return this.guid;
}
public void setGuid(String guid) {
this.guid = guid;
}
public void unsetGuid() {
this.guid = null;
}
/** Returns true if field guid is set (has been asigned a value) and false otherwise */
public boolean isSetGuid() {
return this.guid != null;
}
public void setGuidIsSet(boolean value) {
if (!value) {
this.guid = null;
}
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public void unsetName() {
this.name = null;
}
/** Returns true if field name is set (has been asigned a value) and false otherwise */
public boolean isSetName() {
return this.name != null;
}
public void setNameIsSet(boolean value) {
if (!value) {
this.name = null;
}
}
public String getParentGuid() {
return this.parentGuid;
}
public void setParentGuid(String parentGuid) {
this.parentGuid = parentGuid;
}
public void unsetParentGuid() {
this.parentGuid = null;
}
/** Returns true if field parentGuid is set (has been asigned a value) and false otherwise */
public boolean isSetParentGuid() {
return this.parentGuid != null;
}
public void setParentGuidIsSet(boolean value) {
if (!value) {
this.parentGuid = null;
}
}
public int getUpdateSequenceNum() {
return this.updateSequenceNum;
}
public void setUpdateSequenceNum(int updateSequenceNum) {
this.updateSequenceNum = updateSequenceNum;
setUpdateSequenceNumIsSet(true);
}
public void unsetUpdateSequenceNum() {
__isset_vector[__UPDATESEQUENCENUM_ISSET_ID] = false;
}
/** Returns true if field updateSequenceNum is set (has been asigned a value) and false otherwise */
public boolean isSetUpdateSequenceNum() {
return __isset_vector[__UPDATESEQUENCENUM_ISSET_ID];
}
public void setUpdateSequenceNumIsSet(boolean value) {
__isset_vector[__UPDATESEQUENCENUM_ISSET_ID] = value;
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof Tag)
return this.equals((Tag)that);
return false;
}
public boolean equals(Tag that) {
if (that == null)
return false;
boolean this_present_guid = true && this.isSetGuid();
boolean that_present_guid = true && that.isSetGuid();
if (this_present_guid || that_present_guid) {
if (!(this_present_guid && that_present_guid))
return false;
if (!this.guid.equals(that.guid))
return false;
}
boolean this_present_name = true && this.isSetName();
boolean that_present_name = true && that.isSetName();
if (this_present_name || that_present_name) {
if (!(this_present_name && that_present_name))
return false;
if (!this.name.equals(that.name))
return false;
}
boolean this_present_parentGuid = true && this.isSetParentGuid();
boolean that_present_parentGuid = true && that.isSetParentGuid();
if (this_present_parentGuid || that_present_parentGuid) {
if (!(this_present_parentGuid && that_present_parentGuid))
return false;
if (!this.parentGuid.equals(that.parentGuid))
return false;
}
boolean this_present_updateSequenceNum = true && this.isSetUpdateSequenceNum();
boolean that_present_updateSequenceNum = true && that.isSetUpdateSequenceNum();
if (this_present_updateSequenceNum || that_present_updateSequenceNum) {
if (!(this_present_updateSequenceNum && that_present_updateSequenceNum))
return false;
if (this.updateSequenceNum != that.updateSequenceNum)
return false;
}
return true;
}
@Override
public int hashCode() {
return 0;
}
public int compareTo(Tag other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
Tag typedOther = (Tag)other;
lastComparison = Boolean.valueOf(isSetGuid()).compareTo(typedOther.isSetGuid());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetGuid()) { lastComparison = TBaseHelper.compareTo(this.guid, typedOther.guid);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetName()).compareTo(typedOther.isSetName());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetName()) { lastComparison = TBaseHelper.compareTo(this.name, typedOther.name);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetParentGuid()).compareTo(typedOther.isSetParentGuid());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetParentGuid()) { lastComparison = TBaseHelper.compareTo(this.parentGuid, typedOther.parentGuid);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetUpdateSequenceNum()).compareTo(typedOther.isSetUpdateSequenceNum());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetUpdateSequenceNum()) { lastComparison = TBaseHelper.compareTo(this.updateSequenceNum, typedOther.updateSequenceNum);
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;
}
switch (field.id) {
case 1: // GUID
if (field.type == TType.STRING) {
this.guid = iprot.readString();
} else {
TProtocolUtil.skip(iprot, field.type);
}
break;
case 2: // NAME
if (field.type == TType.STRING) {
this.name = iprot.readString();
} else {
TProtocolUtil.skip(iprot, field.type);
}
break;
case 3: // PARENT_GUID
if (field.type == TType.STRING) {
this.parentGuid = iprot.readString();
} else {
TProtocolUtil.skip(iprot, field.type);
}
break;
case 4: // UPDATE_SEQUENCE_NUM
if (field.type == TType.I32) {
this.updateSequenceNum = iprot.readI32();
setUpdateSequenceNumIsSet(true);
} else {
TProtocolUtil.skip(iprot, field.type);
}
break;
default:
TProtocolUtil.skip(iprot, field.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
validate();
}
public void write(TProtocol oprot) throws TException {
validate();
oprot.writeStructBegin(STRUCT_DESC);
if (this.guid != null) {
if (isSetGuid()) {
oprot.writeFieldBegin(GUID_FIELD_DESC);
oprot.writeString(this.guid);
oprot.writeFieldEnd();
}
}
if (this.name != null) {
if (isSetName()) {
oprot.writeFieldBegin(NAME_FIELD_DESC);
oprot.writeString(this.name);
oprot.writeFieldEnd();
}
}
if (this.parentGuid != null) {
if (isSetParentGuid()) {
oprot.writeFieldBegin(PARENT_GUID_FIELD_DESC);
oprot.writeString(this.parentGuid);
oprot.writeFieldEnd();
}
}
if (isSetUpdateSequenceNum()) {
oprot.writeFieldBegin(UPDATE_SEQUENCE_NUM_FIELD_DESC);
oprot.writeI32(this.updateSequenceNum);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("Tag(");
boolean first = true;
if (isSetGuid()) {
sb.append("guid:");
if (this.guid == null) {
sb.append("null");
} else {
sb.append(this.guid);
}
first = false;
}
if (isSetName()) {
if (!first) sb.append(", ");
sb.append("name:");
if (this.name == null) {
sb.append("null");
} else {
sb.append(this.name);
}
first = false;
}
if (isSetParentGuid()) {
if (!first) sb.append(", ");
sb.append("parentGuid:");
if (this.parentGuid == null) {
sb.append("null");
} else {
sb.append(this.parentGuid);
}
first = false;
}
if (isSetUpdateSequenceNum()) {
if (!first) sb.append(", ");
sb.append("updateSequenceNum:");
sb.append(this.updateSequenceNum);
first = false;
}
sb.append(")");
return sb.toString();
}
public void validate() throws TException {
// check for required fields
}
}