0001
0002
0003
0004
0005
0006
0007 package org.apache.hive.service.cli.thrift;
0008
0009 import org.apache.commons.lang.builder.HashCodeBuilder;
0010 import org.apache.thrift.scheme.IScheme;
0011 import org.apache.thrift.scheme.SchemeFactory;
0012 import org.apache.thrift.scheme.StandardScheme;
0013
0014 import org.apache.thrift.scheme.TupleScheme;
0015 import org.apache.thrift.protocol.TTupleProtocol;
0016 import org.apache.thrift.protocol.TProtocolException;
0017 import org.apache.thrift.EncodingUtils;
0018 import org.apache.thrift.TException;
0019 import java.util.List;
0020 import java.util.ArrayList;
0021 import java.util.Map;
0022 import java.util.HashMap;
0023 import java.util.EnumMap;
0024 import java.util.Set;
0025 import java.util.HashSet;
0026 import java.util.EnumSet;
0027 import java.util.Collections;
0028 import java.util.BitSet;
0029 import java.nio.ByteBuffer;
0030 import java.util.Arrays;
0031 import org.slf4j.Logger;
0032 import org.slf4j.LoggerFactory;
0033
0034 public class TUserDefinedTypeEntry implements org.apache.thrift.TBase<TUserDefinedTypeEntry, TUserDefinedTypeEntry._Fields>, java.io.Serializable, Cloneable {
0035 private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TUserDefinedTypeEntry");
0036
0037 private static final org.apache.thrift.protocol.TField TYPE_CLASS_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("typeClassName", org.apache.thrift.protocol.TType.STRING, (short)1);
0038
0039 private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
0040 static {
0041 schemes.put(StandardScheme.class, new TUserDefinedTypeEntryStandardSchemeFactory());
0042 schemes.put(TupleScheme.class, new TUserDefinedTypeEntryTupleSchemeFactory());
0043 }
0044
0045 private String typeClassName;
0046
0047
0048 public enum _Fields implements org.apache.thrift.TFieldIdEnum {
0049 TYPE_CLASS_NAME((short)1, "typeClassName");
0050
0051 private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
0052
0053 static {
0054 for (_Fields field : EnumSet.allOf(_Fields.class)) {
0055 byName.put(field.getFieldName(), field);
0056 }
0057 }
0058
0059
0060
0061
0062 public static _Fields findByThriftId(int fieldId) {
0063 switch(fieldId) {
0064 case 1:
0065 return TYPE_CLASS_NAME;
0066 default:
0067 return null;
0068 }
0069 }
0070
0071
0072
0073
0074
0075 public static _Fields findByThriftIdOrThrow(int fieldId) {
0076 _Fields fields = findByThriftId(fieldId);
0077 if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
0078 return fields;
0079 }
0080
0081
0082
0083
0084 public static _Fields findByName(String name) {
0085 return byName.get(name);
0086 }
0087
0088 private final short _thriftId;
0089 private final String _fieldName;
0090
0091 _Fields(short thriftId, String fieldName) {
0092 _thriftId = thriftId;
0093 _fieldName = fieldName;
0094 }
0095
0096 public short getThriftFieldId() {
0097 return _thriftId;
0098 }
0099
0100 public String getFieldName() {
0101 return _fieldName;
0102 }
0103 }
0104
0105
0106 public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
0107 static {
0108 Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
0109 tmpMap.put(_Fields.TYPE_CLASS_NAME, new org.apache.thrift.meta_data.FieldMetaData("typeClassName", org.apache.thrift.TFieldRequirementType.REQUIRED,
0110 new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
0111 metaDataMap = Collections.unmodifiableMap(tmpMap);
0112 org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TUserDefinedTypeEntry.class, metaDataMap);
0113 }
0114
0115 public TUserDefinedTypeEntry() {
0116 }
0117
0118 public TUserDefinedTypeEntry(
0119 String typeClassName)
0120 {
0121 this();
0122 this.typeClassName = typeClassName;
0123 }
0124
0125
0126
0127
0128 public TUserDefinedTypeEntry(TUserDefinedTypeEntry other) {
0129 if (other.isSetTypeClassName()) {
0130 this.typeClassName = other.typeClassName;
0131 }
0132 }
0133
0134 public TUserDefinedTypeEntry deepCopy() {
0135 return new TUserDefinedTypeEntry(this);
0136 }
0137
0138 @Override
0139 public void clear() {
0140 this.typeClassName = null;
0141 }
0142
0143 public String getTypeClassName() {
0144 return this.typeClassName;
0145 }
0146
0147 public void setTypeClassName(String typeClassName) {
0148 this.typeClassName = typeClassName;
0149 }
0150
0151 public void unsetTypeClassName() {
0152 this.typeClassName = null;
0153 }
0154
0155
0156 public boolean isSetTypeClassName() {
0157 return this.typeClassName != null;
0158 }
0159
0160 public void setTypeClassNameIsSet(boolean value) {
0161 if (!value) {
0162 this.typeClassName = null;
0163 }
0164 }
0165
0166 public void setFieldValue(_Fields field, Object value) {
0167 switch (field) {
0168 case TYPE_CLASS_NAME:
0169 if (value == null) {
0170 unsetTypeClassName();
0171 } else {
0172 setTypeClassName((String)value);
0173 }
0174 break;
0175
0176 }
0177 }
0178
0179 public Object getFieldValue(_Fields field) {
0180 switch (field) {
0181 case TYPE_CLASS_NAME:
0182 return getTypeClassName();
0183
0184 }
0185 throw new IllegalStateException();
0186 }
0187
0188
0189 public boolean isSet(_Fields field) {
0190 if (field == null) {
0191 throw new IllegalArgumentException();
0192 }
0193
0194 switch (field) {
0195 case TYPE_CLASS_NAME:
0196 return isSetTypeClassName();
0197 }
0198 throw new IllegalStateException();
0199 }
0200
0201 @Override
0202 public boolean equals(Object that) {
0203 if (that == null)
0204 return false;
0205 if (that instanceof TUserDefinedTypeEntry)
0206 return this.equals((TUserDefinedTypeEntry)that);
0207 return false;
0208 }
0209
0210 public boolean equals(TUserDefinedTypeEntry that) {
0211 if (that == null)
0212 return false;
0213
0214 boolean this_present_typeClassName = true && this.isSetTypeClassName();
0215 boolean that_present_typeClassName = true && that.isSetTypeClassName();
0216 if (this_present_typeClassName || that_present_typeClassName) {
0217 if (!(this_present_typeClassName && that_present_typeClassName))
0218 return false;
0219 if (!this.typeClassName.equals(that.typeClassName))
0220 return false;
0221 }
0222
0223 return true;
0224 }
0225
0226 @Override
0227 public int hashCode() {
0228 HashCodeBuilder builder = new HashCodeBuilder();
0229
0230 boolean present_typeClassName = true && (isSetTypeClassName());
0231 builder.append(present_typeClassName);
0232 if (present_typeClassName)
0233 builder.append(typeClassName);
0234
0235 return builder.toHashCode();
0236 }
0237
0238 public int compareTo(TUserDefinedTypeEntry other) {
0239 if (!getClass().equals(other.getClass())) {
0240 return getClass().getName().compareTo(other.getClass().getName());
0241 }
0242
0243 int lastComparison = 0;
0244 TUserDefinedTypeEntry typedOther = (TUserDefinedTypeEntry)other;
0245
0246 lastComparison = Boolean.valueOf(isSetTypeClassName()).compareTo(typedOther.isSetTypeClassName());
0247 if (lastComparison != 0) {
0248 return lastComparison;
0249 }
0250 if (isSetTypeClassName()) {
0251 lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.typeClassName, typedOther.typeClassName);
0252 if (lastComparison != 0) {
0253 return lastComparison;
0254 }
0255 }
0256 return 0;
0257 }
0258
0259 public _Fields fieldForId(int fieldId) {
0260 return _Fields.findByThriftId(fieldId);
0261 }
0262
0263 public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
0264 schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
0265 }
0266
0267 public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
0268 schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
0269 }
0270
0271 @Override
0272 public String toString() {
0273 StringBuilder sb = new StringBuilder("TUserDefinedTypeEntry(");
0274 boolean first = true;
0275
0276 sb.append("typeClassName:");
0277 if (this.typeClassName == null) {
0278 sb.append("null");
0279 } else {
0280 sb.append(this.typeClassName);
0281 }
0282 first = false;
0283 sb.append(")");
0284 return sb.toString();
0285 }
0286
0287 public void validate() throws org.apache.thrift.TException {
0288
0289 if (!isSetTypeClassName()) {
0290 throw new org.apache.thrift.protocol.TProtocolException("Required field 'typeClassName' is unset! Struct:" + toString());
0291 }
0292
0293
0294 }
0295
0296 private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
0297 try {
0298 write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
0299 } catch (org.apache.thrift.TException te) {
0300 throw new java.io.IOException(te);
0301 }
0302 }
0303
0304 private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
0305 try {
0306 read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
0307 } catch (org.apache.thrift.TException te) {
0308 throw new java.io.IOException(te);
0309 }
0310 }
0311
0312 private static class TUserDefinedTypeEntryStandardSchemeFactory implements SchemeFactory {
0313 public TUserDefinedTypeEntryStandardScheme getScheme() {
0314 return new TUserDefinedTypeEntryStandardScheme();
0315 }
0316 }
0317
0318 private static class TUserDefinedTypeEntryStandardScheme extends StandardScheme<TUserDefinedTypeEntry> {
0319
0320 public void read(org.apache.thrift.protocol.TProtocol iprot, TUserDefinedTypeEntry struct) throws org.apache.thrift.TException {
0321 org.apache.thrift.protocol.TField schemeField;
0322 iprot.readStructBegin();
0323 while (true)
0324 {
0325 schemeField = iprot.readFieldBegin();
0326 if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
0327 break;
0328 }
0329 switch (schemeField.id) {
0330 case 1:
0331 if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
0332 struct.typeClassName = iprot.readString();
0333 struct.setTypeClassNameIsSet(true);
0334 } else {
0335 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
0336 }
0337 break;
0338 default:
0339 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
0340 }
0341 iprot.readFieldEnd();
0342 }
0343 iprot.readStructEnd();
0344 struct.validate();
0345 }
0346
0347 public void write(org.apache.thrift.protocol.TProtocol oprot, TUserDefinedTypeEntry struct) throws org.apache.thrift.TException {
0348 struct.validate();
0349
0350 oprot.writeStructBegin(STRUCT_DESC);
0351 if (struct.typeClassName != null) {
0352 oprot.writeFieldBegin(TYPE_CLASS_NAME_FIELD_DESC);
0353 oprot.writeString(struct.typeClassName);
0354 oprot.writeFieldEnd();
0355 }
0356 oprot.writeFieldStop();
0357 oprot.writeStructEnd();
0358 }
0359
0360 }
0361
0362 private static class TUserDefinedTypeEntryTupleSchemeFactory implements SchemeFactory {
0363 public TUserDefinedTypeEntryTupleScheme getScheme() {
0364 return new TUserDefinedTypeEntryTupleScheme();
0365 }
0366 }
0367
0368 private static class TUserDefinedTypeEntryTupleScheme extends TupleScheme<TUserDefinedTypeEntry> {
0369
0370 @Override
0371 public void write(org.apache.thrift.protocol.TProtocol prot, TUserDefinedTypeEntry struct) throws org.apache.thrift.TException {
0372 TTupleProtocol oprot = (TTupleProtocol) prot;
0373 oprot.writeString(struct.typeClassName);
0374 }
0375
0376 @Override
0377 public void read(org.apache.thrift.protocol.TProtocol prot, TUserDefinedTypeEntry struct) throws org.apache.thrift.TException {
0378 TTupleProtocol iprot = (TTupleProtocol) prot;
0379 struct.typeClassName = iprot.readString();
0380 struct.setTypeClassNameIsSet(true);
0381 }
0382 }
0383
0384 }
0385