PageRenderTime 57ms CodeModel.GetById 10ms app.highlight 42ms RepoModel.GetById 1ms app.codeStats 1ms

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

#
Java | 482 lines | 391 code | 66 blank | 25 comment | 98 complexity | 4bd0fb04fd2d633c154c8b41d230c0bd 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 FieldSchema implements TBase<FieldSchema, FieldSchema._Fields>, java.io.Serializable, Cloneable {
 30  private static final TStruct STRUCT_DESC = new TStruct("FieldSchema");
 31
 32  private static final TField NAME_FIELD_DESC = new TField("name", TType.STRING, (short)1);
 33  private static final TField TYPE_FIELD_DESC = new TField("type", TType.STRING, (short)2);
 34  private static final TField COMMENT_FIELD_DESC = new TField("comment", TType.STRING, (short)3);
 35
 36  private String name;
 37  private String type;
 38  private String comment;
 39
 40  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
 41  public enum _Fields implements TFieldIdEnum {
 42    NAME((short)1, "name"),
 43    TYPE((short)2, "type"),
 44    COMMENT((short)3, "comment");
 45
 46    private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
 47
 48    static {
 49      for (_Fields field : EnumSet.allOf(_Fields.class)) {
 50        byName.put(field.getFieldName(), field);
 51      }
 52    }
 53
 54    /**
 55     * Find the _Fields constant that matches fieldId, or null if its not found.
 56     */
 57    public static _Fields findByThriftId(int fieldId) {
 58      switch(fieldId) {
 59        case 1: // NAME
 60          return NAME;
 61        case 2: // TYPE
 62          return TYPE;
 63        case 3: // COMMENT
 64          return COMMENT;
 65        default:
 66          return null;
 67      }
 68    }
 69
 70    /**
 71     * Find the _Fields constant that matches fieldId, throwing an exception
 72     * if it is not found.
 73     */
 74    public static _Fields findByThriftIdOrThrow(int fieldId) {
 75      _Fields fields = findByThriftId(fieldId);
 76      if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
 77      return fields;
 78    }
 79
 80    /**
 81     * Find the _Fields constant that matches name, or null if its not found.
 82     */
 83    public static _Fields findByName(String name) {
 84      return byName.get(name);
 85    }
 86
 87    private final short _thriftId;
 88    private final String _fieldName;
 89
 90    _Fields(short thriftId, String fieldName) {
 91      _thriftId = thriftId;
 92      _fieldName = fieldName;
 93    }
 94
 95    public short getThriftFieldId() {
 96      return _thriftId;
 97    }
 98
 99    public String getFieldName() {
100      return _fieldName;
101    }
102  }
103
104  // isset id assignments
105
106  public static final Map<_Fields, FieldMetaData> metaDataMap;
107  static {
108    Map<_Fields, FieldMetaData> tmpMap = new EnumMap<_Fields, FieldMetaData>(_Fields.class);
109    tmpMap.put(_Fields.NAME, new FieldMetaData("name", TFieldRequirementType.DEFAULT, 
110        new FieldValueMetaData(TType.STRING)));
111    tmpMap.put(_Fields.TYPE, new FieldMetaData("type", TFieldRequirementType.DEFAULT, 
112        new FieldValueMetaData(TType.STRING)));
113    tmpMap.put(_Fields.COMMENT, new FieldMetaData("comment", TFieldRequirementType.DEFAULT, 
114        new FieldValueMetaData(TType.STRING)));
115    metaDataMap = Collections.unmodifiableMap(tmpMap);
116    FieldMetaData.addStructMetaDataMap(FieldSchema.class, metaDataMap);
117  }
118
119  public FieldSchema() {
120  }
121
122  public FieldSchema(
123    String name,
124    String type,
125    String comment)
126  {
127    this();
128    this.name = name;
129    this.type = type;
130    this.comment = comment;
131  }
132
133  /**
134   * Performs a deep copy on <i>other</i>.
135   */
136  public FieldSchema(FieldSchema other) {
137    if (other.isSetName()) {
138      this.name = other.name;
139    }
140    if (other.isSetType()) {
141      this.type = other.type;
142    }
143    if (other.isSetComment()) {
144      this.comment = other.comment;
145    }
146  }
147
148  public FieldSchema deepCopy() {
149    return new FieldSchema(this);
150  }
151
152  @Override
153  public void clear() {
154    this.name = null;
155    this.type = null;
156    this.comment = null;
157  }
158
159  public String getName() {
160    return this.name;
161  }
162
163  public void setName(String name) {
164    this.name = name;
165  }
166
167  public void unsetName() {
168    this.name = null;
169  }
170
171  /** Returns true if field name is set (has been asigned a value) and false otherwise */
172  public boolean isSetName() {
173    return this.name != null;
174  }
175
176  public void setNameIsSet(boolean value) {
177    if (!value) {
178      this.name = null;
179    }
180  }
181
182  public String getType() {
183    return this.type;
184  }
185
186  public void setType(String type) {
187    this.type = type;
188  }
189
190  public void unsetType() {
191    this.type = null;
192  }
193
194  /** Returns true if field type is set (has been asigned a value) and false otherwise */
195  public boolean isSetType() {
196    return this.type != null;
197  }
198
199  public void setTypeIsSet(boolean value) {
200    if (!value) {
201      this.type = null;
202    }
203  }
204
205  public String getComment() {
206    return this.comment;
207  }
208
209  public void setComment(String comment) {
210    this.comment = comment;
211  }
212
213  public void unsetComment() {
214    this.comment = null;
215  }
216
217  /** Returns true if field comment is set (has been asigned a value) and false otherwise */
218  public boolean isSetComment() {
219    return this.comment != null;
220  }
221
222  public void setCommentIsSet(boolean value) {
223    if (!value) {
224      this.comment = null;
225    }
226  }
227
228  public void setFieldValue(_Fields field, Object value) {
229    switch (field) {
230    case NAME:
231      if (value == null) {
232        unsetName();
233      } else {
234        setName((String)value);
235      }
236      break;
237
238    case TYPE:
239      if (value == null) {
240        unsetType();
241      } else {
242        setType((String)value);
243      }
244      break;
245
246    case COMMENT:
247      if (value == null) {
248        unsetComment();
249      } else {
250        setComment((String)value);
251      }
252      break;
253
254    }
255  }
256
257  public Object getFieldValue(_Fields field) {
258    switch (field) {
259    case NAME:
260      return getName();
261
262    case TYPE:
263      return getType();
264
265    case COMMENT:
266      return getComment();
267
268    }
269    throw new IllegalStateException();
270  }
271
272  /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
273  public boolean isSet(_Fields field) {
274    if (field == null) {
275      throw new IllegalArgumentException();
276    }
277
278    switch (field) {
279    case NAME:
280      return isSetName();
281    case TYPE:
282      return isSetType();
283    case COMMENT:
284      return isSetComment();
285    }
286    throw new IllegalStateException();
287  }
288
289  @Override
290  public boolean equals(Object that) {
291    if (that == null)
292      return false;
293    if (that instanceof FieldSchema)
294      return this.equals((FieldSchema)that);
295    return false;
296  }
297
298  public boolean equals(FieldSchema that) {
299    if (that == null)
300      return false;
301
302    boolean this_present_name = true && this.isSetName();
303    boolean that_present_name = true && that.isSetName();
304    if (this_present_name || that_present_name) {
305      if (!(this_present_name && that_present_name))
306        return false;
307      if (!this.name.equals(that.name))
308        return false;
309    }
310
311    boolean this_present_type = true && this.isSetType();
312    boolean that_present_type = true && that.isSetType();
313    if (this_present_type || that_present_type) {
314      if (!(this_present_type && that_present_type))
315        return false;
316      if (!this.type.equals(that.type))
317        return false;
318    }
319
320    boolean this_present_comment = true && this.isSetComment();
321    boolean that_present_comment = true && that.isSetComment();
322    if (this_present_comment || that_present_comment) {
323      if (!(this_present_comment && that_present_comment))
324        return false;
325      if (!this.comment.equals(that.comment))
326        return false;
327    }
328
329    return true;
330  }
331
332  @Override
333  public int hashCode() {
334    return 0;
335  }
336
337  public int compareTo(FieldSchema other) {
338    if (!getClass().equals(other.getClass())) {
339      return getClass().getName().compareTo(other.getClass().getName());
340    }
341
342    int lastComparison = 0;
343    FieldSchema typedOther = (FieldSchema)other;
344
345    lastComparison = Boolean.valueOf(isSetName()).compareTo(typedOther.isSetName());
346    if (lastComparison != 0) {
347      return lastComparison;
348    }
349    if (isSetName()) {
350      lastComparison = TBaseHelper.compareTo(this.name, typedOther.name);
351      if (lastComparison != 0) {
352        return lastComparison;
353      }
354    }
355    lastComparison = Boolean.valueOf(isSetType()).compareTo(typedOther.isSetType());
356    if (lastComparison != 0) {
357      return lastComparison;
358    }
359    if (isSetType()) {
360      lastComparison = TBaseHelper.compareTo(this.type, typedOther.type);
361      if (lastComparison != 0) {
362        return lastComparison;
363      }
364    }
365    lastComparison = Boolean.valueOf(isSetComment()).compareTo(typedOther.isSetComment());
366    if (lastComparison != 0) {
367      return lastComparison;
368    }
369    if (isSetComment()) {
370      lastComparison = TBaseHelper.compareTo(this.comment, typedOther.comment);
371      if (lastComparison != 0) {
372        return lastComparison;
373      }
374    }
375    return 0;
376  }
377
378  public _Fields fieldForId(int fieldId) {
379    return _Fields.findByThriftId(fieldId);
380  }
381
382  public void read(TProtocol iprot) throws TException {
383    TField field;
384    iprot.readStructBegin();
385    while (true)
386    {
387      field = iprot.readFieldBegin();
388      if (field.type == TType.STOP) { 
389        break;
390      }
391      switch (field.id) {
392        case 1: // NAME
393          if (field.type == TType.STRING) {
394            this.name = iprot.readString();
395          } else { 
396            TProtocolUtil.skip(iprot, field.type);
397          }
398          break;
399        case 2: // TYPE
400          if (field.type == TType.STRING) {
401            this.type = iprot.readString();
402          } else { 
403            TProtocolUtil.skip(iprot, field.type);
404          }
405          break;
406        case 3: // COMMENT
407          if (field.type == TType.STRING) {
408            this.comment = iprot.readString();
409          } else { 
410            TProtocolUtil.skip(iprot, field.type);
411          }
412          break;
413        default:
414          TProtocolUtil.skip(iprot, field.type);
415      }
416      iprot.readFieldEnd();
417    }
418    iprot.readStructEnd();
419    validate();
420  }
421
422  public void write(TProtocol oprot) throws TException {
423    validate();
424
425    oprot.writeStructBegin(STRUCT_DESC);
426    if (this.name != null) {
427      oprot.writeFieldBegin(NAME_FIELD_DESC);
428      oprot.writeString(this.name);
429      oprot.writeFieldEnd();
430    }
431    if (this.type != null) {
432      oprot.writeFieldBegin(TYPE_FIELD_DESC);
433      oprot.writeString(this.type);
434      oprot.writeFieldEnd();
435    }
436    if (this.comment != null) {
437      oprot.writeFieldBegin(COMMENT_FIELD_DESC);
438      oprot.writeString(this.comment);
439      oprot.writeFieldEnd();
440    }
441    oprot.writeFieldStop();
442    oprot.writeStructEnd();
443  }
444
445  @Override
446  public String toString() {
447    StringBuilder sb = new StringBuilder("FieldSchema(");
448    boolean first = true;
449
450    sb.append("name:");
451    if (this.name == null) {
452      sb.append("null");
453    } else {
454      sb.append(this.name);
455    }
456    first = false;
457    if (!first) sb.append(", ");
458    sb.append("type:");
459    if (this.type == null) {
460      sb.append("null");
461    } else {
462      sb.append(this.type);
463    }
464    first = false;
465    if (!first) sb.append(", ");
466    sb.append("comment:");
467    if (this.comment == null) {
468      sb.append("null");
469    } else {
470      sb.append(this.comment);
471    }
472    first = false;
473    sb.append(")");
474    return sb.toString();
475  }
476
477  public void validate() throws TException {
478    // check for required fields
479  }
480
481}
482