View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  /**
18   * Autogenerated by Thrift Compiler (0.9.0)
19   *
20   * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
21   *  @generated
22   */
23  package org.apache.accumulo.core.data.thrift;
24  
25  import org.apache.thrift.scheme.IScheme;
26  import org.apache.thrift.scheme.SchemeFactory;
27  import org.apache.thrift.scheme.StandardScheme;
28  
29  import org.apache.thrift.scheme.TupleScheme;
30  import org.apache.thrift.protocol.TTupleProtocol;
31  import org.apache.thrift.protocol.TProtocolException;
32  import org.apache.thrift.EncodingUtils;
33  import org.apache.thrift.TException;
34  import java.util.List;
35  import java.util.ArrayList;
36  import java.util.Map;
37  import java.util.HashMap;
38  import java.util.EnumMap;
39  import java.util.Set;
40  import java.util.HashSet;
41  import java.util.EnumSet;
42  import java.util.Collections;
43  import java.util.BitSet;
44  import java.nio.ByteBuffer;
45  import java.util.Arrays;
46  import org.slf4j.Logger;
47  import org.slf4j.LoggerFactory;
48  
49  @SuppressWarnings("all") public class IterInfo implements org.apache.thrift.TBase<IterInfo, IterInfo._Fields>, java.io.Serializable, Cloneable {
50    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("IterInfo");
51  
52    private static final org.apache.thrift.protocol.TField PRIORITY_FIELD_DESC = new org.apache.thrift.protocol.TField("priority", org.apache.thrift.protocol.TType.I32, (short)1);
53    private static final org.apache.thrift.protocol.TField CLASS_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("className", org.apache.thrift.protocol.TType.STRING, (short)2);
54    private static final org.apache.thrift.protocol.TField ITER_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("iterName", org.apache.thrift.protocol.TType.STRING, (short)3);
55  
56    private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
57    static {
58      schemes.put(StandardScheme.class, new IterInfoStandardSchemeFactory());
59      schemes.put(TupleScheme.class, new IterInfoTupleSchemeFactory());
60    }
61  
62    public int priority; // required
63    public String className; // required
64    public String iterName; // required
65  
66    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
67    @SuppressWarnings("all") public enum _Fields implements org.apache.thrift.TFieldIdEnum {
68      PRIORITY((short)1, "priority"),
69      CLASS_NAME((short)2, "className"),
70      ITER_NAME((short)3, "iterName");
71  
72      private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
73  
74      static {
75        for (_Fields field : EnumSet.allOf(_Fields.class)) {
76          byName.put(field.getFieldName(), field);
77        }
78      }
79  
80      /**
81       * Find the _Fields constant that matches fieldId, or null if its not found.
82       */
83      public static _Fields findByThriftId(int fieldId) {
84        switch(fieldId) {
85          case 1: // PRIORITY
86            return PRIORITY;
87          case 2: // CLASS_NAME
88            return CLASS_NAME;
89          case 3: // ITER_NAME
90            return ITER_NAME;
91          default:
92            return null;
93        }
94      }
95  
96      /**
97       * Find the _Fields constant that matches fieldId, throwing an exception
98       * if it is not found.
99       */
100     public static _Fields findByThriftIdOrThrow(int fieldId) {
101       _Fields fields = findByThriftId(fieldId);
102       if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
103       return fields;
104     }
105 
106     /**
107      * Find the _Fields constant that matches name, or null if its not found.
108      */
109     public static _Fields findByName(String name) {
110       return byName.get(name);
111     }
112 
113     private final short _thriftId;
114     private final String _fieldName;
115 
116     _Fields(short thriftId, String fieldName) {
117       _thriftId = thriftId;
118       _fieldName = fieldName;
119     }
120 
121     public short getThriftFieldId() {
122       return _thriftId;
123     }
124 
125     public String getFieldName() {
126       return _fieldName;
127     }
128   }
129 
130   // isset id assignments
131   private static final int __PRIORITY_ISSET_ID = 0;
132   private byte __isset_bitfield = 0;
133   public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
134   static {
135     Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
136     tmpMap.put(_Fields.PRIORITY, new org.apache.thrift.meta_data.FieldMetaData("priority", org.apache.thrift.TFieldRequirementType.DEFAULT, 
137         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
138     tmpMap.put(_Fields.CLASS_NAME, new org.apache.thrift.meta_data.FieldMetaData("className", org.apache.thrift.TFieldRequirementType.DEFAULT, 
139         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
140     tmpMap.put(_Fields.ITER_NAME, new org.apache.thrift.meta_data.FieldMetaData("iterName", org.apache.thrift.TFieldRequirementType.DEFAULT, 
141         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
142     metaDataMap = Collections.unmodifiableMap(tmpMap);
143     org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(IterInfo.class, metaDataMap);
144   }
145 
146   public IterInfo() {
147   }
148 
149   public IterInfo(
150     int priority,
151     String className,
152     String iterName)
153   {
154     this();
155     this.priority = priority;
156     setPriorityIsSet(true);
157     this.className = className;
158     this.iterName = iterName;
159   }
160 
161   /**
162    * Performs a deep copy on <i>other</i>.
163    */
164   public IterInfo(IterInfo other) {
165     __isset_bitfield = other.__isset_bitfield;
166     this.priority = other.priority;
167     if (other.isSetClassName()) {
168       this.className = other.className;
169     }
170     if (other.isSetIterName()) {
171       this.iterName = other.iterName;
172     }
173   }
174 
175   public IterInfo deepCopy() {
176     return new IterInfo(this);
177   }
178 
179   @Override
180   public void clear() {
181     setPriorityIsSet(false);
182     this.priority = 0;
183     this.className = null;
184     this.iterName = null;
185   }
186 
187   public int getPriority() {
188     return this.priority;
189   }
190 
191   public IterInfo setPriority(int priority) {
192     this.priority = priority;
193     setPriorityIsSet(true);
194     return this;
195   }
196 
197   public void unsetPriority() {
198     __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __PRIORITY_ISSET_ID);
199   }
200 
201   /** Returns true if field priority is set (has been assigned a value) and false otherwise */
202   public boolean isSetPriority() {
203     return EncodingUtils.testBit(__isset_bitfield, __PRIORITY_ISSET_ID);
204   }
205 
206   public void setPriorityIsSet(boolean value) {
207     __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __PRIORITY_ISSET_ID, value);
208   }
209 
210   public String getClassName() {
211     return this.className;
212   }
213 
214   public IterInfo setClassName(String className) {
215     this.className = className;
216     return this;
217   }
218 
219   public void unsetClassName() {
220     this.className = null;
221   }
222 
223   /** Returns true if field className is set (has been assigned a value) and false otherwise */
224   public boolean isSetClassName() {
225     return this.className != null;
226   }
227 
228   public void setClassNameIsSet(boolean value) {
229     if (!value) {
230       this.className = null;
231     }
232   }
233 
234   public String getIterName() {
235     return this.iterName;
236   }
237 
238   public IterInfo setIterName(String iterName) {
239     this.iterName = iterName;
240     return this;
241   }
242 
243   public void unsetIterName() {
244     this.iterName = null;
245   }
246 
247   /** Returns true if field iterName is set (has been assigned a value) and false otherwise */
248   public boolean isSetIterName() {
249     return this.iterName != null;
250   }
251 
252   public void setIterNameIsSet(boolean value) {
253     if (!value) {
254       this.iterName = null;
255     }
256   }
257 
258   public void setFieldValue(_Fields field, Object value) {
259     switch (field) {
260     case PRIORITY:
261       if (value == null) {
262         unsetPriority();
263       } else {
264         setPriority((Integer)value);
265       }
266       break;
267 
268     case CLASS_NAME:
269       if (value == null) {
270         unsetClassName();
271       } else {
272         setClassName((String)value);
273       }
274       break;
275 
276     case ITER_NAME:
277       if (value == null) {
278         unsetIterName();
279       } else {
280         setIterName((String)value);
281       }
282       break;
283 
284     }
285   }
286 
287   public Object getFieldValue(_Fields field) {
288     switch (field) {
289     case PRIORITY:
290       return Integer.valueOf(getPriority());
291 
292     case CLASS_NAME:
293       return getClassName();
294 
295     case ITER_NAME:
296       return getIterName();
297 
298     }
299     throw new IllegalStateException();
300   }
301 
302   /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
303   public boolean isSet(_Fields field) {
304     if (field == null) {
305       throw new IllegalArgumentException();
306     }
307 
308     switch (field) {
309     case PRIORITY:
310       return isSetPriority();
311     case CLASS_NAME:
312       return isSetClassName();
313     case ITER_NAME:
314       return isSetIterName();
315     }
316     throw new IllegalStateException();
317   }
318 
319   @Override
320   public boolean equals(Object that) {
321     if (that == null)
322       return false;
323     if (that instanceof IterInfo)
324       return this.equals((IterInfo)that);
325     return false;
326   }
327 
328   public boolean equals(IterInfo that) {
329     if (that == null)
330       return false;
331 
332     boolean this_present_priority = true;
333     boolean that_present_priority = true;
334     if (this_present_priority || that_present_priority) {
335       if (!(this_present_priority && that_present_priority))
336         return false;
337       if (this.priority != that.priority)
338         return false;
339     }
340 
341     boolean this_present_className = true && this.isSetClassName();
342     boolean that_present_className = true && that.isSetClassName();
343     if (this_present_className || that_present_className) {
344       if (!(this_present_className && that_present_className))
345         return false;
346       if (!this.className.equals(that.className))
347         return false;
348     }
349 
350     boolean this_present_iterName = true && this.isSetIterName();
351     boolean that_present_iterName = true && that.isSetIterName();
352     if (this_present_iterName || that_present_iterName) {
353       if (!(this_present_iterName && that_present_iterName))
354         return false;
355       if (!this.iterName.equals(that.iterName))
356         return false;
357     }
358 
359     return true;
360   }
361 
362   @Override
363   public int hashCode() {
364     return 0;
365   }
366 
367   public int compareTo(IterInfo other) {
368     if (!getClass().equals(other.getClass())) {
369       return getClass().getName().compareTo(other.getClass().getName());
370     }
371 
372     int lastComparison = 0;
373     IterInfo typedOther = (IterInfo)other;
374 
375     lastComparison = Boolean.valueOf(isSetPriority()).compareTo(typedOther.isSetPriority());
376     if (lastComparison != 0) {
377       return lastComparison;
378     }
379     if (isSetPriority()) {
380       lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.priority, typedOther.priority);
381       if (lastComparison != 0) {
382         return lastComparison;
383       }
384     }
385     lastComparison = Boolean.valueOf(isSetClassName()).compareTo(typedOther.isSetClassName());
386     if (lastComparison != 0) {
387       return lastComparison;
388     }
389     if (isSetClassName()) {
390       lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.className, typedOther.className);
391       if (lastComparison != 0) {
392         return lastComparison;
393       }
394     }
395     lastComparison = Boolean.valueOf(isSetIterName()).compareTo(typedOther.isSetIterName());
396     if (lastComparison != 0) {
397       return lastComparison;
398     }
399     if (isSetIterName()) {
400       lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.iterName, typedOther.iterName);
401       if (lastComparison != 0) {
402         return lastComparison;
403       }
404     }
405     return 0;
406   }
407 
408   public _Fields fieldForId(int fieldId) {
409     return _Fields.findByThriftId(fieldId);
410   }
411 
412   public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
413     schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
414   }
415 
416   public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
417     schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
418   }
419 
420   @Override
421   public String toString() {
422     StringBuilder sb = new StringBuilder("IterInfo(");
423     boolean first = true;
424 
425     sb.append("priority:");
426     sb.append(this.priority);
427     first = false;
428     if (!first) sb.append(", ");
429     sb.append("className:");
430     if (this.className == null) {
431       sb.append("null");
432     } else {
433       sb.append(this.className);
434     }
435     first = false;
436     if (!first) sb.append(", ");
437     sb.append("iterName:");
438     if (this.iterName == null) {
439       sb.append("null");
440     } else {
441       sb.append(this.iterName);
442     }
443     first = false;
444     sb.append(")");
445     return sb.toString();
446   }
447 
448   public void validate() throws org.apache.thrift.TException {
449     // check for required fields
450     // check for sub-struct validity
451   }
452 
453   private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
454     try {
455       write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
456     } catch (org.apache.thrift.TException te) {
457       throw new java.io.IOException(te);
458     }
459   }
460 
461   private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
462     try {
463       // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
464       __isset_bitfield = 0;
465       read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
466     } catch (org.apache.thrift.TException te) {
467       throw new java.io.IOException(te);
468     }
469   }
470 
471   private static class IterInfoStandardSchemeFactory implements SchemeFactory {
472     public IterInfoStandardScheme getScheme() {
473       return new IterInfoStandardScheme();
474     }
475   }
476 
477   private static class IterInfoStandardScheme extends StandardScheme<IterInfo> {
478 
479     public void read(org.apache.thrift.protocol.TProtocol iprot, IterInfo struct) throws org.apache.thrift.TException {
480       org.apache.thrift.protocol.TField schemeField;
481       iprot.readStructBegin();
482       while (true)
483       {
484         schemeField = iprot.readFieldBegin();
485         if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
486           break;
487         }
488         switch (schemeField.id) {
489           case 1: // PRIORITY
490             if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
491               struct.priority = iprot.readI32();
492               struct.setPriorityIsSet(true);
493             } else { 
494               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
495             }
496             break;
497           case 2: // CLASS_NAME
498             if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
499               struct.className = iprot.readString();
500               struct.setClassNameIsSet(true);
501             } else { 
502               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
503             }
504             break;
505           case 3: // ITER_NAME
506             if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
507               struct.iterName = iprot.readString();
508               struct.setIterNameIsSet(true);
509             } else { 
510               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
511             }
512             break;
513           default:
514             org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
515         }
516         iprot.readFieldEnd();
517       }
518       iprot.readStructEnd();
519 
520       // check for required fields of primitive type, which can't be checked in the validate method
521       struct.validate();
522     }
523 
524     public void write(org.apache.thrift.protocol.TProtocol oprot, IterInfo struct) throws org.apache.thrift.TException {
525       struct.validate();
526 
527       oprot.writeStructBegin(STRUCT_DESC);
528       oprot.writeFieldBegin(PRIORITY_FIELD_DESC);
529       oprot.writeI32(struct.priority);
530       oprot.writeFieldEnd();
531       if (struct.className != null) {
532         oprot.writeFieldBegin(CLASS_NAME_FIELD_DESC);
533         oprot.writeString(struct.className);
534         oprot.writeFieldEnd();
535       }
536       if (struct.iterName != null) {
537         oprot.writeFieldBegin(ITER_NAME_FIELD_DESC);
538         oprot.writeString(struct.iterName);
539         oprot.writeFieldEnd();
540       }
541       oprot.writeFieldStop();
542       oprot.writeStructEnd();
543     }
544 
545   }
546 
547   private static class IterInfoTupleSchemeFactory implements SchemeFactory {
548     public IterInfoTupleScheme getScheme() {
549       return new IterInfoTupleScheme();
550     }
551   }
552 
553   private static class IterInfoTupleScheme extends TupleScheme<IterInfo> {
554 
555     @Override
556     public void write(org.apache.thrift.protocol.TProtocol prot, IterInfo struct) throws org.apache.thrift.TException {
557       TTupleProtocol oprot = (TTupleProtocol) prot;
558       BitSet optionals = new BitSet();
559       if (struct.isSetPriority()) {
560         optionals.set(0);
561       }
562       if (struct.isSetClassName()) {
563         optionals.set(1);
564       }
565       if (struct.isSetIterName()) {
566         optionals.set(2);
567       }
568       oprot.writeBitSet(optionals, 3);
569       if (struct.isSetPriority()) {
570         oprot.writeI32(struct.priority);
571       }
572       if (struct.isSetClassName()) {
573         oprot.writeString(struct.className);
574       }
575       if (struct.isSetIterName()) {
576         oprot.writeString(struct.iterName);
577       }
578     }
579 
580     @Override
581     public void read(org.apache.thrift.protocol.TProtocol prot, IterInfo struct) throws org.apache.thrift.TException {
582       TTupleProtocol iprot = (TTupleProtocol) prot;
583       BitSet incoming = iprot.readBitSet(3);
584       if (incoming.get(0)) {
585         struct.priority = iprot.readI32();
586         struct.setPriorityIsSet(true);
587       }
588       if (incoming.get(1)) {
589         struct.className = iprot.readString();
590         struct.setClassNameIsSet(true);
591       }
592       if (incoming.get(2)) {
593         struct.iterName = iprot.readString();
594         struct.setIterNameIsSet(true);
595       }
596     }
597   }
598 
599 }
600