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