内容简介:这节咱们开始开发用户服务,上次通过python开发的信息服务已经开发完毕。源码:https://github.com/limingios/msA-docker用户服务使用java语言进行开发,对外通过thift的接口,依赖于下面的信息服务,后端有数据库,开发一个服务,首选需要设计对外的接口,都给别人提供什么样的服务。
这节咱们开始开发用户服务,上次通过 python 开发的信息服务已经开发完毕。源码:https://github.com/limingios/msA-docker
用户服务的分析
用户服务使用 java 语言进行开发,对外通过thift的接口,依赖于下面的信息服务,后端有数据库,开发一个服务,首选需要设计对外的接口,都给别人提供什么样的服务。
用户服务接口创建
- pom编辑
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <parent> <artifactId>ms-server</artifactId> <groupId>com.idig8</groupId> <version>1.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <groupId>com.idig8</groupId> <artifactId>user-thrift-service-api</artifactId> <version>1.0-SNAPSHOT</version> <dependencies> <dependency> <groupId>org.apache.thrift</groupId> <artifactId>libthrift</artifactId> <version>0.10.0</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </build> </project>
- 创建对应这个接口提供服务的thrift
namespace java com.idig8.thrift.user struct UserInfo{ 1:i32 id, 2:string username, 3:string password, 4:string realName, 5:string mobile, 6:string email } service UserService{ UserInfo getUserById(1:i32 id) UserInfo getUserByName(1:string username); void regiserUser(1:UserInfo userInfo); }
- 命令生成java对应的接口类
thrift --gen java -out ../src/main/java user-service.thrift
没有建立环境变量,直接在目录下生成的,然后拷贝到对应的目录下。
- 生成2个类,一个是实体类,一个对应的user-service( 这都是通过thrift自动生成的)
UserInfo.java
/** * Autogenerated by Thrift Compiler (0.11.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated */ package com.idig8.thrift.user; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) @javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2018-10-13") public class UserInfo implements org.apache.thrift.TBase<UserInfo, UserInfo._Fields>, java.io.Serializable, Cloneable, Comparable<UserInfo> { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("UserInfo"); private static final org.apache.thrift.protocol.TField ID_FIELD_DESC = new org.apache.thrift.protocol.TField("id", org.apache.thrift.protocol.TType.I32, (short)1); private static final org.apache.thrift.protocol.TField USERNAME_FIELD_DESC = new org.apache.thrift.protocol.TField("username", org.apache.thrift.protocol.TType.STRING, (short)2); private static final org.apache.thrift.protocol.TField PASSWORD_FIELD_DESC = new org.apache.thrift.protocol.TField("password", org.apache.thrift.protocol.TType.STRING, (short)3); private static final org.apache.thrift.protocol.TField REAL_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("realName", org.apache.thrift.protocol.TType.STRING, (short)4); private static final org.apache.thrift.protocol.TField MOBILE_FIELD_DESC = new org.apache.thrift.protocol.TField("mobile", org.apache.thrift.protocol.TType.STRING, (short)5); private static final org.apache.thrift.protocol.TField EMAIL_FIELD_DESC = new org.apache.thrift.protocol.TField("email", org.apache.thrift.protocol.TType.STRING, (short)6); private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new UserInfoStandardSchemeFactory(); private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new UserInfoTupleSchemeFactory(); public int id; // required public java.lang.String username; // required public java.lang.String password; // required public java.lang.String realName; // required public java.lang.String mobile; // required public java.lang.String email; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { ID((short)1, "id"), USERNAME((short)2, "username"), PASSWORD((short)3, "password"), REAL_NAME((short)4, "realName"), MOBILE((short)5, "mobile"), EMAIL((short)6, "email"); private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 1: // ID return ID; case 2: // USERNAME return USERNAME; case 3: // PASSWORD return PASSWORD; case 4: // REAL_NAME return REAL_NAME; case 5: // MOBILE return MOBILE; case 6: // EMAIL return EMAIL; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(java.lang.String name) { return byName.get(name); } private final short _thriftId; private final java.lang.String _fieldName; _Fields(short thriftId, java.lang.String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public java.lang.String getFieldName() { return _fieldName; } } // isset id assignments private static final int __ID_ISSET_ID = 0; private byte __isset_bitfield = 0; public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.ID, new org.apache.thrift.meta_data.FieldMetaData("id", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); tmpMap.put(_Fields.USERNAME, new org.apache.thrift.meta_data.FieldMetaData("username", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.PASSWORD, new org.apache.thrift.meta_data.FieldMetaData("password", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.REAL_NAME, new org.apache.thrift.meta_data.FieldMetaData("realName", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.MOBILE, new org.apache.thrift.meta_data.FieldMetaData("mobile", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); tmpMap.put(_Fields.EMAIL, new org.apache.thrift.meta_data.FieldMetaData("email", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(UserInfo.class, metaDataMap); } public UserInfo() { } public UserInfo( int id, java.lang.String username, java.lang.String password, java.lang.String realName, java.lang.String mobile, java.lang.String email) { this(); this.id = id; setIdIsSet(true); this.username = username; this.password = password; this.realName = realName; this.mobile = mobile; this.email = email; } /** * Performs a deep copy on <i>other</i>. */ public UserInfo(UserInfo other) { __isset_bitfield = other.__isset_bitfield; this.id = other.id; if (other.isSetUsername()) { this.username = other.username; } if (other.isSetPassword()) { this.password = other.password; } if (other.isSetRealName()) { this.realName = other.realName; } if (other.isSetMobile()) { this.mobile = other.mobile; } if (other.isSetEmail()) { this.email = other.email; } } public UserInfo deepCopy() { return new UserInfo(this); } @Override public void clear() { setIdIsSet(false); this.id = 0; this.username = null; this.password = null; this.realName = null; this.mobile = null; this.email = null; } public int getId() { return this.id; } public UserInfo setId(int id) { this.id = id; setIdIsSet(true); return this; } public void unsetId() { __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __ID_ISSET_ID); } /** Returns true if field id is set (has been assigned a value) and false otherwise */ public boolean isSetId() { return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __ID_ISSET_ID); } public void setIdIsSet(boolean value) { __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __ID_ISSET_ID, value); } public java.lang.String getUsername() { return this.username; } public UserInfo setUsername(java.lang.String username) { this.username = username; return this; } public void unsetUsername() { this.username = null; } /** Returns true if field username is set (has been assigned a value) and false otherwise */ public boolean isSetUsername() { return this.username != null; } public void setUsernameIsSet(boolean value) { if (!value) { this.username = null; } } public java.lang.String getPassword() { return this.password; } public UserInfo setPassword(java.lang.String password) { this.password = password; return this; } public void unsetPassword() { this.password = null; } /** Returns true if field password is set (has been assigned a value) and false otherwise */ public boolean isSetPassword() { return this.password != null; } public void setPasswordIsSet(boolean value) { if (!value) { this.password = null; } } public java.lang.String getRealName() { return this.realName; } public UserInfo setRealName(java.lang.String realName) { this.realName = realName; return this; } public void unsetRealName() { this.realName = null; } /** Returns true if field realName is set (has been assigned a value) and false otherwise */ public boolean isSetRealName() { return this.realName != null; } public void setRealNameIsSet(boolean value) { if (!value) { this.realName = null; } } public java.lang.String getMobile() { return this.mobile; } public UserInfo setMobile(java.lang.String mobile) { this.mobile = mobile; return this; } public void unsetMobile() { this.mobile = null; } /** Returns true if field mobile is set (has been assigned a value) and false otherwise */ public boolean isSetMobile() { return this.mobile != null; } public void setMobileIsSet(boolean value) { if (!value) { this.mobile = null; } } public java.lang.String getEmail() { return this.email; } public UserInfo setEmail(java.lang.String email) { this.email = email; return this; } public void unsetEmail() { this.email = null; } /** Returns true if field email is set (has been assigned a value) and false otherwise */ public boolean isSetEmail() { return this.email != null; } public void setEmailIsSet(boolean value) { if (!value) { this.email = null; } } public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case ID: if (value == null) { unsetId(); } else { setId((java.lang.Integer)value); } break; case USERNAME: if (value == null) { unsetUsername(); } else { setUsername((java.lang.String)value); } break; case PASSWORD: if (value == null) { unsetPassword(); } else { setPassword((java.lang.String)value); } break; case REAL_NAME: if (value == null) { unsetRealName(); } else { setRealName((java.lang.String)value); } break; case MOBILE: if (value == null) { unsetMobile(); } else { setMobile((java.lang.String)value); } break; case EMAIL: if (value == null) { unsetEmail(); } else { setEmail((java.lang.String)value); } break; } } public java.lang.Object getFieldValue(_Fields field) { switch (field) { case ID: return getId(); case USERNAME: return getUsername(); case PASSWORD: return getPassword(); case REAL_NAME: return getRealName(); case MOBILE: return getMobile(); case EMAIL: return getEmail(); } throw new java.lang.IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case ID: return isSetId(); case USERNAME: return isSetUsername(); case PASSWORD: return isSetPassword(); case REAL_NAME: return isSetRealName(); case MOBILE: return isSetMobile(); case EMAIL: return isSetEmail(); } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof UserInfo) return this.equals((UserInfo)that); return false; } public boolean equals(UserInfo that) { if (that == null) return false; if (this == that) return true; boolean this_present_id = true; boolean that_present_id = true; if (this_present_id || that_present_id) { if (!(this_present_id && that_present_id)) return false; if (this.id != that.id) return false; } boolean this_present_username = true && this.isSetUsername(); boolean that_present_username = true && that.isSetUsername(); if (this_present_username || that_present_username) { if (!(this_present_username && that_present_username)) return false; if (!this.username.equals(that.username)) return false; } boolean this_present_password = true && this.isSetPassword(); boolean that_present_password = true && that.isSetPassword(); if (this_present_password || that_present_password) { if (!(this_present_password && that_present_password)) return false; if (!this.password.equals(that.password)) return false; } boolean this_present_realName = true && this.isSetRealName(); boolean that_present_realName = true && that.isSetRealName(); if (this_present_realName || that_present_realName) { if (!(this_present_realName && that_present_realName)) return false; if (!this.realName.equals(that.realName)) return false; } boolean this_present_mobile = true && this.isSetMobile(); boolean that_present_mobile = true && that.isSetMobile(); if (this_present_mobile || that_present_mobile) { if (!(this_present_mobile && that_present_mobile)) return false; if (!this.mobile.equals(that.mobile)) return false; } boolean this_present_email = true && this.isSetEmail(); boolean that_present_email = true && that.isSetEmail(); if (this_present_email || that_present_email) { if (!(this_present_email && that_present_email)) return false; if (!this.email.equals(that.email)) return false; } return true; } @Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + id; hashCode = hashCode * 8191 + ((isSetUsername()) ? 131071 : 524287); if (isSetUsername()) hashCode = hashCode * 8191 + username.hashCode(); hashCode = hashCode * 8191 + ((isSetPassword()) ? 131071 : 524287); if (isSetPassword()) hashCode = hashCode * 8191 + password.hashCode(); hashCode = hashCode * 8191 + ((isSetRealName()) ? 131071 : 524287); if (isSetRealName()) hashCode = hashCode * 8191 + realName.hashCode(); hashCode = hashCode * 8191 + ((isSetMobile()) ? 131071 : 524287); if (isSetMobile()) hashCode = hashCode * 8191 + mobile.hashCode(); hashCode = hashCode * 8191 + ((isSetEmail()) ? 131071 : 524287); if (isSetEmail()) hashCode = hashCode * 8191 + email.hashCode(); return hashCode; } @Override public int compareTo(UserInfo other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = java.lang.Boolean.valueOf(isSetId()).compareTo(other.isSetId()); if (lastComparison != 0) { return lastComparison; } if (isSetId()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.id, other.id); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetUsername()).compareTo(other.isSetUsername()); if (lastComparison != 0) { return lastComparison; } if (isSetUsername()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.username, other.username); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetPassword()).compareTo(other.isSetPassword()); if (lastComparison != 0) { return lastComparison; } if (isSetPassword()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.password, other.password); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetRealName()).compareTo(other.isSetRealName()); if (lastComparison != 0) { return lastComparison; } if (isSetRealName()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.realName, other.realName); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetMobile()).compareTo(other.isSetMobile()); if (lastComparison != 0) { return lastComparison; } if (isSetMobile()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.mobile, other.mobile); if (lastComparison != 0) { return lastComparison; } } lastComparison = java.lang.Boolean.valueOf(isSetEmail()).compareTo(other.isSetEmail()); if (lastComparison != 0) { return lastComparison; } if (isSetEmail()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.email, other.email); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { scheme(iprot).read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { scheme(oprot).write(oprot, this); } @Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("UserInfo("); boolean first = true; sb.append("id:"); sb.append(this.id); first = false; if (!first) sb.append(", "); sb.append("username:"); if (this.username == null) { sb.append("null"); } else { sb.append(this.username); } first = false; if (!first) sb.append(", "); sb.append("password:"); if (this.password == null) { sb.append("null"); } else { sb.append(this.password); } first = false; if (!first) sb.append(", "); sb.append("realName:"); if (this.realName == null) { sb.append("null"); } else { sb.append(this.realName); } first = false; if (!first) sb.append(", "); sb.append("mobile:"); if (this.mobile == null) { sb.append("null"); } else { sb.append(this.mobile); } first = false; if (!first) sb.append(", "); sb.append("email:"); if (this.email == null) { sb.append("null"); } else { sb.append(this.email); } first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // check for sub-struct validity } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { try { // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. __isset_bitfield = 0; read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class UserInfoStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public UserInfoStandardScheme getScheme() { return new UserInfoStandardScheme(); } } private static class UserInfoStandardScheme extends org.apache.thrift.scheme.StandardScheme<UserInfo> { public void read(org.apache.thrift.protocol.TProtocol iprot, UserInfo struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 1: // ID if (schemeField.type == org.apache.thrift.protocol.TType.I32) { struct.id = iprot.readI32(); struct.setIdIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 2: // USERNAME if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.username = iprot.readString(); struct.setUsernameIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 3: // PASSWORD if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.password = iprot.readString(); struct.setPasswordIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 4: // REAL_NAME if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.realName = iprot.readString(); struct.setRealNameIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 5: // MOBILE if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.mobile = iprot.readString(); struct.setMobileIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 6: // EMAIL if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.email = iprot.readString(); struct.setEmailIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, UserInfo struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); oprot.writeFieldBegin(ID_FIELD_DESC); oprot.writeI32(struct.id); oprot.writeFieldEnd(); if (struct.username != null) { oprot.writeFieldBegin(USERNAME_FIELD_DESC); oprot.writeString(struct.username); oprot.writeFieldEnd(); } if (struct.password != null) { oprot.writeFieldBegin(PASSWORD_FIELD_DESC); oprot.writeString(struct.password); oprot.writeFieldEnd(); } if (struct.realName != null) { oprot.writeFieldBegin(REAL_NAME_FIELD_DESC); oprot.writeString(struct.realName); oprot.writeFieldEnd(); } if (struct.mobile != null) { oprot.writeFieldBegin(MOBILE_FIELD_DESC); oprot.writeString(struct.mobile); oprot.writeFieldEnd(); } if (struct.email != null) { oprot.writeFieldBegin(EMAIL_FIELD_DESC); oprot.writeString(struct.email); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class UserInfoTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public UserInfoTupleScheme getScheme() { return new UserInfoTupleScheme(); } } private static class UserInfoTupleScheme extends org.apache.thrift.scheme.TupleScheme<UserInfo> { @Override public void write(org.apache.thrift.protocol.TProtocol prot, UserInfo struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet optionals = new java.util.BitSet(); if (struct.isSetId()) { optionals.set(0); } if (struct.isSetUsername()) { optionals.set(1); } if (struct.isSetPassword()) { optionals.set(2); } if (struct.isSetRealName()) { optionals.set(3); } if (struct.isSetMobile()) { optionals.set(4); } if (struct.isSetEmail()) { optionals.set(5); } oprot.writeBitSet(optionals, 6); if (struct.isSetId()) { oprot.writeI32(struct.id); } if (struct.isSetUsername()) { oprot.writeString(struct.username); } if (struct.isSetPassword()) { oprot.writeString(struct.password); } if (struct.isSetRealName()) { oprot.writeString(struct.realName); } if (struct.isSetMobile()) { oprot.writeString(struct.mobile); } if (struct.isSetEmail()) { oprot.writeString(struct.email); } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, UserInfo struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet incoming = iprot.readBitSet(6); if (incoming.get(0)) { struct.id = iprot.readI32(); struct.setIdIsSet(true); } if (incoming.get(1)) { struct.username = iprot.readString(); struct.setUsernameIsSet(true); } if (incoming.get(2)) { struct.password = iprot.readString(); struct.setPasswordIsSet(true); } if (incoming.get(3)) { struct.realName = iprot.readString(); struct.setRealNameIsSet(true); } if (incoming.get(4)) { struct.mobile = iprot.readString(); struct.setMobileIsSet(true); } if (incoming.get(5)) { struct.email = iprot.readString(); struct.setEmailIsSet(true); } } } private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) { return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); } }
UserService
/** * Autogenerated by Thrift Compiler (0.11.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated */ package com.idig8.thrift.user; @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) @javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2018-10-13") public class UserService { public interface Iface { public UserInfo getUserById(int id) throws org.apache.thrift.TException; public UserInfo getUserByName(java.lang.String username) throws org.apache.thrift.TException; public void regiserUser(UserInfo userInfo) throws org.apache.thrift.TException; } public interface AsyncIface { public void getUserById(int id, org.apache.thrift.async.AsyncMethodCallback<UserInfo> resultHandler) throws org.apache.thrift.TException; public void getUserByName(java.lang.String username, org.apache.thrift.async.AsyncMethodCallback<UserInfo> resultHandler) throws org.apache.thrift.TException; public void regiserUser(UserInfo userInfo, org.apache.thrift.async.AsyncMethodCallback<Void> resultHandler) throws org.apache.thrift.TException; } public static class Client extends org.apache.thrift.TServiceClient implements Iface { public static class Factory implements org.apache.thrift.TServiceClientFactory<Client> { public Factory() {} public Client getClient(org.apache.thrift.protocol.TProtocol prot) { return new Client(prot); } public Client getClient(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) { return new Client(iprot, oprot); } } public Client(org.apache.thrift.protocol.TProtocol prot) { super(prot, prot); } public Client(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) { super(iprot, oprot); } public UserInfo getUserById(int id) throws org.apache.thrift.TException { send_getUserById(id); return recv_getUserById(); } public void send_getUserById(int id) throws org.apache.thrift.TException { getUserById_args args = new getUserById_args(); args.setId(id); sendBase("getUserById", args); } public UserInfo recv_getUserById() throws org.apache.thrift.TException { getUserById_result result = new getUserById_result(); receiveBase(result, "getUserById"); if (result.isSetSuccess()) { return result.success; } throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getUserById failed: unknown result"); } public UserInfo getUserByName(java.lang.String username) throws org.apache.thrift.TException { send_getUserByName(username); return recv_getUserByName(); } public void send_getUserByName(java.lang.String username) throws org.apache.thrift.TException { getUserByName_args args = new getUserByName_args(); args.setUsername(username); sendBase("getUserByName", args); } public UserInfo recv_getUserByName() throws org.apache.thrift.TException { getUserByName_result result = new getUserByName_result(); receiveBase(result, "getUserByName"); if (result.isSetSuccess()) { return result.success; } throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getUserByName failed: unknown result"); } public void regiserUser(UserInfo userInfo) throws org.apache.thrift.TException { send_regiserUser(userInfo); recv_regiserUser(); } public void send_regiserUser(UserInfo userInfo) throws org.apache.thrift.TException { regiserUser_args args = new regiserUser_args(); args.setUserInfo(userInfo); sendBase("regiserUser", args); } public void recv_regiserUser() throws org.apache.thrift.TException { regiserUser_result result = new regiserUser_result(); receiveBase(result, "regiserUser"); return; } } public static class AsyncClient extends org.apache.thrift.async.TAsyncClient implements AsyncIface { public static class Factory implements org.apache.thrift.async.TAsyncClientFactory<AsyncClient> { private org.apache.thrift.async.TAsyncClientManager clientManager; private org.apache.thrift.protocol.TProtocolFactory protocolFactory; public Factory(org.apache.thrift.async.TAsyncClientManager clientManager, org.apache.thrift.protocol.TProtocolFactory protocolFactory) { this.clientManager = clientManager; this.protocolFactory = protocolFactory; } public AsyncClient getAsyncClient(org.apache.thrift.transport.TNonblockingTransport transport) { return new AsyncClient(protocolFactory, clientManager, transport); } } public AsyncClient(org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.async.TAsyncClientManager clientManager, org.apache.thrift.transport.TNonblockingTransport transport) { super(protocolFactory, clientManager, transport); } public void getUserById(int id, org.apache.thrift.async.AsyncMethodCallback<UserInfo> resultHandler) throws org.apache.thrift.TException { checkReady(); getUserById_call method_call = new getUserById_call(id, resultHandler, this, ___protocolFactory, ___transport); this.___currentMethod = method_call; ___manager.call(method_call); } public static class getUserById_call extends org.apache.thrift.async.TAsyncMethodCall<UserInfo> { private int id; public getUserById_call(int id, org.apache.thrift.async.AsyncMethodCallback<UserInfo> resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { super(client, protocolFactory, transport, resultHandler, false); this.id = id; } public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("getUserById", org.apache.thrift.protocol.TMessageType.CALL, 0)); getUserById_args args = new getUserById_args(); args.setId(id); args.write(prot); prot.writeMessageEnd(); } public UserInfo getResult() throws org.apache.thrift.TException { if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { throw new java.lang.IllegalStateException("Method call not finished!"); } org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); return (new Client(prot)).recv_getUserById(); } } public void getUserByName(java.lang.String username, org.apache.thrift.async.AsyncMethodCallback<UserInfo> resultHandler) throws org.apache.thrift.TException { checkReady(); getUserByName_call method_call = new getUserByName_call(username, resultHandler, this, ___protocolFactory, ___transport); this.___currentMethod = method_call; ___manager.call(method_call); } public static class getUserByName_call extends org.apache.thrift.async.TAsyncMethodCall<UserInfo> { private java.lang.String username; public getUserByName_call(java.lang.String username, org.apache.thrift.async.AsyncMethodCallback<UserInfo> resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { super(client, protocolFactory, transport, resultHandler, false); this.username = username; } public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("getUserByName", org.apache.thrift.protocol.TMessageType.CALL, 0)); getUserByName_args args = new getUserByName_args(); args.setUsername(username); args.write(prot); prot.writeMessageEnd(); } public UserInfo getResult() throws org.apache.thrift.TException { if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { throw new java.lang.IllegalStateException("Method call not finished!"); } org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); return (new Client(prot)).recv_getUserByName(); } } public void regiserUser(UserInfo userInfo, org.apache.thrift.async.AsyncMethodCallback<Void> resultHandler) throws org.apache.thrift.TException { checkReady(); regiserUser_call method_call = new regiserUser_call(userInfo, resultHandler, this, ___protocolFactory, ___transport); this.___currentMethod = method_call; ___manager.call(method_call); } public static class regiserUser_call extends org.apache.thrift.async.TAsyncMethodCall<Void> { private UserInfo userInfo; public regiserUser_call(UserInfo userInfo, org.apache.thrift.async.AsyncMethodCallback<Void> resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { super(client, protocolFactory, transport, resultHandler, false); this.userInfo = userInfo; } public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("regiserUser", org.apache.thrift.protocol.TMessageType.CALL, 0)); regiserUser_args args = new regiserUser_args(); args.setUserInfo(userInfo); args.write(prot); prot.writeMessageEnd(); } public Void getResult() throws org.apache.thrift.TException { if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { throw new java.lang.IllegalStateException("Method call not finished!"); } org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); return null; } } } public static class Processor<I extends Iface> extends org.apache.thrift.TBaseProcessor<I> implements org.apache.thrift.TProcessor { private static final org.slf4j.Logger _LOGGER = org.slf4j.LoggerFactory.getLogger(Processor.class.getName()); public Processor(I iface) { super(iface, getProcessMap(new java.util.HashMap<java.lang.String, org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>>())); } protected Processor(I iface, java.util.Map<java.lang.String, org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>> processMap) { super(iface, getProcessMap(processMap)); } private static <I extends Iface> java.util.Map<java.lang.String, org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>> getProcessMap(java.util.Map<java.lang.String, org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>> processMap) { processMap.put("getUserById", new getUserById()); processMap.put("getUserByName", new getUserByName()); processMap.put("regiserUser", new regiserUser()); return processMap; } public static class getUserById<I extends Iface> extends org.apache.thrift.ProcessFunction<I, getUserById_args> { public getUserById() { super("getUserById"); } public getUserById_args getEmptyArgsInstance() { return new getUserById_args(); } protected boolean isOneway() { return false; } @Override protected boolean handleRuntimeExceptions() { return false; } public getUserById_result getResult(I iface, getUserById_args args) throws org.apache.thrift.TException { getUserById_result result = new getUserById_result(); result.success = iface.getUserById(args.id); return result; } } public static class getUserByName<I extends Iface> extends org.apache.thrift.ProcessFunction<I, getUserByName_args> { public getUserByName() { super("getUserByName"); } public getUserByName_args getEmptyArgsInstance() { return new getUserByName_args(); } protected boolean isOneway() { return false; } @Override protected boolean handleRuntimeExceptions() { return false; } public getUserByName_result getResult(I iface, getUserByName_args args) throws org.apache.thrift.TException { getUserByName_result result = new getUserByName_result(); result.success = iface.getUserByName(args.username); return result; } } public static class regiserUser<I extends Iface> extends org.apache.thrift.ProcessFunction<I, regiserUser_args> { public regiserUser() { super("regiserUser"); } public regiserUser_args getEmptyArgsInstance() { return new regiserUser_args(); } protected boolean isOneway() { return false; } @Override protected boolean handleRuntimeExceptions() { return false; } public regiserUser_result getResult(I iface, regiserUser_args args) throws org.apache.thrift.TException { regiserUser_result result = new regiserUser_result(); iface.regiserUser(args.userInfo); return result; } } } public static class AsyncProcessor<I extends AsyncIface> extends org.apache.thrift.TBaseAsyncProcessor<I> { private static final org.slf4j.Logger _LOGGER = org.slf4j.LoggerFactory.getLogger(AsyncProcessor.class.getName()); public AsyncProcessor(I iface) { super(iface, getProcessMap(new java.util.HashMap<java.lang.String, org.apache.thrift.AsyncProcessFunction<I, ? extends org.apache.thrift.TBase, ?>>())); } protected AsyncProcessor(I iface, java.util.Map<java.lang.String, org.apache.thrift.AsyncProcessFunction<I, ? extends org.apache.thrift.TBase, ?>> processMap) { super(iface, getProcessMap(processMap)); } private static <I extends AsyncIface> java.util.Map<java.lang.String, org.apache.thrift.AsyncProcessFunction<I, ? extends org.apache.thrift.TBase,?>> getProcessMap(java.util.Map<java.lang.String, org.apache.thrift.AsyncProcessFunction<I, ? extends org.apache.thrift.TBase, ?>> processMap) { processMap.put("getUserById", new getUserById()); processMap.put("getUserByName", new getUserByName()); processMap.put("regiserUser", new regiserUser()); return processMap; } public static class getUserById<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, getUserById_args, UserInfo> { public getUserById() { super("getUserById"); } public getUserById_args getEmptyArgsInstance() { return new getUserById_args(); } public org.apache.thrift.async.AsyncMethodCallback<UserInfo> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) { final org.apache.thrift.AsyncProcessFunction fcall = this; return new org.apache.thrift.async.AsyncMethodCallback<UserInfo>() { public void onComplete(UserInfo o) { getUserById_result result = new getUserById_result(); result.success = o; try { fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); } catch (org.apache.thrift.transport.TTransportException e) { _LOGGER.error("TTransportException writing to internal frame buffer", e); fb.close(); } catch (java.lang.Exception e) { _LOGGER.error("Exception writing to internal frame buffer", e); onError(e); } } public void onError(java.lang.Exception e) { byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; org.apache.thrift.TSerializable msg; getUserById_result result = new getUserById_result(); if (e instanceof org.apache.thrift.transport.TTransportException) { _LOGGER.error("TTransportException inside handler", e); fb.close(); return; } else if (e instanceof org.apache.thrift.TApplicationException) { _LOGGER.error("TApplicationException inside handler", e); msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; msg = (org.apache.thrift.TApplicationException)e; } else { _LOGGER.error("Exception inside handler", e); msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); } try { fcall.sendResponse(fb,msg,msgType,seqid); } catch (java.lang.Exception ex) { _LOGGER.error("Exception writing to internal frame buffer", ex); fb.close(); } } }; } protected boolean isOneway() { return false; } public void start(I iface, getUserById_args args, org.apache.thrift.async.AsyncMethodCallback<UserInfo> resultHandler) throws org.apache.thrift.TException { iface.getUserById(args.id,resultHandler); } } public static class getUserByName<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, getUserByName_args, UserInfo> { public getUserByName() { super("getUserByName"); } public getUserByName_args getEmptyArgsInstance() { return new getUserByName_args(); } public org.apache.thrift.async.AsyncMethodCallback<UserInfo> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) { final org.apache.thrift.AsyncProcessFunction fcall = this; return new org.apache.thrift.async.AsyncMethodCallback<UserInfo>() { public void onComplete(UserInfo o) { getUserByName_result result = new getUserByName_result(); result.success = o; try { fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); } catch (org.apache.thrift.transport.TTransportException e) { _LOGGER.error("TTransportException writing to internal frame buffer", e); fb.close(); } catch (java.lang.Exception e) { _LOGGER.error("Exception writing to internal frame buffer", e); onError(e); } } public void onError(java.lang.Exception e) { byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; org.apache.thrift.TSerializable msg; getUserByName_result result = new getUserByName_result(); if (e instanceof org.apache.thrift.transport.TTransportException) { _LOGGER.error("TTransportException inside handler", e); fb.close(); return; } else if (e instanceof org.apache.thrift.TApplicationException) { _LOGGER.error("TApplicationException inside handler", e); msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; msg = (org.apache.thrift.TApplicationException)e; } else { _LOGGER.error("Exception inside handler", e); msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); } try { fcall.sendResponse(fb,msg,msgType,seqid); } catch (java.lang.Exception ex) { _LOGGER.error("Exception writing to internal frame buffer", ex); fb.close(); } } }; } protected boolean isOneway() { return false; } public void start(I iface, getUserByName_args args, org.apache.thrift.async.AsyncMethodCallback<UserInfo> resultHandler) throws org.apache.thrift.TException { iface.getUserByName(args.username,resultHandler); } } public static class regiserUser<I extends AsyncIface> extends org.apache.thrift.AsyncProcessFunction<I, regiserUser_args, Void> { public regiserUser() { super("regiserUser"); } public regiserUser_args getEmptyArgsInstance() { return new regiserUser_args(); } public org.apache.thrift.async.AsyncMethodCallback<Void> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) { final org.apache.thrift.AsyncProcessFunction fcall = this; return new org.apache.thrift.async.AsyncMethodCallback<Void>() { public void onComplete(Void o) { regiserUser_result result = new regiserUser_result(); try { fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); } catch (org.apache.thrift.transport.TTransportException e) { _LOGGER.error("TTransportException writing to internal frame buffer", e); fb.close(); } catch (java.lang.Exception e) { _LOGGER.error("Exception writing to internal frame buffer", e); onError(e); } } public void onError(java.lang.Exception e) { byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; org.apache.thrift.TSerializable msg; regiserUser_result result = new regiserUser_result(); if (e instanceof org.apache.thrift.transport.TTransportException) { _LOGGER.error("TTransportException inside handler", e); fb.close(); return; } else if (e instanceof org.apache.thrift.TApplicationException) { _LOGGER.error("TApplicationException inside handler", e); msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; msg = (org.apache.thrift.TApplicationException)e; } else { _LOGGER.error("Exception inside handler", e); msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); } try { fcall.sendResponse(fb,msg,msgType,seqid); } catch (java.lang.Exception ex) { _LOGGER.error("Exception writing to internal frame buffer", ex); fb.close(); } } }; } protected boolean isOneway() { return false; } public void start(I iface, regiserUser_args args, org.apache.thrift.async.AsyncMethodCallback<Void> resultHandler) throws org.apache.thrift.TException { iface.regiserUser(args.userInfo,resultHandler); } } } public static class getUserById_args implements org.apache.thrift.TBase<getUserById_args, getUserById_args._Fields>, java.io.Serializable, Cloneable, Comparable<getUserById_args> { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getUserById_args"); private static final org.apache.thrift.protocol.TField ID_FIELD_DESC = new org.apache.thrift.protocol.TField("id", org.apache.thrift.protocol.TType.I32, (short)1); private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new getUserById_argsStandardSchemeFactory(); private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new getUserById_argsTupleSchemeFactory(); public int id; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { ID((short)1, "id"); private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 1: // ID return ID; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(java.lang.String name) { return byName.get(name); } private final short _thriftId; private final java.lang.String _fieldName; _Fields(short thriftId, java.lang.String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public java.lang.String getFieldName() { return _fieldName; } } // isset id assignments private static final int __ID_ISSET_ID = 0; private byte __isset_bitfield = 0; public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.ID, new org.apache.thrift.meta_data.FieldMetaData("id", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getUserById_args.class, metaDataMap); } public getUserById_args() { } public getUserById_args( int id) { this(); this.id = id; setIdIsSet(true); } /** * Performs a deep copy on <i>other</i>. */ public getUserById_args(getUserById_args other) { __isset_bitfield = other.__isset_bitfield; this.id = other.id; } public getUserById_args deepCopy() { return new getUserById_args(this); } @Override public void clear() { setIdIsSet(false); this.id = 0; } public int getId() { return this.id; } public getUserById_args setId(int id) { this.id = id; setIdIsSet(true); return this; } public void unsetId() { __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __ID_ISSET_ID); } /** Returns true if field id is set (has been assigned a value) and false otherwise */ public boolean isSetId() { return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __ID_ISSET_ID); } public void setIdIsSet(boolean value) { __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __ID_ISSET_ID, value); } public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case ID: if (value == null) { unsetId(); } else { setId((java.lang.Integer)value); } break; } } public java.lang.Object getFieldValue(_Fields field) { switch (field) { case ID: return getId(); } throw new java.lang.IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case ID: return isSetId(); } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof getUserById_args) return this.equals((getUserById_args)that); return false; } public boolean equals(getUserById_args that) { if (that == null) return false; if (this == that) return true; boolean this_present_id = true; boolean that_present_id = true; if (this_present_id || that_present_id) { if (!(this_present_id && that_present_id)) return false; if (this.id != that.id) return false; } return true; } @Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + id; return hashCode; } @Override public int compareTo(getUserById_args other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = java.lang.Boolean.valueOf(isSetId()).compareTo(other.isSetId()); if (lastComparison != 0) { return lastComparison; } if (isSetId()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.id, other.id); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { scheme(iprot).read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { scheme(oprot).write(oprot, this); } @Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("getUserById_args("); boolean first = true; sb.append("id:"); sb.append(this.id); first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // check for sub-struct validity } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { try { // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. __isset_bitfield = 0; read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class getUserById_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public getUserById_argsStandardScheme getScheme() { return new getUserById_argsStandardScheme(); } } private static class getUserById_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme<getUserById_args> { public void read(org.apache.thrift.protocol.TProtocol iprot, getUserById_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 1: // ID if (schemeField.type == org.apache.thrift.protocol.TType.I32) { struct.id = iprot.readI32(); struct.setIdIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, getUserById_args struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); oprot.writeFieldBegin(ID_FIELD_DESC); oprot.writeI32(struct.id); oprot.writeFieldEnd(); oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class getUserById_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public getUserById_argsTupleScheme getScheme() { return new getUserById_argsTupleScheme(); } } private static class getUserById_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme<getUserById_args> { @Override public void write(org.apache.thrift.protocol.TProtocol prot, getUserById_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet optionals = new java.util.BitSet(); if (struct.isSetId()) { optionals.set(0); } oprot.writeBitSet(optionals, 1); if (struct.isSetId()) { oprot.writeI32(struct.id); } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, getUserById_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { struct.id = iprot.readI32(); struct.setIdIsSet(true); } } } private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) { return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); } } public static class getUserById_result implements org.apache.thrift.TBase<getUserById_result, getUserById_result._Fields>, java.io.Serializable, Cloneable, Comparable<getUserById_result> { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getUserById_result"); private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRUCT, (short)0); private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new getUserById_resultStandardSchemeFactory(); private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new getUserById_resultTupleSchemeFactory(); public UserInfo success; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { SUCCESS((short)0, "success"); private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 0: // SUCCESS return SUCCESS; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(java.lang.String name) { return byName.get(name); } private final short _thriftId; private final java.lang.String _fieldName; _Fields(short thriftId, java.lang.String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public java.lang.String getFieldName() { return _fieldName; } } // isset id assignments public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, UserInfo.class))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getUserById_result.class, metaDataMap); } public getUserById_result() { } public getUserById_result( UserInfo success) { this(); this.success = success; } /** * Performs a deep copy on <i>other</i>. */ public getUserById_result(getUserById_result other) { if (other.isSetSuccess()) { this.success = new UserInfo(other.success); } } public getUserById_result deepCopy() { return new getUserById_result(this); } @Override public void clear() { this.success = null; } public UserInfo getSuccess() { return this.success; } public getUserById_result setSuccess(UserInfo success) { this.success = success; return this; } public void unsetSuccess() { this.success = null; } /** Returns true if field success is set (has been assigned a value) and false otherwise */ public boolean isSetSuccess() { return this.success != null; } public void setSuccessIsSet(boolean value) { if (!value) { this.success = null; } } public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case SUCCESS: if (value == null) { unsetSuccess(); } else { setSuccess((UserInfo)value); } break; } } public java.lang.Object getFieldValue(_Fields field) { switch (field) { case SUCCESS: return getSuccess(); } throw new java.lang.IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case SUCCESS: return isSetSuccess(); } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof getUserById_result) return this.equals((getUserById_result)that); return false; } public boolean equals(getUserById_result that) { if (that == null) return false; if (this == that) return true; boolean this_present_success = true && this.isSetSuccess(); boolean that_present_success = true && that.isSetSuccess(); if (this_present_success || that_present_success) { if (!(this_present_success && that_present_success)) return false; if (!this.success.equals(that.success)) return false; } return true; } @Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + ((isSetSuccess()) ? 131071 : 524287); if (isSetSuccess()) hashCode = hashCode * 8191 + success.hashCode(); return hashCode; } @Override public int compareTo(getUserById_result other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = java.lang.Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess()); if (lastComparison != 0) { return lastComparison; } if (isSetSuccess()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { scheme(iprot).read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { scheme(oprot).write(oprot, this); } @Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("getUserById_result("); boolean first = true; sb.append("success:"); if (this.success == null) { sb.append("null"); } else { sb.append(this.success); } first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // check for sub-struct validity if (success != null) { success.validate(); } } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { try { read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class getUserById_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public getUserById_resultStandardScheme getScheme() { return new getUserById_resultStandardScheme(); } } private static class getUserById_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme<getUserById_result> { public void read(org.apache.thrift.protocol.TProtocol iprot, getUserById_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 0: // SUCCESS if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { struct.success = new UserInfo(); struct.success.read(iprot); struct.setSuccessIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, getUserById_result struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.success != null) { oprot.writeFieldBegin(SUCCESS_FIELD_DESC); struct.success.write(oprot); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class getUserById_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public getUserById_resultTupleScheme getScheme() { return new getUserById_resultTupleScheme(); } } private static class getUserById_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme<getUserById_result> { @Override public void write(org.apache.thrift.protocol.TProtocol prot, getUserById_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet optionals = new java.util.BitSet(); if (struct.isSetSuccess()) { optionals.set(0); } oprot.writeBitSet(optionals, 1); if (struct.isSetSuccess()) { struct.success.write(oprot); } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, getUserById_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { struct.success = new UserInfo(); struct.success.read(iprot); struct.setSuccessIsSet(true); } } } private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) { return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); } } public static class getUserByName_args implements org.apache.thrift.TBase<getUserByName_args, getUserByName_args._Fields>, java.io.Serializable, Cloneable, Comparable<getUserByName_args> { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getUserByName_args"); private static final org.apache.thrift.protocol.TField USERNAME_FIELD_DESC = new org.apache.thrift.protocol.TField("username", org.apache.thrift.protocol.TType.STRING, (short)1); private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new getUserByName_argsStandardSchemeFactory(); private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new getUserByName_argsTupleSchemeFactory(); public java.lang.String username; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { USERNAME((short)1, "username"); private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 1: // USERNAME return USERNAME; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(java.lang.String name) { return byName.get(name); } private final short _thriftId; private final java.lang.String _fieldName; _Fields(short thriftId, java.lang.String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public java.lang.String getFieldName() { return _fieldName; } } // isset id assignments public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.USERNAME, new org.apache.thrift.meta_data.FieldMetaData("username", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getUserByName_args.class, metaDataMap); } public getUserByName_args() { } public getUserByName_args( java.lang.String username) { this(); this.username = username; } /** * Performs a deep copy on <i>other</i>. */ public getUserByName_args(getUserByName_args other) { if (other.isSetUsername()) { this.username = other.username; } } public getUserByName_args deepCopy() { return new getUserByName_args(this); } @Override public void clear() { this.username = null; } public java.lang.String getUsername() { return this.username; } public getUserByName_args setUsername(java.lang.String username) { this.username = username; return this; } public void unsetUsername() { this.username = null; } /** Returns true if field username is set (has been assigned a value) and false otherwise */ public boolean isSetUsername() { return this.username != null; } public void setUsernameIsSet(boolean value) { if (!value) { this.username = null; } } public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case USERNAME: if (value == null) { unsetUsername(); } else { setUsername((java.lang.String)value); } break; } } public java.lang.Object getFieldValue(_Fields field) { switch (field) { case USERNAME: return getUsername(); } throw new java.lang.IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case USERNAME: return isSetUsername(); } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof getUserByName_args) return this.equals((getUserByName_args)that); return false; } public boolean equals(getUserByName_args that) { if (that == null) return false; if (this == that) return true; boolean this_present_username = true && this.isSetUsername(); boolean that_present_username = true && that.isSetUsername(); if (this_present_username || that_present_username) { if (!(this_present_username && that_present_username)) return false; if (!this.username.equals(that.username)) return false; } return true; } @Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + ((isSetUsername()) ? 131071 : 524287); if (isSetUsername()) hashCode = hashCode * 8191 + username.hashCode(); return hashCode; } @Override public int compareTo(getUserByName_args other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = java.lang.Boolean.valueOf(isSetUsername()).compareTo(other.isSetUsername()); if (lastComparison != 0) { return lastComparison; } if (isSetUsername()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.username, other.username); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { scheme(iprot).read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { scheme(oprot).write(oprot, this); } @Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("getUserByName_args("); boolean first = true; sb.append("username:"); if (this.username == null) { sb.append("null"); } else { sb.append(this.username); } first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // check for sub-struct validity } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { try { read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class getUserByName_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public getUserByName_argsStandardScheme getScheme() { return new getUserByName_argsStandardScheme(); } } private static class getUserByName_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme<getUserByName_args> { public void read(org.apache.thrift.protocol.TProtocol iprot, getUserByName_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 1: // USERNAME if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.username = iprot.readString(); struct.setUsernameIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, getUserByName_args struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.username != null) { oprot.writeFieldBegin(USERNAME_FIELD_DESC); oprot.writeString(struct.username); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class getUserByName_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public getUserByName_argsTupleScheme getScheme() { return new getUserByName_argsTupleScheme(); } } private static class getUserByName_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme<getUserByName_args> { @Override public void write(org.apache.thrift.protocol.TProtocol prot, getUserByName_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet optionals = new java.util.BitSet(); if (struct.isSetUsername()) { optionals.set(0); } oprot.writeBitSet(optionals, 1); if (struct.isSetUsername()) { oprot.writeString(struct.username); } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, getUserByName_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { struct.username = iprot.readString(); struct.setUsernameIsSet(true); } } } private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) { return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); } } public static class getUserByName_result implements org.apache.thrift.TBase<getUserByName_result, getUserByName_result._Fields>, java.io.Serializable, Cloneable, Comparable<getUserByName_result> { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getUserByName_result"); private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRUCT, (short)0); private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new getUserByName_resultStandardSchemeFactory(); private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new getUserByName_resultTupleSchemeFactory(); public UserInfo success; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { SUCCESS((short)0, "success"); private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 0: // SUCCESS return SUCCESS; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(java.lang.String name) { return byName.get(name); } private final short _thriftId; private final java.lang.String _fieldName; _Fields(short thriftId, java.lang.String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public java.lang.String getFieldName() { return _fieldName; } } // isset id assignments public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, UserInfo.class))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getUserByName_result.class, metaDataMap); } public getUserByName_result() { } public getUserByName_result( UserInfo success) { this(); this.success = success; } /** * Performs a deep copy on <i>other</i>. */ public getUserByName_result(getUserByName_result other) { if (other.isSetSuccess()) { this.success = new UserInfo(other.success); } } public getUserByName_result deepCopy() { return new getUserByName_result(this); } @Override public void clear() { this.success = null; } public UserInfo getSuccess() { return this.success; } public getUserByName_result setSuccess(UserInfo success) { this.success = success; return this; } public void unsetSuccess() { this.success = null; } /** Returns true if field success is set (has been assigned a value) and false otherwise */ public boolean isSetSuccess() { return this.success != null; } public void setSuccessIsSet(boolean value) { if (!value) { this.success = null; } } public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case SUCCESS: if (value == null) { unsetSuccess(); } else { setSuccess((UserInfo)value); } break; } } public java.lang.Object getFieldValue(_Fields field) { switch (field) { case SUCCESS: return getSuccess(); } throw new java.lang.IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case SUCCESS: return isSetSuccess(); } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof getUserByName_result) return this.equals((getUserByName_result)that); return false; } public boolean equals(getUserByName_result that) { if (that == null) return false; if (this == that) return true; boolean this_present_success = true && this.isSetSuccess(); boolean that_present_success = true && that.isSetSuccess(); if (this_present_success || that_present_success) { if (!(this_present_success && that_present_success)) return false; if (!this.success.equals(that.success)) return false; } return true; } @Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + ((isSetSuccess()) ? 131071 : 524287); if (isSetSuccess()) hashCode = hashCode * 8191 + success.hashCode(); return hashCode; } @Override public int compareTo(getUserByName_result other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = java.lang.Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess()); if (lastComparison != 0) { return lastComparison; } if (isSetSuccess()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { scheme(iprot).read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { scheme(oprot).write(oprot, this); } @Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("getUserByName_result("); boolean first = true; sb.append("success:"); if (this.success == null) { sb.append("null"); } else { sb.append(this.success); } first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // check for sub-struct validity if (success != null) { success.validate(); } } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { try { read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class getUserByName_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public getUserByName_resultStandardScheme getScheme() { return new getUserByName_resultStandardScheme(); } } private static class getUserByName_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme<getUserByName_result> { public void read(org.apache.thrift.protocol.TProtocol iprot, getUserByName_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 0: // SUCCESS if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { struct.success = new UserInfo(); struct.success.read(iprot); struct.setSuccessIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, getUserByName_result struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.success != null) { oprot.writeFieldBegin(SUCCESS_FIELD_DESC); struct.success.write(oprot); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class getUserByName_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public getUserByName_resultTupleScheme getScheme() { return new getUserByName_resultTupleScheme(); } } private static class getUserByName_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme<getUserByName_result> { @Override public void write(org.apache.thrift.protocol.TProtocol prot, getUserByName_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet optionals = new java.util.BitSet(); if (struct.isSetSuccess()) { optionals.set(0); } oprot.writeBitSet(optionals, 1); if (struct.isSetSuccess()) { struct.success.write(oprot); } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, getUserByName_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { struct.success = new UserInfo(); struct.success.read(iprot); struct.setSuccessIsSet(true); } } } private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) { return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); } } public static class regiserUser_args implements org.apache.thrift.TBase<regiserUser_args, regiserUser_args._Fields>, java.io.Serializable, Cloneable, Comparable<regiserUser_args> { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("regiserUser_args"); private static final org.apache.thrift.protocol.TField USER_INFO_FIELD_DESC = new org.apache.thrift.protocol.TField("userInfo", org.apache.thrift.protocol.TType.STRUCT, (short)1); private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new regiserUser_argsStandardSchemeFactory(); private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new regiserUser_argsTupleSchemeFactory(); public UserInfo userInfo; // required /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { USER_INFO((short)1, "userInfo"); private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { case 1: // USER_INFO return USER_INFO; default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(java.lang.String name) { return byName.get(name); } private final short _thriftId; private final java.lang.String _fieldName; _Fields(short thriftId, java.lang.String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public java.lang.String getFieldName() { return _fieldName; } } // isset id assignments public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); tmpMap.put(_Fields.USER_INFO, new org.apache.thrift.meta_data.FieldMetaData("userInfo", org.apache.thrift.TFieldRequirementType.DEFAULT, new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, UserInfo.class))); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(regiserUser_args.class, metaDataMap); } public regiserUser_args() { } public regiserUser_args( UserInfo userInfo) { this(); this.userInfo = userInfo; } /** * Performs a deep copy on <i>other</i>. */ public regiserUser_args(regiserUser_args other) { if (other.isSetUserInfo()) { this.userInfo = new UserInfo(other.userInfo); } } public regiserUser_args deepCopy() { return new regiserUser_args(this); } @Override public void clear() { this.userInfo = null; } public UserInfo getUserInfo() { return this.userInfo; } public regiserUser_args setUserInfo(UserInfo userInfo) { this.userInfo = userInfo; return this; } public void unsetUserInfo() { this.userInfo = null; } /** Returns true if field userInfo is set (has been assigned a value) and false otherwise */ public boolean isSetUserInfo() { return this.userInfo != null; } public void setUserInfoIsSet(boolean value) { if (!value) { this.userInfo = null; } } public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { case USER_INFO: if (value == null) { unsetUserInfo(); } else { setUserInfo((UserInfo)value); } break; } } public java.lang.Object getFieldValue(_Fields field) { switch (field) { case USER_INFO: return getUserInfo(); } throw new java.lang.IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { case USER_INFO: return isSetUserInfo(); } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof regiserUser_args) return this.equals((regiserUser_args)that); return false; } public boolean equals(regiserUser_args that) { if (that == null) return false; if (this == that) return true; boolean this_present_userInfo = true && this.isSetUserInfo(); boolean that_present_userInfo = true && that.isSetUserInfo(); if (this_present_userInfo || that_present_userInfo) { if (!(this_present_userInfo && that_present_userInfo)) return false; if (!this.userInfo.equals(that.userInfo)) return false; } return true; } @Override public int hashCode() { int hashCode = 1; hashCode = hashCode * 8191 + ((isSetUserInfo()) ? 131071 : 524287); if (isSetUserInfo()) hashCode = hashCode * 8191 + userInfo.hashCode(); return hashCode; } @Override public int compareTo(regiserUser_args other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = java.lang.Boolean.valueOf(isSetUserInfo()).compareTo(other.isSetUserInfo()); if (lastComparison != 0) { return lastComparison; } if (isSetUserInfo()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.userInfo, other.userInfo); if (lastComparison != 0) { return lastComparison; } } return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { scheme(iprot).read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { scheme(oprot).write(oprot, this); } @Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("regiserUser_args("); boolean first = true; sb.append("userInfo:"); if (this.userInfo == null) { sb.append("null"); } else { sb.append(this.userInfo); } first = false; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // check for sub-struct validity if (userInfo != null) { userInfo.validate(); } } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { try { read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class regiserUser_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public regiserUser_argsStandardScheme getScheme() { return new regiserUser_argsStandardScheme(); } } private static class regiserUser_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme<regiserUser_args> { public void read(org.apache.thrift.protocol.TProtocol iprot, regiserUser_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 1: // USER_INFO if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { struct.userInfo = new UserInfo(); struct.userInfo.read(iprot); struct.setUserInfoIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, regiserUser_args struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); if (struct.userInfo != null) { oprot.writeFieldBegin(USER_INFO_FIELD_DESC); struct.userInfo.write(oprot); oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class regiserUser_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public regiserUser_argsTupleScheme getScheme() { return new regiserUser_argsTupleScheme(); } } private static class regiserUser_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme<regiserUser_args> { @Override public void write(org.apache.thrift.protocol.TProtocol prot, regiserUser_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet optionals = new java.util.BitSet(); if (struct.isSetUserInfo()) { optionals.set(0); } oprot.writeBitSet(optionals, 1); if (struct.isSetUserInfo()) { struct.userInfo.write(oprot); } } @Override public void read(org.apache.thrift.protocol.TProtocol prot, regiserUser_args struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; java.util.BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { struct.userInfo = new UserInfo(); struct.userInfo.read(iprot); struct.setUserInfoIsSet(true); } } } private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) { return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); } } public static class regiserUser_result implements org.apache.thrift.TBase<regiserUser_result, regiserUser_result._Fields>, java.io.Serializable, Cloneable, Comparable<regiserUser_result> { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("regiserUser_result"); private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new regiserUser_resultStandardSchemeFactory(); private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new regiserUser_resultTupleSchemeFactory(); /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ public enum _Fields implements org.apache.thrift.TFieldIdEnum { ; private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>(); static { for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { byName.put(field.getFieldName(), field); } } /** * Find the _Fields constant that matches fieldId, or null if its not found. */ public static _Fields findByThriftId(int fieldId) { switch(fieldId) { default: return null; } } /** * Find the _Fields constant that matches fieldId, throwing an exception * if it is not found. */ public static _Fields findByThriftIdOrThrow(int fieldId) { _Fields fields = findByThriftId(fieldId); if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); return fields; } /** * Find the _Fields constant that matches name, or null if its not found. */ public static _Fields findByName(java.lang.String name) { return byName.get(name); } private final short _thriftId; private final java.lang.String _fieldName; _Fields(short thriftId, java.lang.String fieldName) { _thriftId = thriftId; _fieldName = fieldName; } public short getThriftFieldId() { return _thriftId; } public java.lang.String getFieldName() { return _fieldName; } } public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; static { java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(regiserUser_result.class, metaDataMap); } public regiserUser_result() { } /** * Performs a deep copy on <i>other</i>. */ public regiserUser_result(regiserUser_result other) { } public regiserUser_result deepCopy() { return new regiserUser_result(this); } @Override public void clear() { } public void setFieldValue(_Fields field, java.lang.Object value) { switch (field) { } } public java.lang.Object getFieldValue(_Fields field) { switch (field) { } throw new java.lang.IllegalStateException(); } /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new java.lang.IllegalArgumentException(); } switch (field) { } throw new java.lang.IllegalStateException(); } @Override public boolean equals(java.lang.Object that) { if (that == null) return false; if (that instanceof regiserUser_result) return this.equals((regiserUser_result)that); return false; } public boolean equals(regiserUser_result that) { if (that == null) return false; if (this == that) return true; return true; } @Override public int hashCode() { int hashCode = 1; return hashCode; } @Override public int compareTo(regiserUser_result other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; return 0; } public _Fields fieldForId(int fieldId) { return _Fields.findByThriftId(fieldId); } public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { scheme(iprot).read(iprot, this); } public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { scheme(oprot).write(oprot, this); } @Override public java.lang.String toString() { java.lang.StringBuilder sb = new java.lang.StringBuilder("regiserUser_result("); boolean first = true; sb.append(")"); return sb.toString(); } public void validate() throws org.apache.thrift.TException { // check for required fields // check for sub-struct validity } private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { try { write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { try { read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } } private static class regiserUser_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public regiserUser_resultStandardScheme getScheme() { return new regiserUser_resultStandardScheme(); } } private static class regiserUser_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme<regiserUser_result> { public void read(org.apache.thrift.protocol.TProtocol iprot, regiserUser_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); // check for required fields of primitive type, which can't be checked in the validate method struct.validate(); } public void write(org.apache.thrift.protocol.TProtocol oprot, regiserUser_result struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); oprot.writeFieldStop(); oprot.writeStructEnd(); } } private static class regiserUser_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { public regiserUser_resultTupleScheme getScheme() { return new regiserUser_resultTupleScheme(); } } private static class regiserUser_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme<regiserUser_result> { @Override public void write(org.apache.thrift.protocol.TProtocol prot, regiserUser_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; } @Override public void read(org.apache.thrift.protocol.TProtocol prot, regiserUser_result struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; } } private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) { return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); } } }
-
接口定义好,就可以制作实现模块了
> 创建user-thrift-service模块
-
修改pom.xml
>引入user-thrift-service-api
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.3.RELEASE</version> </parent> <modelVersion>4.0.0</modelVersion> <groupId>com.idig8</groupId> <artifactId>user-thrift-service</artifactId> <version>1.0-SNAPSHOT</version> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> <dependency> <groupId>org.apache.thrift</groupId> <artifactId>libthrift</artifactId> <version>0.10.0</version> </dependency> <dependency> <groupId>com.idig8</groupId> <artifactId>user-thrift-service-api</artifactId> <version>1.0-SNAPSHOT</version> </dependency> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>1.3.1</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.44</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </build> </project>
- 实现user-thrift-serive-api的接口
- 推荐大家使用 docker 的方式安装mysql,之前我的中级有在windows、mac环境下安装docker的方式
# mac下 cur_dir = 'pwd' docker stop idig8-mysql docker rm idig8-mysql docker run --name idig8-mysql -v ${cur_dir}/conf:/etc/mysql/conf.d -v ${cur_dir}/data:/var/lib/mysql -p 3306:3306 -e MY_ROOT_PASSWORD=root -d mysql:latest
这里我直接使用公网的一个ip地址来远程访问,新建数据库表
- user-thrift-service 使用springboot的方式
这些都是springboot的基本操作,建议看我的源码吧。
PS:老铁可能感觉很乱,我把思路从头到尾说一下
1. 编写thrift的文件
2. 建立一个api接口,也就是user-thrift-service-api,通过thrift生成对应的java类
3. 建立user-thrift-service,通过pom引用user-thrift-service-api的jar包文件。
4. user-thrift-service 里面建立service,实现里面user-thrift-service-api的jar包接口方法。
5. 通过引入mybatise 实现数据库调用dao,service引入dao,完成接口
6. ThriftServer 引入的接口方法,启动服务代码,实现RPC开通properties里面的端口配置
>>原创文章,欢迎转载。转载请注明:转载自IT人故事会,谢谢!
>>原文链接地址:
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:- 『高级篇』docker之开发用户服务EdgeService(13)
- NFS服务的用户身份映射 荐
- 微软Azure企业用户须知:无服务器计算服务使用教程
- 译见|构建用户管理微服务(二):实现领域模型
- CentOS 7搭建基于虚拟用户的FTP服务
- 如何取得服务器上的用户组列表?
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Understanding Machine Learning
Shai Shalev-Shwartz、Shai Ben-David / Cambridge University Press / 2014 / USD 48.51
Machine learning is one of the fastest growing areas of computer science, with far-reaching applications. The aim of this textbook is to introduce machine learning, and the algorithmic paradigms it of......一起来看看 《Understanding Machine Learning》 这本书的介绍吧!