/**
* Autogenerated by Thrift Compiler (0.8.0-dev)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package org.pyload.thrift;
import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;
import org.apache.thrift.scheme.TupleScheme;
import org.apache.thrift.protocol.TTupleProtocol;
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;
public class UserData implements org.apache.thrift.TBase<UserData, UserData._Fields>, java.io.Serializable, Cloneable {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("UserData");
private static final org.apache.thrift.protocol.TField NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("name", org.apache.thrift.protocol.TType.STRING, (short)1);
private static final org.apache.thrift.protocol.TField EMAIL_FIELD_DESC = new org.apache.thrift.protocol.TField("email", org.apache.thrift.protocol.TType.STRING, (short)2);
private static final org.apache.thrift.protocol.TField ROLE_FIELD_DESC = new org.apache.thrift.protocol.TField("role", org.apache.thrift.protocol.TType.I32, (short)3);
private static final org.apache.thrift.protocol.TField PERMISSION_FIELD_DESC = new org.apache.thrift.protocol.TField("permission", org.apache.thrift.protocol.TType.I32, (short)4);
private static final org.apache.thrift.protocol.TField TEMPLATE_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("templateName", org.apache.thrift.protocol.TType.STRING, (short)5);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
schemes.put(StandardScheme.class, new UserDataStandardSchemeFactory());
schemes.put(TupleScheme.class, new UserDataTupleSchemeFactory());
}
public String name; // required
public String email; // required
public int role; // required
public int permission; // required
public String templateName; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
NAME((short)1, "name"),
EMAIL((short)2, "email"),
ROLE((short)3, "role"),
PERMISSION((short)4, "permission"),
TEMPLATE_NAME((short)5, "templateName");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
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: // NAME
return NAME;
case 2: // EMAIL
return EMAIL;
case 3: // ROLE
return ROLE;
case 4: // PERMISSION
return PERMISSION;
case 5: // TEMPLATE_NAME
return TEMPLATE_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
private static final int __ROLE_ISSET_ID = 0;
private static final int __PERMISSION_ISSET_ID = 1;
private BitSet __isset_bit_vector = new BitSet(2);
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.NAME, new org.apache.thrift.meta_data.FieldMetaData("name", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
tmpMap.put(_Fields.EMAIL, new org.apache.thrift.meta_data.FieldMetaData("email", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
tmpMap.put(_Fields.ROLE, new org.apache.thrift.meta_data.FieldMetaData("role", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
tmpMap.put(_Fields.PERMISSION, new org.apache.thrift.meta_data.FieldMetaData("permission", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
tmpMap.put(_Fields.TEMPLATE_NAME, new org.apache.thrift.meta_data.FieldMetaData("templateName", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(UserData.class, metaDataMap);
}
public UserData() {
}
public UserData(
String name,
String email,
int role,
int permission,
String templateName)
{
this();
this.name = name;
this.email = email;
this.role = role;
setRoleIsSet(true);
this.permission = permission;
setPermissionIsSet(true);
this.templateName = templateName;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public UserData(UserData other) {
__isset_bit_vector.clear();
__isset_bit_vector.or(other.__isset_bit_vector);
if (other.isSetName()) {
this.name = other.name;
}
if (other.isSetEmail()) {
this.email = other.email;
}
this.role = other.role;
this.permission = other.permission;
if (other.isSetTemplateName()) {
this.templateName = other.templateName;
}
}
public UserData deepCopy() {
return new UserData(this);
}
@Override
public void clear() {
this.name = null;
this.email = null;
setRoleIsSet(false);
this.role = 0;
setPermissionIsSet(false);
this.permission = 0;
this.templateName = null;
}
public String getName() {
return this.name;
}
public UserData setName(String name) {
this.name = name;
return this;
}
public void unsetName() {
this.name = null;
}
/** Returns true if field name is set (has been assigned a value) and false otherwise */
public boolean isSetName() {
return this.name != null;
}
public void setNameIsSet(boolean value) {
if (!value) {
this.name = null;
}
}
public String getEmail() {
return this.email;
}
public UserData setEmail(String email) {
this.email = email;
return this;
}
public void unsetEmail() {
this.email = null;
}
/** Returns true if field email is set (has been assigned a value) and false otherwise */
public boolean isSetEmail() {
return this.email != null;
}
public void setEmailIsSet(boolean value) {
if (!value) {
this.email = null;
}
}
public int getRole() {
return this.role;
}
public UserData setRole(int role) {
this.role = role;
setRoleIsSet(true);
return this;
}
public void unsetRole() {
__isset_bit_vector.clear(__ROLE_ISSET_ID);
}
/** Returns true if field role is set (has been assigned a value) and false otherwise */
public boolean isSetRole() {
return __isset_bit_vector.get(__ROLE_ISSET_ID);
}
public void setRoleIsSet(boolean value) {
__isset_bit_vector.set(__ROLE_ISSET_ID, value);
}
public int getPermission() {
return this.permission;
}
public UserData setPermission(int permission) {
this.permission = permission;
setPermissionIsSet(true);
return this;
}
public void unsetPermission() {
__isset_bit_vector.clear(__PERMISSION_ISSET_ID);
}
/** Returns true if field permission is set (has been assigned a value) and false otherwise */
public boolean isSetPermission() {
return __isset_bit_vector.get(__PERMISSION_ISSET_ID);
}
public void setPermissionIsSet(boolean value) {
__isset_bit_vector.set(__PERMISSION_ISSET_ID, value);
}
public String getTemplateName() {
return this.templateName;
}
public UserData setTemplateName(String templateName) {
this.templateName = templateName;
return this;
}
public void unsetTemplateName() {
this.templateName = null;
}
/** Returns true if field templateName is set (has been assigned a value) and false otherwise */
public boolean isSetTemplateName() {
return this.templateName != null;
}
public void setTemplateNameIsSet(boolean value) {
if (!value) {
this.templateName = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case NAME:
if (value == null) {
unsetName();
} else {
setName((String)value);
}
break;
case EMAIL:
if (value == null) {
unsetEmail();
} else {
setEmail((String)value);
}
break;
case ROLE:
if (value == null) {
unsetRole();
} else {
setRole((Integer)value);
}
break;
case PERMISSION:
if (value == null) {
unsetPermission();
} else {
setPermission((Integer)value);
}
break;
case TEMPLATE_NAME:
if (value == null) {
unsetTemplateName();
} else {
setTemplateName((String)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case NAME:
return getName();
case EMAIL:
return getEmail();
case ROLE:
return Integer.valueOf(getRole());
case PERMISSION:
return Integer.valueOf(getPermission());
case TEMPLATE_NAME:
return getTemplateName();
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case NAME:
return isSetName();
case EMAIL:
return isSetEmail();
case ROLE:
return isSetRole();
case PERMISSION:
return isSetPermission();
case TEMPLATE_NAME:
return isSetTemplateName();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof UserData)
return this.equals((UserData)that);
return false;
}
public boolean equals(UserData that) {
if (that == null)
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_email = true && this.isSetEmail();
boolean that_present_email = true && that.isSetEmail();
if (this_present_email || that_present_email) {
if (!(this_present_email && that_present_email))
return false;
if (!this.email.equals(that.email))
return false;
}
boolean this_present_role = true;
boolean that_present_role = true;
if (this_present_role || that_present_role) {
if (!(this_present_role && that_present_role))
return false;
if (this.role != that.role)
return false;
}
boolean this_present_permission = true;
boolean that_present_permission = true;
if (this_present_permission || that_present_permission) {
if (!(this_present_permission && that_present_permission))
return false;
if (this.permission != that.permission)
return false;
}
boolean this_present_templateName = true && this.isSetTemplateName();
boolean that_present_templateName = true && that.isSetTemplateName();
if (this_present_templateName || that_present_templateName) {
if (!(this_present_templateName && that_present_templateName))
return false;
if (!this.templateName.equals(that.templateName))
return false;
}
return true;
}
@Override
public int hashCode() {
return 0;
}
public int compareTo(UserData other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
UserData typedOther = (UserData)other;
lastComparison = Boolean.valueOf(isSetName()).compareTo(typedOther.isSetName());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetName()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.name, typedOther.name);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetEmail()).compareTo(typedOther.isSetEmail());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetEmail()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.email, typedOther.email);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetRole()).compareTo(typedOther.isSetRole());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetRole()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.role, typedOther.role);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetPermission()).compareTo(typedOther.isSetPermission());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetPermission()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.permission, typedOther.permission);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetTemplateName()).compareTo(typedOther.isSetTemplateName());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetTemplateName()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.templateName, typedOther.templateName);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("UserData(");
boolean first = true;
sb.append("name:");
if (this.name == null) {
sb.append("null");
} else {
sb.append(this.name);
}
first = false;
if (!first) sb.append(", ");
sb.append("email:");
if (this.email == null) {
sb.append("null");
} else {
sb.append(this.email);
}
first = false;
if (!first) sb.append(", ");
sb.append("role:");
sb.append(this.role);
first = false;
if (!first) sb.append(", ");
sb.append("permission:");
sb.append(this.permission);
first = false;
if (!first) sb.append(", ");
sb.append("templateName:");
if (this.templateName == null) {
sb.append("null");
} else {
sb.append(this.templateName);
}
first = false;
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te.getMessage());
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
// it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
__isset_bit_vector = new BitSet(1);
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te.getMessage());
}
}
private static class UserDataStandardSchemeFactory implements SchemeFactory {
public UserDataStandardScheme getScheme() {
return new UserDataStandardScheme();
}
}
private static class UserDataStandardScheme extends StandardScheme<UserData> {
public void read(org.apache.thrift.protocol.TProtocol iprot, UserData struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField schemeField;
iprot.readStructBegin();
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
case 1: // NAME
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.name = iprot.readString();
struct.setNameIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 2: // EMAIL
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.email = iprot.readString();
struct.setEmailIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 3: // ROLE
if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
struct.role = iprot.readI32();
struct.setRoleIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 4: // PERMISSION
if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
struct.permission = iprot.readI32();
struct.setPermissionIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 5: // TEMPLATE_NAME
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.templateName = iprot.readString();
struct.setTemplateNameIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, UserData struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
if (struct.name != null) {
oprot.writeFieldBegin(NAME_FIELD_DESC);
oprot.writeString(struct.name);
oprot.writeFieldEnd();
}
if (struct.email != null) {
oprot.writeFieldBegin(EMAIL_FIELD_DESC);
oprot.writeString(struct.email);
oprot.writeFieldEnd();
}
oprot.writeFieldBegin(ROLE_FIELD_DESC);
oprot.writeI32(struct.role);
oprot.writeFieldEnd();
oprot.writeFieldBegin(PERMISSION_FIELD_DESC);
oprot.writeI32(struct.permission);
oprot.writeFieldEnd();
if (struct.templateName != null) {
oprot.writeFieldBegin(TEMPLATE_NAME_FIELD_DESC);
oprot.writeString(struct.templateName);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class UserDataTupleSchemeFactory implements SchemeFactory {
public UserDataTupleScheme getScheme() {
return new UserDataTupleScheme();
}
}
private static class UserDataTupleScheme extends TupleScheme<UserData> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, UserData struct) throws org.apache.thrift.TException {
TTupleProtocol oprot = (TTupleProtocol) prot;
BitSet optionals = new BitSet();
if (struct.isSetName()) {
optionals.set(0);
}
if (struct.isSetEmail()) {
optionals.set(1);
}
if (struct.isSetRole()) {
optionals.set(2);
}
if (struct.isSetPermission()) {
optionals.set(3);
}
if (struct.isSetTemplateName()) {
optionals.set(4);
}
oprot.writeBitSet(optionals, 5);
if (struct.isSetName()) {
oprot.writeString(struct.name);
}
if (struct.isSetEmail()) {
oprot.writeString(struct.email);
}
if (struct.isSetRole()) {
oprot.writeI32(struct.role);
}
if (struct.isSetPermission()) {
oprot.writeI32(struct.permission);
}
if (struct.isSetTemplateName()) {
oprot.writeString(struct.templateName);
}
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, UserData struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
BitSet incoming = iprot.readBitSet(5);
if (incoming.get(0)) {
struct.name = iprot.readString();
struct.setNameIsSet(true);
}
if (incoming.get(1)) {
struct.email = iprot.readString();
struct.setEmailIsSet(true);
}
if (incoming.get(2)) {
struct.role = iprot.readI32();
struct.setRoleIsSet(true);
}
if (incoming.get(3)) {
struct.permission = iprot.readI32();
struct.setPermissionIsSet(true);
}
if (incoming.get(4)) {
struct.templateName = iprot.readString();
struct.setTemplateNameIsSet(true);
}
}
}
}