Function.java 7.4 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 Function implements TBase, java.io.Serializable, Cloneable {
  20. private static final TStruct STRUCT_DESC = new TStruct("Function");
  21. private static final TField NAME_FIELD_DESC = new TField("name", TType.STRING, (short)1);
  22. private static final TField CLASS_NAME_FIELD_DESC = new TField("class_name", TType.STRING, (short)2);
  23. public String name;
  24. public static final int NAME = 1;
  25. public String class_name;
  26. public static final int CLASS_NAME = 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(NAME, new FieldMetaData("name", TFieldRequirementType.DEFAULT,
  32. new FieldValueMetaData(TType.STRING)));
  33. put(CLASS_NAME, new FieldMetaData("class_name", TFieldRequirementType.DEFAULT,
  34. new FieldValueMetaData(TType.STRING)));
  35. }});
  36. static {
  37. FieldMetaData.addStructMetaDataMap(Function.class, metaDataMap);
  38. }
  39. public Function() {
  40. }
  41. public Function(
  42. String name,
  43. String class_name)
  44. {
  45. this();
  46. this.name = name;
  47. this.class_name = class_name;
  48. }
  49. /**
  50. * Performs a deep copy on <i>other</i>.
  51. */
  52. public Function(Function other) {
  53. if (other.isSetName()) {
  54. this.name = other.name;
  55. }
  56. if (other.isSetClass_name()) {
  57. this.class_name = other.class_name;
  58. }
  59. }
  60. @Override
  61. public Function clone() {
  62. return new Function(this);
  63. }
  64. public String getName() {
  65. return this.name;
  66. }
  67. public void setName(String name) {
  68. this.name = name;
  69. }
  70. public void unsetName() {
  71. this.name = null;
  72. }
  73. // Returns true if field name is set (has been asigned a value) and false otherwise
  74. public boolean isSetName() {
  75. return this.name != null;
  76. }
  77. public void setNameIsSet(boolean value) {
  78. if (!value) {
  79. this.name = null;
  80. }
  81. }
  82. public String getClass_name() {
  83. return this.class_name;
  84. }
  85. public void setClass_name(String class_name) {
  86. this.class_name = class_name;
  87. }
  88. public void unsetClass_name() {
  89. this.class_name = null;
  90. }
  91. // Returns true if field class_name is set (has been asigned a value) and false otherwise
  92. public boolean isSetClass_name() {
  93. return this.class_name != null;
  94. }
  95. public void setClass_nameIsSet(boolean value) {
  96. if (!value) {
  97. this.class_name = null;
  98. }
  99. }
  100. public void setFieldValue(int fieldID, Object value) {
  101. switch (fieldID) {
  102. case NAME:
  103. if (value == null) {
  104. unsetName();
  105. } else {
  106. setName((String)value);
  107. }
  108. break;
  109. case CLASS_NAME:
  110. if (value == null) {
  111. unsetClass_name();
  112. } else {
  113. setClass_name((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 NAME:
  123. return getName();
  124. case CLASS_NAME:
  125. return getClass_name();
  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 NAME:
  134. return isSetName();
  135. case CLASS_NAME:
  136. return isSetClass_name();
  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 Function)
  146. return this.equals((Function)that);
  147. return false;
  148. }
  149. public boolean equals(Function that) {
  150. if (that == null)
  151. return false;
  152. boolean this_present_name = true && this.isSetName();
  153. boolean that_present_name = true && that.isSetName();
  154. if (this_present_name || that_present_name) {
  155. if (!(this_present_name && that_present_name))
  156. return false;
  157. if (!this.name.equals(that.name))
  158. return false;
  159. }
  160. boolean this_present_class_name = true && this.isSetClass_name();
  161. boolean that_present_class_name = true && that.isSetClass_name();
  162. if (this_present_class_name || that_present_class_name) {
  163. if (!(this_present_class_name && that_present_class_name))
  164. return false;
  165. if (!this.class_name.equals(that.class_name))
  166. return false;
  167. }
  168. return true;
  169. }
  170. @Override
  171. public int hashCode() {
  172. HashCodeBuilder builder = new HashCodeBuilder();
  173. boolean present_name = true && (isSetName());
  174. builder.append(present_name);
  175. if (present_name)
  176. builder.append(name);
  177. boolean present_class_name = true && (isSetClass_name());
  178. builder.append(present_class_name);
  179. if (present_class_name)
  180. builder.append(class_name);
  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 NAME:
  195. if (field.type == TType.STRING) {
  196. this.name = iprot.readString();
  197. } else {
  198. TProtocolUtil.skip(iprot, field.type);
  199. }
  200. break;
  201. case CLASS_NAME:
  202. if (field.type == TType.STRING) {
  203. this.class_name = 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.name != null) {
  222. oprot.writeFieldBegin(NAME_FIELD_DESC);
  223. oprot.writeString(this.name);
  224. oprot.writeFieldEnd();
  225. }
  226. if (this.class_name != null) {
  227. oprot.writeFieldBegin(CLASS_NAME_FIELD_DESC);
  228. oprot.writeString(this.class_name);
  229. oprot.writeFieldEnd();
  230. }
  231. oprot.writeFieldStop();
  232. oprot.writeStructEnd();
  233. }
  234. @Override
  235. public String toString() {
  236. StringBuilder sb = new StringBuilder("Function(");
  237. boolean first = true;
  238. sb.append("name:");
  239. if (this.name == null) {
  240. sb.append("null");
  241. } else {
  242. sb.append(this.name);
  243. }
  244. first = false;
  245. if (!first) sb.append(", ");
  246. sb.append("class_name:");
  247. if (this.class_name == null) {
  248. sb.append("null");
  249. } else {
  250. sb.append(this.class_name);
  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. }