java的一段对象数据类型映射的代码
try { List<GateMetaPO> listGateInfoPO = majorGateReaderService.queryForAggregateBy( chapter); List<GateInfoPB> list = Lists.transform(listGateInfoPO, new Function<GateMetaPO, GateInfoPB>() { @Override public GateInfoPB apply(GateMetaPO input) { GateInfoPB.Builder builder = GateInfoPB.newBuilder(); builder.setChapter(input.getChapter()); builder.setGateCode(input.getGateCode()); builder.setExp(input.getExp()); builder.setMoney(input.getMoney()); builder.setIndex(input.getIndex()); List<EmemyList> ememyList = input.getEmemyList(); List<EmemyListPB> ememyListPB = Lists.transform(ememyList, new Function<EmemyList, EmemyListPB>() { @Override public EmemyListPB apply( EmemyList input) { EmemyListPB.Builder builder = EmemyListPB.newBuilder(); builder.setMode(input.getMode()); List<EmemyInfo> ememyInfo = input.getEmemyInfo(); List<EmemyInfoPB> ememyInfoPB = Lists.transform(ememyInfo, new Function<EmemyInfo, EmemyInfoPB>() { @Override public EmemyInfoPB apply(EmemyInfo input) { EmemyInfoPB.Builder builder = EmemyInfoPB.newBuilder(); builder.setEmemyCode(input.getEmemyCode()); builder.setIndex(Integer.parseInt(input.getEmemyIndex())); return builder.build(); } }); builder.addAllEmemyInfoPB(ememyInfoPB); return builder.build(); } }); builder.addAllEmemyListPB(ememyListPB); List<GoodsList> goodsList = input.getGoodsList(); List<GoodsListPB> goodsListPB = Lists.transform(goodsList, new Function<GoodsList, GoodsListPB>(){ @Override public GoodsListPB apply(GoodsList input) { // TODO Auto-generated method stub GoodsListPB.Builder builder = GoodsListPB.newBuilder(); builder.setMode(input.getMode()); List<GoodsInfo> goodsInfo = input.getGoodsInfo(); List<GoodsInfoPB> goodsInfoPB = Lists.transform(goodsInfo, new Function<GoodsInfo, GoodsInfoPB>(){ @Override public GoodsInfoPB apply(GoodsInfo input) { GoodsInfoPB.Builder builder = GoodsInfoPB.newBuilder(); builder.setGoodsCode(input.getGoodsCode()); builder.setMaxCounts(input.getMaxCounts()); builder.setDropRate(input.getDropRate()); return builder.build(); } }); builder.addAllGoodsInfoPB(goodsInfoPB); return builder.build(); } }); builder.addAllGoodsListPB(goodsListPB); List<GateState> gateState = input.getGateStateList(); List<GateStatePB> gateStatePB = Lists.transform(gateState, new Function<GateState, GateStatePB>(){ @Override public GateStatePB apply(GateState input) { GateStatePB.Builder builder = GateStatePB.newBuilder(); builder.setMode(input.getMode()); builder.setBattleState(input.getBattleState()); builder.setScore(input.getScore()); builder.setCounts(input.getCounts()); builder.setTotal(input.getTotal()); return builder.build(); } }); builder.addAllGateStatePB(gateStatePB); return builder.build(); } }); builder.setResultCode(1).addAllGateInfo(list); } catch (Exception e) { }