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 ConstraintViolationException extends TException implements org.apache.thrift.TBase<ConstraintViolationException, ConstraintViolationException._Fields>, java.io.Serializable, Cloneable {
50    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ConstraintViolationException");
51  
52    private static final org.apache.thrift.protocol.TField VIOLATION_SUMMARIES_FIELD_DESC = new org.apache.thrift.protocol.TField("violationSummaries", 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 ConstraintViolationExceptionStandardSchemeFactory());
57      schemes.put(TupleScheme.class, new ConstraintViolationExceptionTupleSchemeFactory());
58    }
59  
60    public List<org.apache.accumulo.core.data.thrift.TConstraintViolationSummary> violationSummaries; // 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      VIOLATION_SUMMARIES((short)1, "violationSummaries");
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: // VIOLATION_SUMMARIES
80            return VIOLATION_SUMMARIES;
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.VIOLATION_SUMMARIES, new org.apache.thrift.meta_data.FieldMetaData("violationSummaries", 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, org.apache.accumulo.core.data.thrift.TConstraintViolationSummary.class))));
127     metaDataMap = Collections.unmodifiableMap(tmpMap);
128     org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(ConstraintViolationException.class, metaDataMap);
129   }
130 
131   public ConstraintViolationException() {
132   }
133 
134   public ConstraintViolationException(
135     List<org.apache.accumulo.core.data.thrift.TConstraintViolationSummary> violationSummaries)
136   {
137     this();
138     this.violationSummaries = violationSummaries;
139   }
140 
141   /**
142    * Performs a deep copy on <i>other</i>.
143    */
144   public ConstraintViolationException(ConstraintViolationException other) {
145     if (other.isSetViolationSummaries()) {
146       List<org.apache.accumulo.core.data.thrift.TConstraintViolationSummary> __this__violationSummaries = new ArrayList<org.apache.accumulo.core.data.thrift.TConstraintViolationSummary>();
147       for (org.apache.accumulo.core.data.thrift.TConstraintViolationSummary other_element : other.violationSummaries) {
148         __this__violationSummaries.add(new org.apache.accumulo.core.data.thrift.TConstraintViolationSummary(other_element));
149       }
150       this.violationSummaries = __this__violationSummaries;
151     }
152   }
153 
154   public ConstraintViolationException deepCopy() {
155     return new ConstraintViolationException(this);
156   }
157 
158   @Override
159   public void clear() {
160     this.violationSummaries = null;
161   }
162 
163   public int getViolationSummariesSize() {
164     return (this.violationSummaries == null) ? 0 : this.violationSummaries.size();
165   }
166 
167   public java.util.Iterator<org.apache.accumulo.core.data.thrift.TConstraintViolationSummary> getViolationSummariesIterator() {
168     return (this.violationSummaries == null) ? null : this.violationSummaries.iterator();
169   }
170 
171   public void addToViolationSummaries(org.apache.accumulo.core.data.thrift.TConstraintViolationSummary elem) {
172     if (this.violationSummaries == null) {
173       this.violationSummaries = new ArrayList<org.apache.accumulo.core.data.thrift.TConstraintViolationSummary>();
174     }
175     this.violationSummaries.add(elem);
176   }
177 
178   public List<org.apache.accumulo.core.data.thrift.TConstraintViolationSummary> getViolationSummaries() {
179     return this.violationSummaries;
180   }
181 
182   public ConstraintViolationException setViolationSummaries(List<org.apache.accumulo.core.data.thrift.TConstraintViolationSummary> violationSummaries) {
183     this.violationSummaries = violationSummaries;
184     return this;
185   }
186 
187   public void unsetViolationSummaries() {
188     this.violationSummaries = null;
189   }
190 
191   /** Returns true if field violationSummaries is set (has been assigned a value) and false otherwise */
192   public boolean isSetViolationSummaries() {
193     return this.violationSummaries != null;
194   }
195 
196   public void setViolationSummariesIsSet(boolean value) {
197     if (!value) {
198       this.violationSummaries = null;
199     }
200   }
201 
202   public void setFieldValue(_Fields field, Object value) {
203     switch (field) {
204     case VIOLATION_SUMMARIES:
205       if (value == null) {
206         unsetViolationSummaries();
207       } else {
208         setViolationSummaries((List<org.apache.accumulo.core.data.thrift.TConstraintViolationSummary>)value);
209       }
210       break;
211 
212     }
213   }
214 
215   public Object getFieldValue(_Fields field) {
216     switch (field) {
217     case VIOLATION_SUMMARIES:
218       return getViolationSummaries();
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 VIOLATION_SUMMARIES:
232       return isSetViolationSummaries();
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 ConstraintViolationException)
242       return this.equals((ConstraintViolationException)that);
243     return false;
244   }
245 
246   public boolean equals(ConstraintViolationException that) {
247     if (that == null)
248       return false;
249 
250     boolean this_present_violationSummaries = true && this.isSetViolationSummaries();
251     boolean that_present_violationSummaries = true && that.isSetViolationSummaries();
252     if (this_present_violationSummaries || that_present_violationSummaries) {
253       if (!(this_present_violationSummaries && that_present_violationSummaries))
254         return false;
255       if (!this.violationSummaries.equals(that.violationSummaries))
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(ConstraintViolationException other) {
268     if (!getClass().equals(other.getClass())) {
269       return getClass().getName().compareTo(other.getClass().getName());
270     }
271 
272     int lastComparison = 0;
273     ConstraintViolationException typedOther = (ConstraintViolationException)other;
274 
275     lastComparison = Boolean.valueOf(isSetViolationSummaries()).compareTo(typedOther.isSetViolationSummaries());
276     if (lastComparison != 0) {
277       return lastComparison;
278     }
279     if (isSetViolationSummaries()) {
280       lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.violationSummaries, typedOther.violationSummaries);
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("ConstraintViolationException(");
303     boolean first = true;
304 
305     sb.append("violationSummaries:");
306     if (this.violationSummaries == null) {
307       sb.append("null");
308     } else {
309       sb.append(this.violationSummaries);
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 ConstraintViolationExceptionStandardSchemeFactory implements SchemeFactory {
338     public ConstraintViolationExceptionStandardScheme getScheme() {
339       return new ConstraintViolationExceptionStandardScheme();
340     }
341   }
342 
343   private static class ConstraintViolationExceptionStandardScheme extends StandardScheme<ConstraintViolationException> {
344 
345     public void read(org.apache.thrift.protocol.TProtocol iprot, ConstraintViolationException 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: // VIOLATION_SUMMARIES
356             if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
357               {
358                 org.apache.thrift.protocol.TList _list0 = iprot.readListBegin();
359                 struct.violationSummaries = new ArrayList<org.apache.accumulo.core.data.thrift.TConstraintViolationSummary>(_list0.size);
360                 for (int _i1 = 0; _i1 < _list0.size; ++_i1)
361                 {
362                   org.apache.accumulo.core.data.thrift.TConstraintViolationSummary _elem2; // required
363                   _elem2 = new org.apache.accumulo.core.data.thrift.TConstraintViolationSummary();
364                   _elem2.read(iprot);
365                   struct.violationSummaries.add(_elem2);
366                 }
367                 iprot.readListEnd();
368               }
369               struct.setViolationSummariesIsSet(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, ConstraintViolationException struct) throws org.apache.thrift.TException {
386       struct.validate();
387 
388       oprot.writeStructBegin(STRUCT_DESC);
389       if (struct.violationSummaries != null) {
390         oprot.writeFieldBegin(VIOLATION_SUMMARIES_FIELD_DESC);
391         {
392           oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.violationSummaries.size()));
393           for (org.apache.accumulo.core.data.thrift.TConstraintViolationSummary _iter3 : struct.violationSummaries)
394           {
395             _iter3.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 ConstraintViolationExceptionTupleSchemeFactory implements SchemeFactory {
408     public ConstraintViolationExceptionTupleScheme getScheme() {
409       return new ConstraintViolationExceptionTupleScheme();
410     }
411   }
412 
413   private static class ConstraintViolationExceptionTupleScheme extends TupleScheme<ConstraintViolationException> {
414 
415     @Override
416     public void write(org.apache.thrift.protocol.TProtocol prot, ConstraintViolationException struct) throws org.apache.thrift.TException {
417       TTupleProtocol oprot = (TTupleProtocol) prot;
418       BitSet optionals = new BitSet();
419       if (struct.isSetViolationSummaries()) {
420         optionals.set(0);
421       }
422       oprot.writeBitSet(optionals, 1);
423       if (struct.isSetViolationSummaries()) {
424         {
425           oprot.writeI32(struct.violationSummaries.size());
426           for (org.apache.accumulo.core.data.thrift.TConstraintViolationSummary _iter4 : struct.violationSummaries)
427           {
428             _iter4.write(oprot);
429           }
430         }
431       }
432     }
433 
434     @Override
435     public void read(org.apache.thrift.protocol.TProtocol prot, ConstraintViolationException 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 _list5 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
441           struct.violationSummaries = new ArrayList<org.apache.accumulo.core.data.thrift.TConstraintViolationSummary>(_list5.size);
442           for (int _i6 = 0; _i6 < _list5.size; ++_i6)
443           {
444             org.apache.accumulo.core.data.thrift.TConstraintViolationSummary _elem7; // required
445             _elem7 = new org.apache.accumulo.core.data.thrift.TConstraintViolationSummary();
446             _elem7.read(iprot);
447             struct.violationSummaries.add(_elem7);
448           }
449         }
450         struct.setViolationSummariesIsSet(true);
451       }
452     }
453   }
454 
455 }
456