blob: 99c0dcb67ea12856bc8537c658949e64fa00d403 [file] [log] [blame]
/**
* Autogenerated by Thrift Compiler (0.9.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package org.apache.sentry.provider.db.service.thrift;
import org.apache.commons.lang.builder.HashCodeBuilder;
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 org.apache.thrift.protocol.TProtocolException;
import org.apache.thrift.EncodingUtils;
import org.apache.thrift.TException;
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 TStoreAuthorizable implements org.apache.thrift.TBase<TStoreAuthorizable, TStoreAuthorizable._Fields>, java.io.Serializable, Cloneable {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TStoreAuthorizable");
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 TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("type", org.apache.thrift.protocol.TType.STRING, (short)2);
private static final org.apache.thrift.protocol.TField PRIVILEGES_FIELD_DESC = new org.apache.thrift.protocol.TField("privileges", org.apache.thrift.protocol.TType.MAP, (short)3);
private static final org.apache.thrift.protocol.TField CHILDREN_FIELD_DESC = new org.apache.thrift.protocol.TField("children", org.apache.thrift.protocol.TType.SET, (short)4);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
schemes.put(StandardScheme.class, new TStoreAuthorizableStandardSchemeFactory());
schemes.put(TupleScheme.class, new TStoreAuthorizableTupleSchemeFactory());
}
private String name; // required
private String type; // required
private Map<String,TStorePrivilege> privileges; // optional
private Set<Integer> children; // optional
/** 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"),
TYPE((short)2, "type"),
PRIVILEGES((short)3, "privileges"),
CHILDREN((short)4, "children");
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: // TYPE
return TYPE;
case 3: // PRIVILEGES
return PRIVILEGES;
case 4: // CHILDREN
return CHILDREN;
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 _Fields optionals[] = {_Fields.PRIVILEGES,_Fields.CHILDREN};
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.REQUIRED,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
tmpMap.put(_Fields.TYPE, new org.apache.thrift.meta_data.FieldMetaData("type", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
tmpMap.put(_Fields.PRIVILEGES, new org.apache.thrift.meta_data.FieldMetaData("privileges", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING),
new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TStorePrivilege.class))));
tmpMap.put(_Fields.CHILDREN, new org.apache.thrift.meta_data.FieldMetaData("children", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.SetMetaData(org.apache.thrift.protocol.TType.SET,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TStoreAuthorizable.class, metaDataMap);
}
public TStoreAuthorizable() {
}
public TStoreAuthorizable(
String name,
String type)
{
this();
this.name = name;
this.type = type;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public TStoreAuthorizable(TStoreAuthorizable other) {
if (other.isSetName()) {
this.name = other.name;
}
if (other.isSetType()) {
this.type = other.type;
}
if (other.isSetPrivileges()) {
Map<String,TStorePrivilege> __this__privileges = new HashMap<String,TStorePrivilege>();
for (Map.Entry<String, TStorePrivilege> other_element : other.privileges.entrySet()) {
String other_element_key = other_element.getKey();
TStorePrivilege other_element_value = other_element.getValue();
String __this__privileges_copy_key = other_element_key;
TStorePrivilege __this__privileges_copy_value = new TStorePrivilege(other_element_value);
__this__privileges.put(__this__privileges_copy_key, __this__privileges_copy_value);
}
this.privileges = __this__privileges;
}
if (other.isSetChildren()) {
Set<Integer> __this__children = new HashSet<Integer>();
for (Integer other_element : other.children) {
__this__children.add(other_element);
}
this.children = __this__children;
}
}
public TStoreAuthorizable deepCopy() {
return new TStoreAuthorizable(this);
}
@Override
public void clear() {
this.name = null;
this.type = null;
this.privileges = null;
this.children = 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 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 getType() {
return this.type;
}
public void setType(String type) {
this.type = type;
}
public void unsetType() {
this.type = null;
}
/** Returns true if field type is set (has been assigned a value) and false otherwise */
public boolean isSetType() {
return this.type != null;
}
public void setTypeIsSet(boolean value) {
if (!value) {
this.type = null;
}
}
public int getPrivilegesSize() {
return (this.privileges == null) ? 0 : this.privileges.size();
}
public void putToPrivileges(String key, TStorePrivilege val) {
if (this.privileges == null) {
this.privileges = new HashMap<String,TStorePrivilege>();
}
this.privileges.put(key, val);
}
public Map<String,TStorePrivilege> getPrivileges() {
return this.privileges;
}
public void setPrivileges(Map<String,TStorePrivilege> privileges) {
this.privileges = privileges;
}
public void unsetPrivileges() {
this.privileges = null;
}
/** Returns true if field privileges is set (has been assigned a value) and false otherwise */
public boolean isSetPrivileges() {
return this.privileges != null;
}
public void setPrivilegesIsSet(boolean value) {
if (!value) {
this.privileges = null;
}
}
public int getChildrenSize() {
return (this.children == null) ? 0 : this.children.size();
}
public java.util.Iterator<Integer> getChildrenIterator() {
return (this.children == null) ? null : this.children.iterator();
}
public void addToChildren(int elem) {
if (this.children == null) {
this.children = new HashSet<Integer>();
}
this.children.add(elem);
}
public Set<Integer> getChildren() {
return this.children;
}
public void setChildren(Set<Integer> children) {
this.children = children;
}
public void unsetChildren() {
this.children = null;
}
/** Returns true if field children is set (has been assigned a value) and false otherwise */
public boolean isSetChildren() {
return this.children != null;
}
public void setChildrenIsSet(boolean value) {
if (!value) {
this.children = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case NAME:
if (value == null) {
unsetName();
} else {
setName((String)value);
}
break;
case TYPE:
if (value == null) {
unsetType();
} else {
setType((String)value);
}
break;
case PRIVILEGES:
if (value == null) {
unsetPrivileges();
} else {
setPrivileges((Map<String,TStorePrivilege>)value);
}
break;
case CHILDREN:
if (value == null) {
unsetChildren();
} else {
setChildren((Set<Integer>)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case NAME:
return getName();
case TYPE:
return getType();
case PRIVILEGES:
return getPrivileges();
case CHILDREN:
return getChildren();
}
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 TYPE:
return isSetType();
case PRIVILEGES:
return isSetPrivileges();
case CHILDREN:
return isSetChildren();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof TStoreAuthorizable)
return this.equals((TStoreAuthorizable)that);
return false;
}
public boolean equals(TStoreAuthorizable 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_type = true && this.isSetType();
boolean that_present_type = true && that.isSetType();
if (this_present_type || that_present_type) {
if (!(this_present_type && that_present_type))
return false;
if (!this.type.equals(that.type))
return false;
}
boolean this_present_privileges = true && this.isSetPrivileges();
boolean that_present_privileges = true && that.isSetPrivileges();
if (this_present_privileges || that_present_privileges) {
if (!(this_present_privileges && that_present_privileges))
return false;
if (!this.privileges.equals(that.privileges))
return false;
}
boolean this_present_children = true && this.isSetChildren();
boolean that_present_children = true && that.isSetChildren();
if (this_present_children || that_present_children) {
if (!(this_present_children && that_present_children))
return false;
if (!this.children.equals(that.children))
return false;
}
return true;
}
@Override
public int hashCode() {
HashCodeBuilder builder = new HashCodeBuilder();
boolean present_name = true && (isSetName());
builder.append(present_name);
if (present_name)
builder.append(name);
boolean present_type = true && (isSetType());
builder.append(present_type);
if (present_type)
builder.append(type);
boolean present_privileges = true && (isSetPrivileges());
builder.append(present_privileges);
if (present_privileges)
builder.append(privileges);
boolean present_children = true && (isSetChildren());
builder.append(present_children);
if (present_children)
builder.append(children);
return builder.toHashCode();
}
public int compareTo(TStoreAuthorizable other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
TStoreAuthorizable typedOther = (TStoreAuthorizable)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(isSetType()).compareTo(typedOther.isSetType());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetType()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.type, typedOther.type);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetPrivileges()).compareTo(typedOther.isSetPrivileges());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetPrivileges()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.privileges, typedOther.privileges);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetChildren()).compareTo(typedOther.isSetChildren());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetChildren()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.children, typedOther.children);
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("TStoreAuthorizable(");
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("type:");
if (this.type == null) {
sb.append("null");
} else {
sb.append(this.type);
}
first = false;
if (isSetPrivileges()) {
if (!first) sb.append(", ");
sb.append("privileges:");
if (this.privileges == null) {
sb.append("null");
} else {
sb.append(this.privileges);
}
first = false;
}
if (isSetChildren()) {
if (!first) sb.append(", ");
sb.append("children:");
if (this.children == null) {
sb.append("null");
} else {
sb.append(this.children);
}
first = false;
}
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
if (!isSetName()) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'name' is unset! Struct:" + toString());
}
if (!isSetType()) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'type' is unset! Struct:" + toString());
}
// check for sub-struct validity
}
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);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
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);
}
}
private static class TStoreAuthorizableStandardSchemeFactory implements SchemeFactory {
public TStoreAuthorizableStandardScheme getScheme() {
return new TStoreAuthorizableStandardScheme();
}
}
private static class TStoreAuthorizableStandardScheme extends StandardScheme<TStoreAuthorizable> {
public void read(org.apache.thrift.protocol.TProtocol iprot, TStoreAuthorizable 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: // TYPE
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.type = iprot.readString();
struct.setTypeIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 3: // PRIVILEGES
if (schemeField.type == org.apache.thrift.protocol.TType.MAP) {
{
org.apache.thrift.protocol.TMap _map0 = iprot.readMapBegin();
struct.privileges = new HashMap<String,TStorePrivilege>(2*_map0.size);
for (int _i1 = 0; _i1 < _map0.size; ++_i1)
{
String _key2; // required
TStorePrivilege _val3; // required
_key2 = iprot.readString();
_val3 = new TStorePrivilege();
_val3.read(iprot);
struct.privileges.put(_key2, _val3);
}
iprot.readMapEnd();
}
struct.setPrivilegesIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 4: // CHILDREN
if (schemeField.type == org.apache.thrift.protocol.TType.SET) {
{
org.apache.thrift.protocol.TSet _set4 = iprot.readSetBegin();
struct.children = new HashSet<Integer>(2*_set4.size);
for (int _i5 = 0; _i5 < _set4.size; ++_i5)
{
int _elem6; // required
_elem6 = iprot.readI32();
struct.children.add(_elem6);
}
iprot.readSetEnd();
}
struct.setChildrenIsSet(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();
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, TStoreAuthorizable 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.type != null) {
oprot.writeFieldBegin(TYPE_FIELD_DESC);
oprot.writeString(struct.type);
oprot.writeFieldEnd();
}
if (struct.privileges != null) {
if (struct.isSetPrivileges()) {
oprot.writeFieldBegin(PRIVILEGES_FIELD_DESC);
{
oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRUCT, struct.privileges.size()));
for (Map.Entry<String, TStorePrivilege> _iter7 : struct.privileges.entrySet())
{
oprot.writeString(_iter7.getKey());
_iter7.getValue().write(oprot);
}
oprot.writeMapEnd();
}
oprot.writeFieldEnd();
}
}
if (struct.children != null) {
if (struct.isSetChildren()) {
oprot.writeFieldBegin(CHILDREN_FIELD_DESC);
{
oprot.writeSetBegin(new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.I32, struct.children.size()));
for (int _iter8 : struct.children)
{
oprot.writeI32(_iter8);
}
oprot.writeSetEnd();
}
oprot.writeFieldEnd();
}
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class TStoreAuthorizableTupleSchemeFactory implements SchemeFactory {
public TStoreAuthorizableTupleScheme getScheme() {
return new TStoreAuthorizableTupleScheme();
}
}
private static class TStoreAuthorizableTupleScheme extends TupleScheme<TStoreAuthorizable> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, TStoreAuthorizable struct) throws org.apache.thrift.TException {
TTupleProtocol oprot = (TTupleProtocol) prot;
oprot.writeString(struct.name);
oprot.writeString(struct.type);
BitSet optionals = new BitSet();
if (struct.isSetPrivileges()) {
optionals.set(0);
}
if (struct.isSetChildren()) {
optionals.set(1);
}
oprot.writeBitSet(optionals, 2);
if (struct.isSetPrivileges()) {
{
oprot.writeI32(struct.privileges.size());
for (Map.Entry<String, TStorePrivilege> _iter9 : struct.privileges.entrySet())
{
oprot.writeString(_iter9.getKey());
_iter9.getValue().write(oprot);
}
}
}
if (struct.isSetChildren()) {
{
oprot.writeI32(struct.children.size());
for (int _iter10 : struct.children)
{
oprot.writeI32(_iter10);
}
}
}
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, TStoreAuthorizable struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
struct.name = iprot.readString();
struct.setNameIsSet(true);
struct.type = iprot.readString();
struct.setTypeIsSet(true);
BitSet incoming = iprot.readBitSet(2);
if (incoming.get(0)) {
{
org.apache.thrift.protocol.TMap _map11 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
struct.privileges = new HashMap<String,TStorePrivilege>(2*_map11.size);
for (int _i12 = 0; _i12 < _map11.size; ++_i12)
{
String _key13; // required
TStorePrivilege _val14; // required
_key13 = iprot.readString();
_val14 = new TStorePrivilege();
_val14.read(iprot);
struct.privileges.put(_key13, _val14);
}
}
struct.setPrivilegesIsSet(true);
}
if (incoming.get(1)) {
{
org.apache.thrift.protocol.TSet _set15 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.I32, iprot.readI32());
struct.children = new HashSet<Integer>(2*_set15.size);
for (int _i16 = 0; _i16 < _set15.size; ++_i16)
{
int _elem17; // required
_elem17 = iprot.readI32();
struct.children.add(_elem17);
}
}
struct.setChildrenIsSet(true);
}
}
}
}