很简单,主要是注意抽象。
public class ConvertUtil { public static void convertToSnapshotDto(Snapshot model,SnapshotDto dto){ if(model == null) return; if(dto == null) dto = new SnapshotDto(); BeanUtils.copyProperties(model, dto); dto.setState(model.getState() != null ? model.getState().name() : null); dto.setInterval(model.getInterval() != null ? model.getInterval().name() : null); } public static List<SnapshotDto> convertCollectionToSnapshotDto(Collection<Snapshot> collection){ if(collection == null || collection.size() == 0) return null; List<SnapshotDto> dtos = new ArrayList<SnapshotDto>(); for(Snapshot snapshot : collection){ SnapshotDto dto = new SnapshotDto(); convertToSnapshotDto(snapshot,dto); dtos.add(dto); } return dtos; } }
相关推荐
Generate POJO-JPA-Swagger-DTO
标签:apollo-dto-1.0-javadoc.jar,apollo,dto,1.0,javadoc,jar包下载,依赖包
标签:apollo-dto-1.7.jar,apollo,dto,1.7,jar包下载,依赖包
标签:apollo-dto-1.2.jar,apollo,dto,1.2,jar包下载,依赖包
$ composer require cblink/laravel-dto -vvv 生成DTO // 默认将创建到项目app/DTO目录 php artisan make:dto BaseDTO 贡献 您可以通过以下三种方式之一进行贡献: 使用归档错误报告。 回答问题或修复上的错误。 ...
标签:apollo-dto-1.5.jar,apollo,dto,1.5,jar包下载,依赖包
标签:apollo-dto-1.3.jar,apollo,dto,1.3,jar包下载,依赖包
标签:apollo-dto-1.6.jar,apollo,dto,1.6,jar包下载,依赖包
标签:apollo-dto-1.0.jar,apollo,dto,1.0,jar包下载,依赖包
标签:apollo-dto-1.3-scaladoc.jar,apollo,dto,1.3,scaladoc,jar包下载,依赖包
标签:apollo-dto-1.1-scaladoc.jar,apollo,dto,1.1,scaladoc,jar包下载,依赖包
标签:apollo-dto-1.5-scaladoc.jar,apollo,dto,1.5,scaladoc,jar包下载,依赖包
标签:apollo-dto-1.1-sources.jar,apollo,dto,1.1,sources,jar包下载,依赖包
标签:apollo-dto-1.4-scaladoc.jar,apollo,dto,1.4,scaladoc,jar包下载,依赖包
标签:apollo-dto-1.3-javadoc.jar,apollo,dto,1.3,javadoc,jar包下载,依赖包
标签:apollo-dto-1.2-scaladoc.jar,apollo,dto,1.2,scaladoc,jar包下载,依赖包
标签:apollo-dto-1.0-sources.jar,apollo,dto,1.0,sources,jar包下载,依赖包
标签:apollo-dto-1.6-scaladoc.jar,apollo,dto,1.6,scaladoc,jar包下载,依赖包
标签:apollo-dto-1.5-sources.jar,apollo,dto,1.5,sources,jar包下载,依赖包
标签:apollo-dto-1.6-sources.jar,apollo,dto,1.6,sources,jar包下载,依赖包