当前位置: 首页>>代码示例>>Java>>正文


Java MatchingStrategies类代码示例

本文整理汇总了Java中org.modelmapper.convention.MatchingStrategies的典型用法代码示例。如果您正苦于以下问题:Java MatchingStrategies类的具体用法?Java MatchingStrategies怎么用?Java MatchingStrategies使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MatchingStrategies类属于org.modelmapper.convention包,在下文中一共展示了MatchingStrategies类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: OrderMapper

import org.modelmapper.convention.MatchingStrategies; //导入依赖的package包/类
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;
            });
}
 
开发者ID:roybailey,项目名称:research-graphql,代码行数:32,代码来源:OrderMapper.java

示例2: ensureMapper

import org.modelmapper.convention.MatchingStrategies; //导入依赖的package包/类
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;
}
 
开发者ID:apache,项目名称:incubator-batchee,代码行数:27,代码来源:ModelMapperItemProcessor.java

示例3: getProjectDtoFromEntity

import org.modelmapper.convention.MatchingStrategies; //导入依赖的package包/类
public ProjectDTO getProjectDtoFromEntity(Project project) {
	getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
	ProjectDTO projectDTO = map(project, ProjectDTO.class);
	mapFromOrganization(project, projectDTO);
	
	return projectDTO;
}
 
开发者ID:Code4SocialGood,项目名称:c4sg-services,代码行数:8,代码来源:ProjectMapper.java

示例4: updateUser

import org.modelmapper.convention.MatchingStrategies; //导入依赖的package包/类
@Override
public UserDTO updateUser(long id, UserUpdateDTO updateDTO) {
    Assert.notNull(updateDTO, "User update dto must not be null.");
    User userToUpdate = userRepository.findOne(id);
    if (userToUpdate != null) {
        modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STANDARD);
        modelMapper.map(updateDTO, userToUpdate.getDetails());
        modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.LOOSE);
        User saved = userRepository.save(userToUpdate);
        return modelMapper.map(saved, UserDTO.class);
    }
    return null;
}
 
开发者ID:RFTDevGroup,项目名称:RFTBackend,代码行数:14,代码来源:UserServiceImpl.java

示例5: save

import org.modelmapper.convention.MatchingStrategies; //导入依赖的package包/类
@Override
public boolean save(TransportCreateDTO createDTO, User owner) {
    Assert.notNull(createDTO, "Transport create dto must not be null!");

    Transport transportToSave = new Transport();
    modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
    modelMapper.map(createDTO, transportToSave);
    modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.LOOSE);

    transportToSave.setOwner(owner);
    Transport saved = transportRepository.save(transportToSave);
    return saved != null;
}
 
开发者ID:RFTDevGroup,项目名称:RFTBackend,代码行数:14,代码来源:TransportServiceImpl.java

示例6: getProjectDtoFromEntity

import org.modelmapper.convention.MatchingStrategies; //导入依赖的package包/类
public ProjectDTO getProjectDtoFromEntity(Project project){
	getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
	ProjectDTO projectDTO = map(project, ProjectDTO.class);
	projectDTO.setOrganizationName(project.getOrganization().getName());
	return projectDTO;
}
 
开发者ID:Code4SocialGood,项目名称:C4SG-Obsolete,代码行数:7,代码来源:ProjectMapper.java

示例7: getStoryDtoFromEntity

import org.modelmapper.convention.MatchingStrategies; //导入依赖的package包/类
public StoryDTO getStoryDtoFromEntity(Story story) {
    getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
    StoryDTO storyDTO = map(story, StoryDTO.class);
    return storyDTO;
}
 
开发者ID:Code4SocialGood,项目名称:c4sg-services,代码行数:6,代码来源:StoryMapper.java

示例8: getProjectEntityFromCreateProjectDto

import org.modelmapper.convention.MatchingStrategies; //导入依赖的package包/类
public Project getProjectEntityFromCreateProjectDto(CreateProjectDTO createProjectDTO){
	getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
	Project project = map(createProjectDTO, Project.class);
	project.setOrganization(organizationDAO.findOne(createProjectDTO.getOrganizationId()));
	return project;
}
 
开发者ID:Code4SocialGood,项目名称:c4sg-services,代码行数:7,代码来源:ProjectMapper.java

示例9: configure

import org.modelmapper.convention.MatchingStrategies; //导入依赖的package包/类
@Override
public void configure(Configuration configuration) {
    configuration.setMatchingStrategy(MatchingStrategies.STRICT);
}
 
开发者ID:rozidan,项目名称:project-template,代码行数:5,代码来源:MapperConfiguration.java


注:本文中的org.modelmapper.convention.MatchingStrategies类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。