View Javadoc

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