ConfigVariable.java 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. /**
  2. * Autogenerated by Thrift
  3. *
  4. * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  5. */
  6. package com.cloudera.beeswax.api;
  7. import org.apache.commons.lang.builder.HashCodeBuilder;
  8. import java.util.List;
  9. import java.util.ArrayList;
  10. import java.util.Map;
  11. import java.util.HashMap;
  12. import java.util.Set;
  13. import java.util.HashSet;
  14. import java.util.Collections;
  15. import org.apache.log4j.Logger;
  16. import org.apache.thrift.*;
  17. import org.apache.thrift.meta_data.*;
  18. import org.apache.thrift.protocol.*;
  19. /**
  20. * Represents a Hadoop-style configuration variable.
  21. */
  22. public class ConfigVariable implements TBase, java.io.Serializable, Cloneable {
  23. private static final TStruct STRUCT_DESC = new TStruct("ConfigVariable");
  24. private static final TField KEY_FIELD_DESC = new TField("key", TType.STRING, (short)1);
  25. private static final TField VALUE_FIELD_DESC = new TField("value", TType.STRING, (short)2);
  26. private static final TField DESCRIPTION_FIELD_DESC = new TField("description", TType.STRING, (short)3);
  27. public String key;
  28. public static final int KEY = 1;
  29. public String value;
  30. public static final int VALUE = 2;
  31. public String description;
  32. public static final int DESCRIPTION = 3;
  33. private final Isset __isset = new Isset();
  34. private static final class Isset implements java.io.Serializable {
  35. }
  36. public static final Map<Integer, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new HashMap<Integer, FieldMetaData>() {{
  37. put(KEY, new FieldMetaData("key", TFieldRequirementType.DEFAULT,
  38. new FieldValueMetaData(TType.STRING)));
  39. put(VALUE, new FieldMetaData("value", TFieldRequirementType.DEFAULT,
  40. new FieldValueMetaData(TType.STRING)));
  41. put(DESCRIPTION, new FieldMetaData("description", TFieldRequirementType.DEFAULT,
  42. new FieldValueMetaData(TType.STRING)));
  43. }});
  44. static {
  45. FieldMetaData.addStructMetaDataMap(ConfigVariable.class, metaDataMap);
  46. }
  47. public ConfigVariable() {
  48. }
  49. public ConfigVariable(
  50. String key,
  51. String value,
  52. String description)
  53. {
  54. this();
  55. this.key = key;
  56. this.value = value;
  57. this.description = description;
  58. }
  59. /**
  60. * Performs a deep copy on <i>other</i>.
  61. */
  62. public ConfigVariable(ConfigVariable other) {
  63. if (other.isSetKey()) {
  64. this.key = other.key;
  65. }
  66. if (other.isSetValue()) {
  67. this.value = other.value;
  68. }
  69. if (other.isSetDescription()) {
  70. this.description = other.description;
  71. }
  72. }
  73. @Override
  74. public ConfigVariable clone() {
  75. return new ConfigVariable(this);
  76. }
  77. public String getKey() {
  78. return this.key;
  79. }
  80. public void setKey(String key) {
  81. this.key = key;
  82. }
  83. public void unsetKey() {
  84. this.key = null;
  85. }
  86. // Returns true if field key is set (has been asigned a value) and false otherwise
  87. public boolean isSetKey() {
  88. return this.key != null;
  89. }
  90. public void setKeyIsSet(boolean value) {
  91. if (!value) {
  92. this.key = null;
  93. }
  94. }
  95. public String getValue() {
  96. return this.value;
  97. }
  98. public void setValue(String value) {
  99. this.value = value;
  100. }
  101. public void unsetValue() {
  102. this.value = null;
  103. }
  104. // Returns true if field value is set (has been asigned a value) and false otherwise
  105. public boolean isSetValue() {
  106. return this.value != null;
  107. }
  108. public void setValueIsSet(boolean value) {
  109. if (!value) {
  110. this.value = null;
  111. }
  112. }
  113. public String getDescription() {
  114. return this.description;
  115. }
  116. public void setDescription(String description) {
  117. this.description = description;
  118. }
  119. public void unsetDescription() {
  120. this.description = null;
  121. }
  122. // Returns true if field description is set (has been asigned a value) and false otherwise
  123. public boolean isSetDescription() {
  124. return this.description != null;
  125. }
  126. public void setDescriptionIsSet(boolean value) {
  127. if (!value) {
  128. this.description = null;
  129. }
  130. }
  131. public void setFieldValue(int fieldID, Object value) {
  132. switch (fieldID) {
  133. case KEY:
  134. if (value == null) {
  135. unsetKey();
  136. } else {
  137. setKey((String)value);
  138. }
  139. break;
  140. case VALUE:
  141. if (value == null) {
  142. unsetValue();
  143. } else {
  144. setValue((String)value);
  145. }
  146. break;
  147. case DESCRIPTION:
  148. if (value == null) {
  149. unsetDescription();
  150. } else {
  151. setDescription((String)value);
  152. }
  153. break;
  154. default:
  155. throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
  156. }
  157. }
  158. public Object getFieldValue(int fieldID) {
  159. switch (fieldID) {
  160. case KEY:
  161. return getKey();
  162. case VALUE:
  163. return getValue();
  164. case DESCRIPTION:
  165. return getDescription();
  166. default:
  167. throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
  168. }
  169. }
  170. // Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise
  171. public boolean isSet(int fieldID) {
  172. switch (fieldID) {
  173. case KEY:
  174. return isSetKey();
  175. case VALUE:
  176. return isSetValue();
  177. case DESCRIPTION:
  178. return isSetDescription();
  179. default:
  180. throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
  181. }
  182. }
  183. @Override
  184. public boolean equals(Object that) {
  185. if (that == null)
  186. return false;
  187. if (that instanceof ConfigVariable)
  188. return this.equals((ConfigVariable)that);
  189. return false;
  190. }
  191. public boolean equals(ConfigVariable that) {
  192. if (that == null)
  193. return false;
  194. boolean this_present_key = true && this.isSetKey();
  195. boolean that_present_key = true && that.isSetKey();
  196. if (this_present_key || that_present_key) {
  197. if (!(this_present_key && that_present_key))
  198. return false;
  199. if (!this.key.equals(that.key))
  200. return false;
  201. }
  202. boolean this_present_value = true && this.isSetValue();
  203. boolean that_present_value = true && that.isSetValue();
  204. if (this_present_value || that_present_value) {
  205. if (!(this_present_value && that_present_value))
  206. return false;
  207. if (!this.value.equals(that.value))
  208. return false;
  209. }
  210. boolean this_present_description = true && this.isSetDescription();
  211. boolean that_present_description = true && that.isSetDescription();
  212. if (this_present_description || that_present_description) {
  213. if (!(this_present_description && that_present_description))
  214. return false;
  215. if (!this.description.equals(that.description))
  216. return false;
  217. }
  218. return true;
  219. }
  220. @Override
  221. public int hashCode() {
  222. HashCodeBuilder builder = new HashCodeBuilder();
  223. boolean present_key = true && (isSetKey());
  224. builder.append(present_key);
  225. if (present_key)
  226. builder.append(key);
  227. boolean present_value = true && (isSetValue());
  228. builder.append(present_value);
  229. if (present_value)
  230. builder.append(value);
  231. boolean present_description = true && (isSetDescription());
  232. builder.append(present_description);
  233. if (present_description)
  234. builder.append(description);
  235. return builder.toHashCode();
  236. }
  237. public void read(TProtocol iprot) throws TException {
  238. TField field;
  239. iprot.readStructBegin();
  240. while (true)
  241. {
  242. field = iprot.readFieldBegin();
  243. if (field.type == TType.STOP) {
  244. break;
  245. }
  246. switch (field.id)
  247. {
  248. case KEY:
  249. if (field.type == TType.STRING) {
  250. this.key = iprot.readString();
  251. } else {
  252. TProtocolUtil.skip(iprot, field.type);
  253. }
  254. break;
  255. case VALUE:
  256. if (field.type == TType.STRING) {
  257. this.value = iprot.readString();
  258. } else {
  259. TProtocolUtil.skip(iprot, field.type);
  260. }
  261. break;
  262. case DESCRIPTION:
  263. if (field.type == TType.STRING) {
  264. this.description = iprot.readString();
  265. } else {
  266. TProtocolUtil.skip(iprot, field.type);
  267. }
  268. break;
  269. default:
  270. TProtocolUtil.skip(iprot, field.type);
  271. break;
  272. }
  273. iprot.readFieldEnd();
  274. }
  275. iprot.readStructEnd();
  276. // check for required fields of primitive type, which can't be checked in the validate method
  277. validate();
  278. }
  279. public void write(TProtocol oprot) throws TException {
  280. validate();
  281. oprot.writeStructBegin(STRUCT_DESC);
  282. if (this.key != null) {
  283. oprot.writeFieldBegin(KEY_FIELD_DESC);
  284. oprot.writeString(this.key);
  285. oprot.writeFieldEnd();
  286. }
  287. if (this.value != null) {
  288. oprot.writeFieldBegin(VALUE_FIELD_DESC);
  289. oprot.writeString(this.value);
  290. oprot.writeFieldEnd();
  291. }
  292. if (this.description != null) {
  293. oprot.writeFieldBegin(DESCRIPTION_FIELD_DESC);
  294. oprot.writeString(this.description);
  295. oprot.writeFieldEnd();
  296. }
  297. oprot.writeFieldStop();
  298. oprot.writeStructEnd();
  299. }
  300. @Override
  301. public String toString() {
  302. StringBuilder sb = new StringBuilder("ConfigVariable(");
  303. boolean first = true;
  304. sb.append("key:");
  305. if (this.key == null) {
  306. sb.append("null");
  307. } else {
  308. sb.append(this.key);
  309. }
  310. first = false;
  311. if (!first) sb.append(", ");
  312. sb.append("value:");
  313. if (this.value == null) {
  314. sb.append("null");
  315. } else {
  316. sb.append(this.value);
  317. }
  318. first = false;
  319. if (!first) sb.append(", ");
  320. sb.append("description:");
  321. if (this.description == null) {
  322. sb.append("null");
  323. } else {
  324. sb.append(this.description);
  325. }
  326. first = false;
  327. sb.append(")");
  328. return sb.toString();
  329. }
  330. public void validate() throws TException {
  331. // check for required fields
  332. // check that fields of type enum have valid values
  333. }
  334. }