本文整理了Java中org.modelmapper.ModelMapper.<init>()
方法的一些代码示例,展示了ModelMapper.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ModelMapper.<init>()
方法的具体详情如下:
包路径:org.modelmapper.ModelMapper
类名称:ModelMapper
方法名:<init>
[英]Creates a new ModelMapper.
[中]创建一个新的ModelMapper。
代码示例来源:origin: Raysmond/SpringBlog
private static ModelMapper getMapper() {
if (MAPPER == null) {
MAPPER = new ModelMapper();
MAPPER.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
}
return MAPPER;
}
代码示例来源:origin: Vedenin/useful-java-links
public static void main(String[] args) {
// init mapper
PropertyMap<Source, Destination> orderMap = new PropertyMap<Source, Destination>() {
protected void configure() {
map().setText(source.getMessage());
}
};
ModelMapper modelMapper = new ModelMapper();
modelMapper.addMappings(orderMap);
// convert
Source source = new Source("Hello World!");
Destination destObject = modelMapper.map(source, Destination.class);
destObject.print(); // print Hello World!
}
}
代码示例来源:origin: bramp/ffmpeg-cli-wrapper
private static ModelMapper newModelMapper() {
final ModelMapper mapper = new ModelMapper();
Configuration config =
mapper
.getConfiguration()
.copy()
.setFieldMatchingEnabled(true)
.setPropertyCondition(notDefault)
.setSourceNameTokenizer(NameTokenizers.UNDERSCORE);
createTypeMap(mapper, MainEncodingOptions.class, FFmpegOutputBuilder.class, config);
createTypeMap(mapper, AudioWrapper.class, FFmpegOutputBuilder.class, config);
createTypeMap(mapper, VideoWrapper.class, FFmpegOutputBuilder.class, config);
return mapper;
}
代码示例来源:origin: stackoverflow.com
ModelMapper modelMapper = new ModelMapper();
modelMapper.addMappings(new PropertyMap<Order, OrderDTO>() {
protected void configure() {
map().setBillingStreet(source.getBillingStreetAddress());
skip().setBillingCity(null);
}
});
代码示例来源:origin: stackoverflow.com
ModelMapper modelMapper = new ModelMapper();
modelMapper.addMappings(new PropertyMap<SourceClass, DestClass>() {
protected void configure() {
map().setSomeProperty(someConstant);
}
});
代码示例来源:origin: ConsenSys/eventeum
public ModelMapper createModelMapper() {
return new ModelMapper();
}
}
代码示例来源:origin: Refactoring-Bot/Refactoring-Bot
@Bean
public ModelMapper modelMapper() {
return new ModelMapper();
}
}
代码示例来源:origin: murraco/spring-boot-jwt
@Bean
public ModelMapper modelMapper() {
return new ModelMapper();
}
代码示例来源:origin: arey/java-object-mapper-benchmark
public ModelMapper() {
modelMapper = new org.modelmapper.ModelMapper();
modelMapper.addMappings(new PropertyMap<Order, OrderDTO>() {
@Override
protected void configure() {
map().setBillingStreetAddress(source.getCustomer().getBillingAddress().getStreet());
map().setBillingCity(source.getCustomer().getBillingAddress().getCity());
map().setShippingStreetAddress(source.getCustomer().getShippingAddress().getStreet());
map().setShippingCity(source.getCustomer().getShippingAddress().getCity());
}
});
}
代码示例来源:origin: jmnarloch/modelmapper-spring-boot-starter
/**
* {@inheritDoc}
*/
@Override
public ModelMapper getObject() throws Exception {
// instantiates new instance of mapper
final ModelMapper modelMapper = new ModelMapper();
// configures the mapper
configure(modelMapper);
// returns the mapper
return modelMapper;
}
代码示例来源:origin: stackoverflow.com
ModelMapper modelMapper = new ModelMapper();
modelMapper.createTypeMap(Source.class, Destination.class).setConverter(
new AbstractConverter<Source, Destination>() {
protected Destination convert(Source source) {
Destination dest = new Destination();
dest.numOfImages = source.images.size();
return dest;
}
});
代码示例来源:origin: stackoverflow.com
ModelMapper modelMapper = new ModelMapper();
List<Mapping> mappings = modelMapper.createTypeMap(Source.class, Dest.class).getMappings();
代码示例来源:origin: ldlqdsdcn/eidea4
/**
* 对象转换,把对象相同名字的属性复制给新对象
*
* @param obj 要转换的对象
* @param classOfT 转换后的类
* @return 转换后类的实例
*/
public static <T> T convertObject(Object obj, Class<T> classOfT) {
ModelMapper modelMapper = new ModelMapper();
return modelMapper.map(obj, classOfT);
}
代码示例来源:origin: stackoverflow.com
ModelMapper modelMapper = new ModelMapper();
modelMapper.getConfiguration()
.enableFieldMatching(true)
.setFieldAccessLevel(AccessLevel.PRIVATE);
代码示例来源:origin: stackoverflow.com
ModelMapper mapper = new ModelMapper();
mapper.getConfiguration().setProvider(providerVo);
mapper.addConverter(converterDtoToVo);
代码示例来源:origin: getheimdall/heimdall
/**
* Converts a source to a type destination.
*
* @param source The source object
* @param typeDestination The type destination
* @return The object created
*/
public static <T, E> E mapper(T source, Class<E> typeDestination) {
ModelMapper modelMapper = new ModelMapper();
modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
return modelMapper.map(source, typeDestination);
}
代码示例来源:origin: getheimdall/heimdall
/**
* Converts a source to a type destination.
*
* @param source The source object
* @param destination The destination object
* @return The object created
*/
public static <T, E> E mapper(T source, E destination) {
ModelMapper modelMapper = new ModelMapper();
modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
modelMapper.map(source, destination);
return destination;
}
代码示例来源:origin: tigerphz/tgcloud-master
@Override
public void saveAndSendExceptionLog(final GlobalExceptionLogDto exceptionLogDto) {
ExceptionLogInfo exceptionLog = new ModelMapper().map(exceptionLogDto, ExceptionLogInfo.class);
exceptionLog.setId(generateId());
exceptionLog.setCreateTime(new Date());
exceptionLogRepository.save(exceptionLog);
}
代码示例来源:origin: getheimdall/heimdall
/**
* Converts a source to a type destination.
*
* @param source The souce object
* @param typeDestination The type destination
* @param mapping The properties for the mapping process
* @return The object created
*/
public static <T, E> E mapperWithMapping(T source, Class<E> typeDestination, PropertyMap<T, E> mapping) {
ModelMapper modelMapper = new ModelMapper();
modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
modelMapper.addMappings(mapping);
return modelMapper.map(source, typeDestination);
}
代码示例来源:origin: ldlqdsdcn/eidea4
@Override
public TableBo saveTableBo(TableBo tableBo) {
ModelMapper modelMapper = new ModelMapper();
TablePo tablePo = modelMapper.map(tableBo, TablePo.class);
List<TableColumnPo> tableColumnPoList = modelMapper.map(tableBo.getTableColumnBoList(), new TypeToken<List<TableColumnPo>>() {
}.getType());
tableColumnPoList.forEach(e -> {
e.setTablePo(tablePo);
});
tablePo.setCoreTableColumns(tableColumnPoList);
tableDao.saveForLog(tablePo);
return modelMapper.map(tablePo, TableBo.class);
}
内容来源于网络,如有侵权,请联系作者删除!