PageRenderTime 48ms CodeModel.GetById 11ms app.highlight 31ms RepoModel.GetById 2ms app.codeStats 0ms

/tags/release-0.0.0-rc0/hive/external/metastore/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/PrivilegeBag.java

#
Java | 344 lines | 268 code | 53 blank | 23 comment | 51 complexity | 614679a3f6144746bcc695fe3883519c MD5 | raw file
  1/**
  2 * Autogenerated by Thrift
  3 *
  4 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  5 */
  6package org.apache.hadoop.hive.metastore.api;
  7
  8import java.util.List;
  9import java.util.ArrayList;
 10import java.util.Map;
 11import java.util.HashMap;
 12import java.util.EnumMap;
 13import java.util.Set;
 14import java.util.HashSet;
 15import java.util.EnumSet;
 16import java.util.Collections;
 17import java.util.BitSet;
 18import java.nio.ByteBuffer;
 19import java.util.Arrays;
 20import org.slf4j.Logger;
 21import org.slf4j.LoggerFactory;
 22
 23import org.apache.thrift.*;
 24import org.apache.thrift.async.*;
 25import org.apache.thrift.meta_data.*;
 26import org.apache.thrift.transport.*;
 27import org.apache.thrift.protocol.*;
 28
 29public class PrivilegeBag implements TBase<PrivilegeBag, PrivilegeBag._Fields>, java.io.Serializable, Cloneable {
 30  private static final TStruct STRUCT_DESC = new TStruct("PrivilegeBag");
 31
 32  private static final TField PRIVILEGES_FIELD_DESC = new TField("privileges", TType.LIST, (short)1);
 33
 34  private List<HiveObjectPrivilege> privileges;
 35
 36  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
 37  public enum _Fields implements TFieldIdEnum {
 38    PRIVILEGES((short)1, "privileges");
 39
 40    private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
 41
 42    static {
 43      for (_Fields field : EnumSet.allOf(_Fields.class)) {
 44        byName.put(field.getFieldName(), field);
 45      }
 46    }
 47
 48    /**
 49     * Find the _Fields constant that matches fieldId, or null if its not found.
 50     */
 51    public static _Fields findByThriftId(int fieldId) {
 52      switch(fieldId) {
 53        case 1: // PRIVILEGES
 54          return PRIVILEGES;
 55        default:
 56          return null;
 57      }
 58    }
 59
 60    /**
 61     * Find the _Fields constant that matches fieldId, throwing an exception
 62     * if it is not found.
 63     */
 64    public static _Fields findByThriftIdOrThrow(int fieldId) {
 65      _Fields fields = findByThriftId(fieldId);
 66      if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
 67      return fields;
 68    }
 69
 70    /**
 71     * Find the _Fields constant that matches name, or null if its not found.
 72     */
 73    public static _Fields findByName(String name) {
 74      return byName.get(name);
 75    }
 76
 77    private final short _thriftId;
 78    private final String _fieldName;
 79
 80    _Fields(short thriftId, String fieldName) {
 81      _thriftId = thriftId;
 82      _fieldName = fieldName;
 83    }
 84
 85    public short getThriftFieldId() {
 86      return _thriftId;
 87    }
 88
 89    public String getFieldName() {
 90      return _fieldName;
 91    }
 92  }
 93
 94  // isset id assignments
 95
 96  public static final Map<_Fields, FieldMetaData> metaDataMap;
 97  static {
 98    Map<_Fields, FieldMetaData> tmpMap = new EnumMap<_Fields, FieldMetaData>(_Fields.class);
 99    tmpMap.put(_Fields.PRIVILEGES, new FieldMetaData("privileges", TFieldRequirementType.DEFAULT, 
100        new ListMetaData(TType.LIST, 
101            new StructMetaData(TType.STRUCT, HiveObjectPrivilege.class))));
102    metaDataMap = Collections.unmodifiableMap(tmpMap);
103    FieldMetaData.addStructMetaDataMap(PrivilegeBag.class, metaDataMap);
104  }
105
106  public PrivilegeBag() {
107  }
108
109  public PrivilegeBag(
110    List<HiveObjectPrivilege> privileges)
111  {
112    this();
113    this.privileges = privileges;
114  }
115
116  /**
117   * Performs a deep copy on <i>other</i>.
118   */
119  public PrivilegeBag(PrivilegeBag other) {
120    if (other.isSetPrivileges()) {
121      List<HiveObjectPrivilege> __this__privileges = new ArrayList<HiveObjectPrivilege>();
122      for (HiveObjectPrivilege other_element : other.privileges) {
123        __this__privileges.add(new HiveObjectPrivilege(other_element));
124      }
125      this.privileges = __this__privileges;
126    }
127  }
128
129  public PrivilegeBag deepCopy() {
130    return new PrivilegeBag(this);
131  }
132
133  @Override
134  public void clear() {
135    this.privileges = null;
136  }
137
138  public int getPrivilegesSize() {
139    return (this.privileges == null) ? 0 : this.privileges.size();
140  }
141
142  public java.util.Iterator<HiveObjectPrivilege> getPrivilegesIterator() {
143    return (this.privileges == null) ? null : this.privileges.iterator();
144  }
145
146  public void addToPrivileges(HiveObjectPrivilege elem) {
147    if (this.privileges == null) {
148      this.privileges = new ArrayList<HiveObjectPrivilege>();
149    }
150    this.privileges.add(elem);
151  }
152
153  public List<HiveObjectPrivilege> getPrivileges() {
154    return this.privileges;
155  }
156
157  public void setPrivileges(List<HiveObjectPrivilege> privileges) {
158    this.privileges = privileges;
159  }
160
161  public void unsetPrivileges() {
162    this.privileges = null;
163  }
164
165  /** Returns true if field privileges is set (has been asigned a value) and false otherwise */
166  public boolean isSetPrivileges() {
167    return this.privileges != null;
168  }
169
170  public void setPrivilegesIsSet(boolean value) {
171    if (!value) {
172      this.privileges = null;
173    }
174  }
175
176  public void setFieldValue(_Fields field, Object value) {
177    switch (field) {
178    case PRIVILEGES:
179      if (value == null) {
180        unsetPrivileges();
181      } else {
182        setPrivileges((List<HiveObjectPrivilege>)value);
183      }
184      break;
185
186    }
187  }
188
189  public Object getFieldValue(_Fields field) {
190    switch (field) {
191    case PRIVILEGES:
192      return getPrivileges();
193
194    }
195    throw new IllegalStateException();
196  }
197
198  /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
199  public boolean isSet(_Fields field) {
200    if (field == null) {
201      throw new IllegalArgumentException();
202    }
203
204    switch (field) {
205    case PRIVILEGES:
206      return isSetPrivileges();
207    }
208    throw new IllegalStateException();
209  }
210
211  @Override
212  public boolean equals(Object that) {
213    if (that == null)
214      return false;
215    if (that instanceof PrivilegeBag)
216      return this.equals((PrivilegeBag)that);
217    return false;
218  }
219
220  public boolean equals(PrivilegeBag that) {
221    if (that == null)
222      return false;
223
224    boolean this_present_privileges = true && this.isSetPrivileges();
225    boolean that_present_privileges = true && that.isSetPrivileges();
226    if (this_present_privileges || that_present_privileges) {
227      if (!(this_present_privileges && that_present_privileges))
228        return false;
229      if (!this.privileges.equals(that.privileges))
230        return false;
231    }
232
233    return true;
234  }
235
236  @Override
237  public int hashCode() {
238    return 0;
239  }
240
241  public int compareTo(PrivilegeBag other) {
242    if (!getClass().equals(other.getClass())) {
243      return getClass().getName().compareTo(other.getClass().getName());
244    }
245
246    int lastComparison = 0;
247    PrivilegeBag typedOther = (PrivilegeBag)other;
248
249    lastComparison = Boolean.valueOf(isSetPrivileges()).compareTo(typedOther.isSetPrivileges());
250    if (lastComparison != 0) {
251      return lastComparison;
252    }
253    if (isSetPrivileges()) {
254      lastComparison = TBaseHelper.compareTo(this.privileges, typedOther.privileges);
255      if (lastComparison != 0) {
256        return lastComparison;
257      }
258    }
259    return 0;
260  }
261
262  public _Fields fieldForId(int fieldId) {
263    return _Fields.findByThriftId(fieldId);
264  }
265
266  public void read(TProtocol iprot) throws TException {
267    TField field;
268    iprot.readStructBegin();
269    while (true)
270    {
271      field = iprot.readFieldBegin();
272      if (field.type == TType.STOP) { 
273        break;
274      }
275      switch (field.id) {
276        case 1: // PRIVILEGES
277          if (field.type == TType.LIST) {
278            {
279              TList _list8 = iprot.readListBegin();
280              this.privileges = new ArrayList<HiveObjectPrivilege>(_list8.size);
281              for (int _i9 = 0; _i9 < _list8.size; ++_i9)
282              {
283                HiveObjectPrivilege _elem10;
284                _elem10 = new HiveObjectPrivilege();
285                _elem10.read(iprot);
286                this.privileges.add(_elem10);
287              }
288              iprot.readListEnd();
289            }
290          } else { 
291            TProtocolUtil.skip(iprot, field.type);
292          }
293          break;
294        default:
295          TProtocolUtil.skip(iprot, field.type);
296      }
297      iprot.readFieldEnd();
298    }
299    iprot.readStructEnd();
300    validate();
301  }
302
303  public void write(TProtocol oprot) throws TException {
304    validate();
305
306    oprot.writeStructBegin(STRUCT_DESC);
307    if (this.privileges != null) {
308      oprot.writeFieldBegin(PRIVILEGES_FIELD_DESC);
309      {
310        oprot.writeListBegin(new TList(TType.STRUCT, this.privileges.size()));
311        for (HiveObjectPrivilege _iter11 : this.privileges)
312        {
313          _iter11.write(oprot);
314        }
315        oprot.writeListEnd();
316      }
317      oprot.writeFieldEnd();
318    }
319    oprot.writeFieldStop();
320    oprot.writeStructEnd();
321  }
322
323  @Override
324  public String toString() {
325    StringBuilder sb = new StringBuilder("PrivilegeBag(");
326    boolean first = true;
327
328    sb.append("privileges:");
329    if (this.privileges == null) {
330      sb.append("null");
331    } else {
332      sb.append(this.privileges);
333    }
334    first = false;
335    sb.append(")");
336    return sb.toString();
337  }
338
339  public void validate() throws TException {
340    // check for required fields
341  }
342
343}
344