| /** |
| * 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 TStorePrivilege implements org.apache.thrift.TBase<TStorePrivilege, TStorePrivilege._Fields>, java.io.Serializable, Cloneable { |
| private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TStorePrivilege"); |
| |
| private static final org.apache.thrift.protocol.TField GRANT_OPTION_FIELD_DESC = new org.apache.thrift.protocol.TField("grantOption", org.apache.thrift.protocol.TType.I32, (short)1); |
| private static final org.apache.thrift.protocol.TField PRIVILEGE_FIELD_DESC = new org.apache.thrift.protocol.TField("privilege", org.apache.thrift.protocol.TType.I16, (short)2); |
| |
| private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>(); |
| static { |
| schemes.put(StandardScheme.class, new TStorePrivilegeStandardSchemeFactory()); |
| schemes.put(TupleScheme.class, new TStorePrivilegeTupleSchemeFactory()); |
| } |
| |
| private TSentryGrantOption grantOption; // required |
| private short privilege; // 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 { |
| /** |
| * |
| * @see TSentryGrantOption |
| */ |
| GRANT_OPTION((short)1, "grantOption"), |
| PRIVILEGE((short)2, "privilege"); |
| |
| 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: // GRANT_OPTION |
| return GRANT_OPTION; |
| case 2: // PRIVILEGE |
| return PRIVILEGE; |
| 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 __PRIVILEGE_ISSET_ID = 0; |
| private byte __isset_bitfield = 0; |
| 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.GRANT_OPTION, new org.apache.thrift.meta_data.FieldMetaData("grantOption", org.apache.thrift.TFieldRequirementType.REQUIRED, |
| new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, TSentryGrantOption.class))); |
| tmpMap.put(_Fields.PRIVILEGE, new org.apache.thrift.meta_data.FieldMetaData("privilege", org.apache.thrift.TFieldRequirementType.REQUIRED, |
| new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I16))); |
| metaDataMap = Collections.unmodifiableMap(tmpMap); |
| org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TStorePrivilege.class, metaDataMap); |
| } |
| |
| public TStorePrivilege() { |
| } |
| |
| public TStorePrivilege( |
| TSentryGrantOption grantOption, |
| short privilege) |
| { |
| this(); |
| this.grantOption = grantOption; |
| this.privilege = privilege; |
| setPrivilegeIsSet(true); |
| } |
| |
| /** |
| * Performs a deep copy on <i>other</i>. |
| */ |
| public TStorePrivilege(TStorePrivilege other) { |
| __isset_bitfield = other.__isset_bitfield; |
| if (other.isSetGrantOption()) { |
| this.grantOption = other.grantOption; |
| } |
| this.privilege = other.privilege; |
| } |
| |
| public TStorePrivilege deepCopy() { |
| return new TStorePrivilege(this); |
| } |
| |
| @Override |
| public void clear() { |
| this.grantOption = null; |
| setPrivilegeIsSet(false); |
| this.privilege = 0; |
| } |
| |
| /** |
| * |
| * @see TSentryGrantOption |
| */ |
| public TSentryGrantOption getGrantOption() { |
| return this.grantOption; |
| } |
| |
| /** |
| * |
| * @see TSentryGrantOption |
| */ |
| public void setGrantOption(TSentryGrantOption grantOption) { |
| this.grantOption = grantOption; |
| } |
| |
| public void unsetGrantOption() { |
| this.grantOption = null; |
| } |
| |
| /** Returns true if field grantOption is set (has been assigned a value) and false otherwise */ |
| public boolean isSetGrantOption() { |
| return this.grantOption != null; |
| } |
| |
| public void setGrantOptionIsSet(boolean value) { |
| if (!value) { |
| this.grantOption = null; |
| } |
| } |
| |
| public short getPrivilege() { |
| return this.privilege; |
| } |
| |
| public void setPrivilege(short privilege) { |
| this.privilege = privilege; |
| setPrivilegeIsSet(true); |
| } |
| |
| public void unsetPrivilege() { |
| __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __PRIVILEGE_ISSET_ID); |
| } |
| |
| /** Returns true if field privilege is set (has been assigned a value) and false otherwise */ |
| public boolean isSetPrivilege() { |
| return EncodingUtils.testBit(__isset_bitfield, __PRIVILEGE_ISSET_ID); |
| } |
| |
| public void setPrivilegeIsSet(boolean value) { |
| __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __PRIVILEGE_ISSET_ID, value); |
| } |
| |
| public void setFieldValue(_Fields field, Object value) { |
| switch (field) { |
| case GRANT_OPTION: |
| if (value == null) { |
| unsetGrantOption(); |
| } else { |
| setGrantOption((TSentryGrantOption)value); |
| } |
| break; |
| |
| case PRIVILEGE: |
| if (value == null) { |
| unsetPrivilege(); |
| } else { |
| setPrivilege((Short)value); |
| } |
| break; |
| |
| } |
| } |
| |
| public Object getFieldValue(_Fields field) { |
| switch (field) { |
| case GRANT_OPTION: |
| return getGrantOption(); |
| |
| case PRIVILEGE: |
| return Short.valueOf(getPrivilege()); |
| |
| } |
| 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 GRANT_OPTION: |
| return isSetGrantOption(); |
| case PRIVILEGE: |
| return isSetPrivilege(); |
| } |
| throw new IllegalStateException(); |
| } |
| |
| @Override |
| public boolean equals(Object that) { |
| if (that == null) |
| return false; |
| if (that instanceof TStorePrivilege) |
| return this.equals((TStorePrivilege)that); |
| return false; |
| } |
| |
| public boolean equals(TStorePrivilege that) { |
| if (that == null) |
| return false; |
| |
| boolean this_present_grantOption = true && this.isSetGrantOption(); |
| boolean that_present_grantOption = true && that.isSetGrantOption(); |
| if (this_present_grantOption || that_present_grantOption) { |
| if (!(this_present_grantOption && that_present_grantOption)) |
| return false; |
| if (!this.grantOption.equals(that.grantOption)) |
| return false; |
| } |
| |
| boolean this_present_privilege = true; |
| boolean that_present_privilege = true; |
| if (this_present_privilege || that_present_privilege) { |
| if (!(this_present_privilege && that_present_privilege)) |
| return false; |
| if (this.privilege != that.privilege) |
| return false; |
| } |
| |
| return true; |
| } |
| |
| @Override |
| public int hashCode() { |
| HashCodeBuilder builder = new HashCodeBuilder(); |
| |
| boolean present_grantOption = true && (isSetGrantOption()); |
| builder.append(present_grantOption); |
| if (present_grantOption) |
| builder.append(grantOption.getValue()); |
| |
| boolean present_privilege = true; |
| builder.append(present_privilege); |
| if (present_privilege) |
| builder.append(privilege); |
| |
| return builder.toHashCode(); |
| } |
| |
| public int compareTo(TStorePrivilege other) { |
| if (!getClass().equals(other.getClass())) { |
| return getClass().getName().compareTo(other.getClass().getName()); |
| } |
| |
| int lastComparison = 0; |
| TStorePrivilege typedOther = (TStorePrivilege)other; |
| |
| lastComparison = Boolean.valueOf(isSetGrantOption()).compareTo(typedOther.isSetGrantOption()); |
| if (lastComparison != 0) { |
| return lastComparison; |
| } |
| if (isSetGrantOption()) { |
| lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.grantOption, typedOther.grantOption); |
| if (lastComparison != 0) { |
| return lastComparison; |
| } |
| } |
| lastComparison = Boolean.valueOf(isSetPrivilege()).compareTo(typedOther.isSetPrivilege()); |
| if (lastComparison != 0) { |
| return lastComparison; |
| } |
| if (isSetPrivilege()) { |
| lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.privilege, typedOther.privilege); |
| 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("TStorePrivilege("); |
| boolean first = true; |
| |
| sb.append("grantOption:"); |
| if (this.grantOption == null) { |
| sb.append("null"); |
| } else { |
| sb.append(this.grantOption); |
| } |
| first = false; |
| if (!first) sb.append(", "); |
| sb.append("privilege:"); |
| sb.append(this.privilege); |
| first = false; |
| sb.append(")"); |
| return sb.toString(); |
| } |
| |
| public void validate() throws org.apache.thrift.TException { |
| // check for required fields |
| if (!isSetGrantOption()) { |
| throw new org.apache.thrift.protocol.TProtocolException("Required field 'grantOption' is unset! Struct:" + toString()); |
| } |
| |
| if (!isSetPrivilege()) { |
| throw new org.apache.thrift.protocol.TProtocolException("Required field 'privilege' 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 { |
| // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. |
| __isset_bitfield = 0; |
| 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 TStorePrivilegeStandardSchemeFactory implements SchemeFactory { |
| public TStorePrivilegeStandardScheme getScheme() { |
| return new TStorePrivilegeStandardScheme(); |
| } |
| } |
| |
| private static class TStorePrivilegeStandardScheme extends StandardScheme<TStorePrivilege> { |
| |
| public void read(org.apache.thrift.protocol.TProtocol iprot, TStorePrivilege 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: // GRANT_OPTION |
| if (schemeField.type == org.apache.thrift.protocol.TType.I32) { |
| struct.grantOption = TSentryGrantOption.findByValue(iprot.readI32()); |
| struct.setGrantOptionIsSet(true); |
| } else { |
| org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); |
| } |
| break; |
| case 2: // PRIVILEGE |
| if (schemeField.type == org.apache.thrift.protocol.TType.I16) { |
| struct.privilege = iprot.readI16(); |
| struct.setPrivilegeIsSet(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, TStorePrivilege struct) throws org.apache.thrift.TException { |
| struct.validate(); |
| |
| oprot.writeStructBegin(STRUCT_DESC); |
| if (struct.grantOption != null) { |
| oprot.writeFieldBegin(GRANT_OPTION_FIELD_DESC); |
| oprot.writeI32(struct.grantOption.getValue()); |
| oprot.writeFieldEnd(); |
| } |
| oprot.writeFieldBegin(PRIVILEGE_FIELD_DESC); |
| oprot.writeI16(struct.privilege); |
| oprot.writeFieldEnd(); |
| oprot.writeFieldStop(); |
| oprot.writeStructEnd(); |
| } |
| |
| } |
| |
| private static class TStorePrivilegeTupleSchemeFactory implements SchemeFactory { |
| public TStorePrivilegeTupleScheme getScheme() { |
| return new TStorePrivilegeTupleScheme(); |
| } |
| } |
| |
| private static class TStorePrivilegeTupleScheme extends TupleScheme<TStorePrivilege> { |
| |
| @Override |
| public void write(org.apache.thrift.protocol.TProtocol prot, TStorePrivilege struct) throws org.apache.thrift.TException { |
| TTupleProtocol oprot = (TTupleProtocol) prot; |
| oprot.writeI32(struct.grantOption.getValue()); |
| oprot.writeI16(struct.privilege); |
| } |
| |
| @Override |
| public void read(org.apache.thrift.protocol.TProtocol prot, TStorePrivilege struct) throws org.apache.thrift.TException { |
| TTupleProtocol iprot = (TTupleProtocol) prot; |
| struct.grantOption = TSentryGrantOption.findByValue(iprot.readI32()); |
| struct.setGrantOptionIsSet(true); |
| struct.privilege = iprot.readI16(); |
| struct.setPrivilegeIsSet(true); |
| } |
| } |
| |
| } |
| |