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.tabletserver.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 IteratorConfig implements org.apache.thrift.TBase<IteratorConfig, IteratorConfig._Fields>, java.io.Serializable, Cloneable {
50    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("IteratorConfig");
51  
52    private static final org.apache.thrift.protocol.TField ITERATORS_FIELD_DESC = new org.apache.thrift.protocol.TField("iterators", org.apache.thrift.protocol.TType.LIST, (short)1);
53  
54    private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
55    static {
56      schemes.put(StandardScheme.class, new IteratorConfigStandardSchemeFactory());
57      schemes.put(TupleScheme.class, new IteratorConfigTupleSchemeFactory());
58    }
59  
60    public List<TIteratorSetting> iterators; // required
61  
62    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
63    @SuppressWarnings("all") public enum _Fields implements org.apache.thrift.TFieldIdEnum {
64      ITERATORS((short)1, "iterators");
65  
66      private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
67  
68      static {
69        for (_Fields field : EnumSet.allOf(_Fields.class)) {
70          byName.put(field.getFieldName(), field);
71        }
72      }
73  
74      /**
75       * Find the _Fields constant that matches fieldId, or null if its not found.
76       */
77      public static _Fields findByThriftId(int fieldId) {
78        switch(fieldId) {
79          case 1: // ITERATORS
80            return ITERATORS;
81          default:
82            return null;
83        }
84      }
85  
86      /**
87       * Find the _Fields constant that matches fieldId, throwing an exception
88       * if it is not found.
89       */
90      public static _Fields findByThriftIdOrThrow(int fieldId) {
91        _Fields fields = findByThriftId(fieldId);
92        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
93        return fields;
94      }
95  
96      /**
97       * Find the _Fields constant that matches name, or null if its not found.
98       */
99      public static _Fields findByName(String name) {
100       return byName.get(name);
101     }
102 
103     private final short _thriftId;
104     private final String _fieldName;
105 
106     _Fields(short thriftId, String fieldName) {
107       _thriftId = thriftId;
108       _fieldName = fieldName;
109     }
110 
111     public short getThriftFieldId() {
112       return _thriftId;
113     }
114 
115     public String getFieldName() {
116       return _fieldName;
117     }
118   }
119 
120   // isset id assignments
121   public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
122   static {
123     Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
124     tmpMap.put(_Fields.ITERATORS, new org.apache.thrift.meta_data.FieldMetaData("iterators", org.apache.thrift.TFieldRequirementType.DEFAULT, 
125         new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, 
126             new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TIteratorSetting.class))));
127     metaDataMap = Collections.unmodifiableMap(tmpMap);
128     org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(IteratorConfig.class, metaDataMap);
129   }
130 
131   public IteratorConfig() {
132   }
133 
134   public IteratorConfig(
135     List<TIteratorSetting> iterators)
136   {
137     this();
138     this.iterators = iterators;
139   }
140 
141   /**
142    * Performs a deep copy on <i>other</i>.
143    */
144   public IteratorConfig(IteratorConfig other) {
145     if (other.isSetIterators()) {
146       List<TIteratorSetting> __this__iterators = new ArrayList<TIteratorSetting>();
147       for (TIteratorSetting other_element : other.iterators) {
148         __this__iterators.add(new TIteratorSetting(other_element));
149       }
150       this.iterators = __this__iterators;
151     }
152   }
153 
154   public IteratorConfig deepCopy() {
155     return new IteratorConfig(this);
156   }
157 
158   @Override
159   public void clear() {
160     this.iterators = null;
161   }
162 
163   public int getIteratorsSize() {
164     return (this.iterators == null) ? 0 : this.iterators.size();
165   }
166 
167   public java.util.Iterator<TIteratorSetting> getIteratorsIterator() {
168     return (this.iterators == null) ? null : this.iterators.iterator();
169   }
170 
171   public void addToIterators(TIteratorSetting elem) {
172     if (this.iterators == null) {
173       this.iterators = new ArrayList<TIteratorSetting>();
174     }
175     this.iterators.add(elem);
176   }
177 
178   public List<TIteratorSetting> getIterators() {
179     return this.iterators;
180   }
181 
182   public IteratorConfig setIterators(List<TIteratorSetting> iterators) {
183     this.iterators = iterators;
184     return this;
185   }
186 
187   public void unsetIterators() {
188     this.iterators = null;
189   }
190 
191   /** Returns true if field iterators is set (has been assigned a value) and false otherwise */
192   public boolean isSetIterators() {
193     return this.iterators != null;
194   }
195 
196   public void setIteratorsIsSet(boolean value) {
197     if (!value) {
198       this.iterators = null;
199     }
200   }
201 
202   public void setFieldValue(_Fields field, Object value) {
203     switch (field) {
204     case ITERATORS:
205       if (value == null) {
206         unsetIterators();
207       } else {
208         setIterators((List<TIteratorSetting>)value);
209       }
210       break;
211 
212     }
213   }
214 
215   public Object getFieldValue(_Fields field) {
216     switch (field) {
217     case ITERATORS:
218       return getIterators();
219 
220     }
221     throw new IllegalStateException();
222   }
223 
224   /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
225   public boolean isSet(_Fields field) {
226     if (field == null) {
227       throw new IllegalArgumentException();
228     }
229 
230     switch (field) {
231     case ITERATORS:
232       return isSetIterators();
233     }
234     throw new IllegalStateException();
235   }
236 
237   @Override
238   public boolean equals(Object that) {
239     if (that == null)
240       return false;
241     if (that instanceof IteratorConfig)
242       return this.equals((IteratorConfig)that);
243     return false;
244   }
245 
246   public boolean equals(IteratorConfig that) {
247     if (that == null)
248       return false;
249 
250     boolean this_present_iterators = true && this.isSetIterators();
251     boolean that_present_iterators = true && that.isSetIterators();
252     if (this_present_iterators || that_present_iterators) {
253       if (!(this_present_iterators && that_present_iterators))
254         return false;
255       if (!this.iterators.equals(that.iterators))
256         return false;
257     }
258 
259     return true;
260   }
261 
262   @Override
263   public int hashCode() {
264     return 0;
265   }
266 
267   public int compareTo(IteratorConfig other) {
268     if (!getClass().equals(other.getClass())) {
269       return getClass().getName().compareTo(other.getClass().getName());
270     }
271 
272     int lastComparison = 0;
273     IteratorConfig typedOther = (IteratorConfig)other;
274 
275     lastComparison = Boolean.valueOf(isSetIterators()).compareTo(typedOther.isSetIterators());
276     if (lastComparison != 0) {
277       return lastComparison;
278     }
279     if (isSetIterators()) {
280       lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.iterators, typedOther.iterators);
281       if (lastComparison != 0) {
282         return lastComparison;
283       }
284     }
285     return 0;
286   }
287 
288   public _Fields fieldForId(int fieldId) {
289     return _Fields.findByThriftId(fieldId);
290   }
291 
292   public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
293     schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
294   }
295 
296   public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
297     schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
298   }
299 
300   @Override
301   public String toString() {
302     StringBuilder sb = new StringBuilder("IteratorConfig(");
303     boolean first = true;
304 
305     sb.append("iterators:");
306     if (this.iterators == null) {
307       sb.append("null");
308     } else {
309       sb.append(this.iterators);
310     }
311     first = false;
312     sb.append(")");
313     return sb.toString();
314   }
315 
316   public void validate() throws org.apache.thrift.TException {
317     // check for required fields
318     // check for sub-struct validity
319   }
320 
321   private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
322     try {
323       write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
324     } catch (org.apache.thrift.TException te) {
325       throw new java.io.IOException(te);
326     }
327   }
328 
329   private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
330     try {
331       read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
332     } catch (org.apache.thrift.TException te) {
333       throw new java.io.IOException(te);
334     }
335   }
336 
337   private static class IteratorConfigStandardSchemeFactory implements SchemeFactory {
338     public IteratorConfigStandardScheme getScheme() {
339       return new IteratorConfigStandardScheme();
340     }
341   }
342 
343   private static class IteratorConfigStandardScheme extends StandardScheme<IteratorConfig> {
344 
345     public void read(org.apache.thrift.protocol.TProtocol iprot, IteratorConfig struct) throws org.apache.thrift.TException {
346       org.apache.thrift.protocol.TField schemeField;
347       iprot.readStructBegin();
348       while (true)
349       {
350         schemeField = iprot.readFieldBegin();
351         if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
352           break;
353         }
354         switch (schemeField.id) {
355           case 1: // ITERATORS
356             if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
357               {
358                 org.apache.thrift.protocol.TList _list98 = iprot.readListBegin();
359                 struct.iterators = new ArrayList<TIteratorSetting>(_list98.size);
360                 for (int _i99 = 0; _i99 < _list98.size; ++_i99)
361                 {
362                   TIteratorSetting _elem100; // required
363                   _elem100 = new TIteratorSetting();
364                   _elem100.read(iprot);
365                   struct.iterators.add(_elem100);
366                 }
367                 iprot.readListEnd();
368               }
369               struct.setIteratorsIsSet(true);
370             } else { 
371               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
372             }
373             break;
374           default:
375             org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
376         }
377         iprot.readFieldEnd();
378       }
379       iprot.readStructEnd();
380 
381       // check for required fields of primitive type, which can't be checked in the validate method
382       struct.validate();
383     }
384 
385     public void write(org.apache.thrift.protocol.TProtocol oprot, IteratorConfig struct) throws org.apache.thrift.TException {
386       struct.validate();
387 
388       oprot.writeStructBegin(STRUCT_DESC);
389       if (struct.iterators != null) {
390         oprot.writeFieldBegin(ITERATORS_FIELD_DESC);
391         {
392           oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.iterators.size()));
393           for (TIteratorSetting _iter101 : struct.iterators)
394           {
395             _iter101.write(oprot);
396           }
397           oprot.writeListEnd();
398         }
399         oprot.writeFieldEnd();
400       }
401       oprot.writeFieldStop();
402       oprot.writeStructEnd();
403     }
404 
405   }
406 
407   private static class IteratorConfigTupleSchemeFactory implements SchemeFactory {
408     public IteratorConfigTupleScheme getScheme() {
409       return new IteratorConfigTupleScheme();
410     }
411   }
412 
413   private static class IteratorConfigTupleScheme extends TupleScheme<IteratorConfig> {
414 
415     @Override
416     public void write(org.apache.thrift.protocol.TProtocol prot, IteratorConfig struct) throws org.apache.thrift.TException {
417       TTupleProtocol oprot = (TTupleProtocol) prot;
418       BitSet optionals = new BitSet();
419       if (struct.isSetIterators()) {
420         optionals.set(0);
421       }
422       oprot.writeBitSet(optionals, 1);
423       if (struct.isSetIterators()) {
424         {
425           oprot.writeI32(struct.iterators.size());
426           for (TIteratorSetting _iter102 : struct.iterators)
427           {
428             _iter102.write(oprot);
429           }
430         }
431       }
432     }
433 
434     @Override
435     public void read(org.apache.thrift.protocol.TProtocol prot, IteratorConfig struct) throws org.apache.thrift.TException {
436       TTupleProtocol iprot = (TTupleProtocol) prot;
437       BitSet incoming = iprot.readBitSet(1);
438       if (incoming.get(0)) {
439         {
440           org.apache.thrift.protocol.TList _list103 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
441           struct.iterators = new ArrayList<TIteratorSetting>(_list103.size);
442           for (int _i104 = 0; _i104 < _list103.size; ++_i104)
443           {
444             TIteratorSetting _elem105; // required
445             _elem105 = new TIteratorSetting();
446             _elem105.read(iprot);
447             struct.iterators.add(_elem105);
448           }
449         }
450         struct.setIteratorsIsSet(true);
451       }
452     }
453   }
454 
455 }
456