Setting.java 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  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. public class Setting implements TBase, java.io.Serializable, Cloneable {
  20. private static final TStruct STRUCT_DESC = new TStruct("Setting");
  21. private static final TField KEY_FIELD_DESC = new TField("key", TType.STRING, (short)1);
  22. private static final TField VALUE_FIELD_DESC = new TField("value", TType.STRING, (short)2);
  23. public String key;
  24. public static final int KEY = 1;
  25. public String value;
  26. public static final int VALUE = 2;
  27. private final Isset __isset = new Isset();
  28. private static final class Isset implements java.io.Serializable {
  29. }
  30. public static final Map<Integer, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new HashMap<Integer, FieldMetaData>() {{
  31. put(KEY, new FieldMetaData("key", TFieldRequirementType.DEFAULT,
  32. new FieldValueMetaData(TType.STRING)));
  33. put(VALUE, new FieldMetaData("value", TFieldRequirementType.DEFAULT,
  34. new FieldValueMetaData(TType.STRING)));
  35. }});
  36. static {
  37. FieldMetaData.addStructMetaDataMap(Setting.class, metaDataMap);
  38. }
  39. public Setting() {
  40. }
  41. public Setting(
  42. String key,
  43. String value)
  44. {
  45. this();
  46. this.key = key;
  47. this.value = value;
  48. }
  49. /**
  50. * Performs a deep copy on <i>other</i>.
  51. */
  52. public Setting(Setting other) {
  53. if (other.isSetKey()) {
  54. this.key = other.key;
  55. }
  56. if (other.isSetValue()) {
  57. this.value = other.value;
  58. }
  59. }
  60. @Override
  61. public Setting clone() {
  62. return new Setting(this);
  63. }
  64. public String getKey() {
  65. return this.key;
  66. }
  67. public void setKey(String key) {
  68. this.key = key;
  69. }
  70. public void unsetKey() {
  71. this.key = null;
  72. }
  73. // Returns true if field key is set (has been asigned a value) and false otherwise
  74. public boolean isSetKey() {
  75. return this.key != null;
  76. }
  77. public void setKeyIsSet(boolean value) {
  78. if (!value) {
  79. this.key = null;
  80. }
  81. }
  82. public String getValue() {
  83. return this.value;
  84. }
  85. public void setValue(String value) {
  86. this.value = value;
  87. }
  88. public void unsetValue() {
  89. this.value = null;
  90. }
  91. // Returns true if field value is set (has been asigned a value) and false otherwise
  92. public boolean isSetValue() {
  93. return this.value != null;
  94. }
  95. public void setValueIsSet(boolean value) {
  96. if (!value) {
  97. this.value = null;
  98. }
  99. }
  100. public void setFieldValue(int fieldID, Object value) {
  101. switch (fieldID) {
  102. case KEY:
  103. if (value == null) {
  104. unsetKey();
  105. } else {
  106. setKey((String)value);
  107. }
  108. break;
  109. case VALUE:
  110. if (value == null) {
  111. unsetValue();
  112. } else {
  113. setValue((String)value);
  114. }
  115. break;
  116. default:
  117. throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
  118. }
  119. }
  120. public Object getFieldValue(int fieldID) {
  121. switch (fieldID) {
  122. case KEY:
  123. return getKey();
  124. case VALUE:
  125. return getValue();
  126. default:
  127. throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
  128. }
  129. }
  130. // Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise
  131. public boolean isSet(int fieldID) {
  132. switch (fieldID) {
  133. case KEY:
  134. return isSetKey();
  135. case VALUE:
  136. return isSetValue();
  137. default:
  138. throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
  139. }
  140. }
  141. @Override
  142. public boolean equals(Object that) {
  143. if (that == null)
  144. return false;
  145. if (that instanceof Setting)
  146. return this.equals((Setting)that);
  147. return false;
  148. }
  149. public boolean equals(Setting that) {
  150. if (that == null)
  151. return false;
  152. boolean this_present_key = true && this.isSetKey();
  153. boolean that_present_key = true && that.isSetKey();
  154. if (this_present_key || that_present_key) {
  155. if (!(this_present_key && that_present_key))
  156. return false;
  157. if (!this.key.equals(that.key))
  158. return false;
  159. }
  160. boolean this_present_value = true && this.isSetValue();
  161. boolean that_present_value = true && that.isSetValue();
  162. if (this_present_value || that_present_value) {
  163. if (!(this_present_value && that_present_value))
  164. return false;
  165. if (!this.value.equals(that.value))
  166. return false;
  167. }
  168. return true;
  169. }
  170. @Override
  171. public int hashCode() {
  172. HashCodeBuilder builder = new HashCodeBuilder();
  173. boolean present_key = true && (isSetKey());
  174. builder.append(present_key);
  175. if (present_key)
  176. builder.append(key);
  177. boolean present_value = true && (isSetValue());
  178. builder.append(present_value);
  179. if (present_value)
  180. builder.append(value);
  181. return builder.toHashCode();
  182. }
  183. public void read(TProtocol iprot) throws TException {
  184. TField field;
  185. iprot.readStructBegin();
  186. while (true)
  187. {
  188. field = iprot.readFieldBegin();
  189. if (field.type == TType.STOP) {
  190. break;
  191. }
  192. switch (field.id)
  193. {
  194. case KEY:
  195. if (field.type == TType.STRING) {
  196. this.key = iprot.readString();
  197. } else {
  198. TProtocolUtil.skip(iprot, field.type);
  199. }
  200. break;
  201. case VALUE:
  202. if (field.type == TType.STRING) {
  203. this.value = iprot.readString();
  204. } else {
  205. TProtocolUtil.skip(iprot, field.type);
  206. }
  207. break;
  208. default:
  209. TProtocolUtil.skip(iprot, field.type);
  210. break;
  211. }
  212. iprot.readFieldEnd();
  213. }
  214. iprot.readStructEnd();
  215. // check for required fields of primitive type, which can't be checked in the validate method
  216. validate();
  217. }
  218. public void write(TProtocol oprot) throws TException {
  219. validate();
  220. oprot.writeStructBegin(STRUCT_DESC);
  221. if (this.key != null) {
  222. oprot.writeFieldBegin(KEY_FIELD_DESC);
  223. oprot.writeString(this.key);
  224. oprot.writeFieldEnd();
  225. }
  226. if (this.value != null) {
  227. oprot.writeFieldBegin(VALUE_FIELD_DESC);
  228. oprot.writeString(this.value);
  229. oprot.writeFieldEnd();
  230. }
  231. oprot.writeFieldStop();
  232. oprot.writeStructEnd();
  233. }
  234. @Override
  235. public String toString() {
  236. StringBuilder sb = new StringBuilder("Setting(");
  237. boolean first = true;
  238. sb.append("key:");
  239. if (this.key == null) {
  240. sb.append("null");
  241. } else {
  242. sb.append(this.key);
  243. }
  244. first = false;
  245. if (!first) sb.append(", ");
  246. sb.append("value:");
  247. if (this.value == null) {
  248. sb.append("null");
  249. } else {
  250. sb.append(this.value);
  251. }
  252. first = false;
  253. sb.append(")");
  254. return sb.toString();
  255. }
  256. public void validate() throws TException {
  257. // check for required fields
  258. // check that fields of type enum have valid values
  259. }
  260. }