org.modelmapper.convention.MatchingStrategies Java Examples
The following examples show how to use
org.modelmapper.convention.MatchingStrategies.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ModelMapperItemProcessor.java From incubator-batchee with Apache License 2.0 | 7 votes |
private ModelMapper ensureMapper() { if (mapper == null) { synchronized (this) { if (mapper == null) { mapper = newMapper(); if (matchingStrategy != null) { final Configuration configuration = mapper.getConfiguration(); try { configuration.setMatchingStrategy(MatchingStrategy.class.cast( MatchingStrategies.class.getDeclaredField(matchingStrategy.toUpperCase(Locale.ENGLISH)).get(null))); } catch (final Exception e) { try { configuration.setMatchingStrategy(MatchingStrategy.class.cast(currentLoader().loadClass(matchingStrategy))); } catch (final Exception e1) { if (RuntimeException.class.isInstance(e)) { throw RuntimeException.class.cast(e); } throw new IllegalStateException(e); } } } } } } return mapper; }
Example #2
Source File: PageFieldServiceImpl.java From agile-service-old with Apache License 2.0 | 6 votes |
@Override public List<PageFieldViewVO> queryPageFieldViewList(Long organizationId, Long projectId, PageFieldViewParamVO paramDTO) { if (!EnumUtil.contain(PageCode.class, paramDTO.getPageCode())) { throw new CommonException(ERROR_PAGECODE_ILLEGAL); } if (!EnumUtil.contain(ObjectSchemeCode.class, paramDTO.getSchemeCode())) { throw new CommonException(ERROR_SCHEMECODE_ILLEGAL); } if (!EnumUtil.contain(ObjectSchemeFieldContext.class, paramDTO.getContext())) { throw new CommonException(ERROR_CONTEXT_ILLEGAL); } List<PageFieldDTO> pageFields = queryPageField(organizationId, projectId, paramDTO.getPageCode(), paramDTO.getContext()); //modelMapper设置严格匹配策略 modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); pageFields = pageFields.stream().filter(PageFieldDTO::getDisplay).collect(Collectors.toList()); List<PageFieldViewVO> pageFieldViews = modelMapper.map(pageFields, new TypeToken<List<PageFieldViewVO>>() { }.getType()); //填充option optionService.fillOptions(organizationId, projectId, pageFieldViews); FieldValueUtil.handleDefaultValue(pageFieldViews); return pageFieldViews; }
Example #3
Source File: ModelMappingConfig.java From production-ready-microservices-starter with MIT License | 5 votes |
@Bean public ModelMapper createModelMapper() { ModelMapper modelMapper = new ModelMapper(); modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); addMappingSiteCreateUpdateRequestToSite(modelMapper); addMappingSiteToSiteResponse(modelMapper); return modelMapper; }
Example #4
Source File: AbstractSpec.java From incubator-pinot with Apache License 2.0 | 5 votes |
public static <T extends AbstractSpec> T fromProperties(Map<String, Object> properties, Class<T> specClass) { // don't reuse model mapper instance. It caches typeMaps and will result in unexpected mappings ModelMapper modelMapper = new ModelMapper(); // use strict mapping to ensure no mismatches or ambiguity occurs modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); return modelMapper.map(properties, specClass); }
Example #5
Source File: DefaultModelMapperFactory.java From spring-boot-doma2-sample with Apache License 2.0 | 5 votes |
/** * ModelMapperを返します。 * * @return */ public static ModelMapper create() { // ObjectMappingのためのマッパー val modelMapper = new ModelMapper(); val configuration = modelMapper.getConfiguration(); configuration.setPropertyCondition( // IDフィールド以外をマッピングする context -> { // DomaDtoのIDカラムは上書きしないようにする PropertyInfo propertyInfo = context.getMapping().getLastDestinationProperty(); return !(context.getParent().getDestination() instanceof DomaDto && propertyInfo.getName().equals("id")); }); // 厳格にマッピングする configuration.setMatchingStrategy(MatchingStrategies.STRICT); // コンバーター val idToInt = new AbstractConverter<ID<?>, Integer>() { @Override protected Integer convert(ID<?> source) { return source == null ? null : source.getValue(); } }; modelMapper.addConverter(idToInt); return modelMapper; }
Example #6
Source File: ProjectMapper.java From c4sg-services with MIT License | 5 votes |
public ProjectDTO getProjectDtoFromEntity(Project project) { getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); ProjectDTO projectDTO = map(project, ProjectDTO.class); mapFromOrganization(project, projectDTO); return projectDTO; }
Example #7
Source File: OrderMapper.java From research-graphql with MIT License | 5 votes |
public OrderMapper() { mapper = new ModelMapper(); // use strict to prevent over eager matching (happens with ID fields) mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); // create PropertyMap<source,target> here and add to mapper mapper.addMappings(new PropertyMap<OrderForm, OrderDto>() { @Override protected void configure() { } }); mapper.addMappings(new PropertyMap<OrderDto, OrderForm>() { @Override protected void configure() { } }); mapper.addMappings(new PropertyMap<OrderItemDto, OrderItem>() { @Override protected void configure() { } }); // need to add the parent link to jpa order items (as these don't exist in dto form) mapper.getTypeMap(OrderDto.class, OrderForm.class) .setPostConverter(context -> { OrderForm target = context.getDestination(); log.info("post-converter fixing OrderItem parent links {}", target); if (target.getItems() != null) { target.getItems().stream().forEach((item) -> item.setOrder(target)); } return target; }); }
Example #8
Source File: GenericConverter.java From heimdall with Apache License 2.0 | 5 votes |
public static <T, E> void convertWithMapping(T source, E destination, PropertyMap<T, E> mapping) { if (source != null && destination != null) { ModelMapper modelMapper = new ModelMapper(); modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); modelMapper.addMappings(mapping); modelMapper.map(source, destination); } }
Example #9
Source File: GenericConverter.java From heimdall with Apache License 2.0 | 5 votes |
/** * Converts a source to a type destination. * * @param source The souce object * @return The object created */ public static <E, T> List<E> mapper(List<T> source, Type destinationType) { List<E> model = null; if (source != null && destinationType != null) { ModelMapper modelMapper = new ModelMapper(); modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); model = modelMapper.map(source, destinationType); } return model; }
Example #10
Source File: GenericConverter.java From heimdall with Apache License 2.0 | 5 votes |
/** * 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; }
Example #11
Source File: GenericConverter.java From heimdall with Apache License 2.0 | 5 votes |
/** * 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); }
Example #12
Source File: MappingConfig.java From production-ready-microservices-starter with MIT License | 5 votes |
@Bean public ModelMapper createModelMapper() { ModelMapper mapper = new ModelMapper(); mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); return mapper; }
Example #13
Source File: ProjectInfoServiceImpl.java From agile-service-old with Apache License 2.0 | 4 votes |
@PostConstruct public void init() { modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); }
Example #14
Source File: BoardColumnServiceImpl.java From agile-service-old with Apache License 2.0 | 4 votes |
@PostConstruct public void init() { modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); }
Example #15
Source File: StateMachineClientServiceImpl.java From agile-service-old with Apache License 2.0 | 4 votes |
@PostConstruct public void init() { modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); }
Example #16
Source File: IssueCommentServiceImpl.java From agile-service-old with Apache License 2.0 | 4 votes |
@PostConstruct public void init() { modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); }
Example #17
Source File: ArtServiceImpl.java From agile-service-old with Apache License 2.0 | 4 votes |
@PostConstruct public void init() { modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); }
Example #18
Source File: IterativeWorktableServiceImpl.java From agile-service-old with Apache License 2.0 | 4 votes |
@PostConstruct public void init() { modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); }
Example #19
Source File: StoryMapWidthServiceImpl.java From agile-service-old with Apache License 2.0 | 4 votes |
@PostConstruct public void init() { modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); }
Example #20
Source File: IssueServiceImpl.java From agile-service-old with Apache License 2.0 | 4 votes |
@PostConstruct public void init() { modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); }
Example #21
Source File: IssueAssembler.java From agile-service-old with Apache License 2.0 | 4 votes |
@PostConstruct public void init() { modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); }
Example #22
Source File: FeatureCommonAssembler.java From agile-service-old with Apache License 2.0 | 4 votes |
@PostConstruct public void init() { modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); }
Example #23
Source File: ArtAssembler.java From agile-service-old with Apache License 2.0 | 4 votes |
@PostConstruct public void init() { modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); }
Example #24
Source File: BoardSprintAttrServiceImpl.java From agile-service-old with Apache License 2.0 | 4 votes |
@PostConstruct public void init() { this.modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); }
Example #25
Source File: PiServiceImpl.java From agile-service-old with Apache License 2.0 | 4 votes |
@PostConstruct public void init() { modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); }
Example #26
Source File: StoryMapServiceImpl.java From agile-service-old with Apache License 2.0 | 4 votes |
@PostConstruct public void init() { modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); }
Example #27
Source File: QuickFilterServiceImpl.java From agile-service-old with Apache License 2.0 | 4 votes |
@PostConstruct public void init() { modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); }
Example #28
Source File: BoardFeatureServiceImpl.java From agile-service-old with Apache License 2.0 | 4 votes |
@PostConstruct public void init() { this.modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); }
Example #29
Source File: StoryMapper.java From c4sg-services with MIT License | 4 votes |
public StoryDTO getStoryDtoFromEntity(Story story) { getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); StoryDTO storyDTO = map(story, StoryDTO.class); return storyDTO; }
Example #30
Source File: DataLogAspect.java From agile-service-old with Apache License 2.0 | 4 votes |
@PostConstruct public void init() { modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); }