我如何重写以下内容以使用lambda而不是内部函数:
List<ExtraService> extraServices = product.getServices().getExtraService().stream()
.map(new Function<com.novasol.bookingflow.api.entities.products.ExtraService, ExtraService>() {
@Override
public ExtraService apply(com.novasol.bookingflow.api.entities.products.ExtraService es) {
ExtraService extraService = new ExtraService();
extraService.setServiceId(es.getServiceID());
extraService.setPriceUnitCode(es.getPriceUnitCode().intValue());
extraService.setServiceGroup(es.getServiceGroup().intValue());
extraService.setMaxUnits(es.getMaxUnits().intValue());
return extraService;
}
}).collect(toList());
就像是
List<ExtraService> extraServices = product.getServices().getExtraService().stream()
.map( es -> {
ExtraService extraService = new ExtraService();
extraService.setServiceId(es.getServiceID());
extraService.setPriceUnitCode(es.getPriceUnitCode().intValue());
extraService.setServiceGroup(es.getServiceGroup().intValue());
extraService.setMaxUnits(es.getMaxUnits().intValue());
return extraService;
}
).collect(toList());
?
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句