# thrift-generator **Repository Path**: finallygo/thrift-generator ## Basic Information - **Project Name**: thrift-generator - **Description**: Creating a thrift file via a Java interface - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2017-12-11 - **Last Updated**: 2022-07-01 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README thrift-generator ================ Creating a thrift file via a Java interface ## example ```java public interface ICommonUserService { public User login(int id, String name); public User getUserById(long id); public boolean saveUser(User user); public List getUserIds(long id); public Map getUserByIds(List ids); public Map> getUsersByName(List names); public Map> getGroupUsers(List names, List userList, List lns, long ll); public List testCase1(Map num1, List num2, List num3, long num4, String num5); } ``` ```java public class ThriftFileBuilderTest { private ThriftFileBuilder fileBuilder = new ThriftFileBuilder(); @Test public void toOutputstream() throws Exception { this.fileBuilder.buildToOutputStream(ICommonUserService.class, System.out); } } ``` ### 执行: ```mvn test -Dtest=com.sohu.thrift.generator.builder.ThriftFileBuilderTest``` ### 之后会在控制台输出如下信息: ```thrift namespace java com.sohu.thrift.generator.test.thrift enum Status { NORMAL = 0, BLOCKED = 1 } struct Account { 1:i32 id, 2:string name } struct User { 1:i32 id, 2:string name, 3:bool sex, 4:Status status, 5:list ids, 6:Account account } service ICommonUserService { list getUserIds(1:i64 id), User login(1:i32 id,2:string name), map> getUsersByName(1:list names), map> getGroupUsers(1:list names,2:list userList,3:list lns,4:i64 ll), map getUserByIds(1:list ids), list testCase1(1:map num1,2:list num2,3:list num3,4:i64 num4,5:string num5), User getUserById(1:i64 id), bool saveUser(1:User user) } ```