本文整理汇总了Java中org.dozer.DozerBeanMapper.map方法的典型用法代码示例。如果您正苦于以下问题:Java DozerBeanMapper.map方法的具体用法?Java DozerBeanMapper.map怎么用?Java DozerBeanMapper.map使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.dozer.DozerBeanMapper
的用法示例。
在下文中一共展示了DozerBeanMapper.map方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: map
import org.dozer.DozerBeanMapper; //导入方法依赖的package包/类
public static void map(final Object source, final Object destination, boolean ignoreNull) {
DozerBeanMapper mapper = new DozerBeanMapper();
if(ignoreNull) {
mapper.addMapping(new BeanMappingBuilder() {
protected void configure() {
mapping(source.getClass(), destination.getClass(), mapNull(false), mapEmptyString(true));
}
});
}
mapper.map(source, destination);
}
示例2: executeInternal
import org.dozer.DozerBeanMapper; //导入方法依赖的package包/类
@Override
protected SavePropertyResult executeInternal(SaveProperty action, ExecutionContext context) throws ActionException {
DozerBeanMapper mapper = new DozerBeanMapper();
Properties property = mapper.map(action.getProperties(), Properties.class);
Contentholder originalProperty = contentholderDAOProvider.get().get(action.getProperties().getId());
property.setContentitems(originalProperty.getContentitems());
property.setTimeStamp(System.currentTimeMillis());
System.out.println("The property being saved = " + property.getId());
Users user = getUser();
System.out.println("The user =" + user);
property.setUser(user);
BaseWIPSvcHelper helper = new BaseWIPSvcHelper((Contentholder) property, contentholderDAOProvider.get(),
itemDAOProvider.get());
property = (Properties) helper.checkin();
postSaveOrUpdateproperties(property);
System.out.println("The property that got checkedin =" + property.getId());
PropertiesDTO pDTO = DozerBeanMapperSingletonWrapper.getInstance().map(property, PropertiesDTO.class);
return new SavePropertyResult(pDTO);
}
示例3: sourceToDestinationMapping
import org.dozer.DozerBeanMapper; //导入方法依赖的package包/类
/**
* @param source. The source object that needs to map to destination.
* @param destination. The destination object that needs to map from source.
* @return destination object
*/
public static Object sourceToDestinationMapping(Object source, Class destination) {
DozerBeanMapper mapper = DozerBeanMapperSingletonWrapper.instance();
Object destinationObj = mapper.map(source, destination);
return destinationObj;
}
示例4: testDozer
import org.dozer.DozerBeanMapper; //导入方法依赖的package包/类
public Profiler testDozer(int invokeNum, String frameworkName) {
DozerBeanMapper mapper = new DozerBeanMapper();
long start = System.currentTimeMillis();
for (int i = 0; i < invokeNum; i++) {
Person7 p = getPerson();
PersonDto dto = mapper.map(p, PersonDto.class);
//System.out.println(dto);
}
return Profiler.apply(System.currentTimeMillis(), start)
.setFrameworkName(frameworkName);
}
示例5: useJEntityGraphDataMapper
import org.dozer.DozerBeanMapper; //导入方法依赖的package包/类
/**
* Combines using an entityGraph for accessing data from a database with
* dozer mapping and returns a decoupled data object
*
* @param em
* entity manager for database access
* @param classTypeBE
* source object type
* @param classTypeDO
* destination object type
* @param entityGraphName
* name of the entity graph
* @param id
* identification number for accessed entity
* @return data object of type classTypeDO
*/
public <BE, DO> DO useJEntityGraphDataMapper(final EntityManager em, final Class<BE> classTypeBE,
final Class<DO> classTypeDO, final String entityGraphName, final int id) {
final BuildDozerMapping dozerMappingBuilder = new BuildDozerMapping();
final BuildEntityGraph entityGraphBuilder = new BuildEntityGraph();
BE businessEntity = null;
DO dataObject = null;
try {
dataObject = classTypeDO.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
e.printStackTrace();
}
@SuppressWarnings("unchecked")
final EntityGraph<BE> xmlGraph = (EntityGraph<BE>) entityGraphBuilder.generateEntityGraphXPath(em,
entityGraphName, classTypeBE);
final Map<String, Object> hints = new HashMap<String, Object>();
hints.put("javax.persistence.loadgraph", xmlGraph);
businessEntity = em.find(classTypeBE, id, hints);
final DozerBeanMapper mapper = dozerMappingBuilder.generateMappingRulesXPath(entityGraphName);
mapper.map(businessEntity, dataObject);
return dataObject;
}
示例6: mapFromPerson
import org.dozer.DozerBeanMapper; //导入方法依赖的package包/类
public static PersonBean mapFromPerson(Person sourceObject) {
List<String> myMappingFiles = new ArrayList<String>();
myMappingFiles.add("dozerMappings.xml");
DozerBeanMapper mapper = new DozerBeanMapper();
mapper.setMappingFiles(myMappingFiles);
System.out.println("Mapping Person to PersonBean...");
return (PersonBean) mapper.map(sourceObject, PersonBean.class);
}
示例7: mapToPerson
import org.dozer.DozerBeanMapper; //导入方法依赖的package包/类
public static Person mapToPerson(PersonBean sourceObject) {
List<String> myMappingFiles = new ArrayList<String>();
myMappingFiles.add("dozerMappings.xml");
DozerBeanMapper mapper = new DozerBeanMapper();
mapper.setMappingFiles(myMappingFiles);
System.out.println("Mapping PersonBean to Person...");
return (Person) mapper.map(sourceObject, Person.class);
}
示例8: mapFromPerson
import org.dozer.DozerBeanMapper; //导入方法依赖的package包/类
public static PersonAnnotationBean mapFromPerson(Person sourceObject) {
List<String> myMappingFiles = new ArrayList<String>();
myMappingFiles.add("dozerMappings.xml");
DozerBeanMapper mapper = new DozerBeanMapper();
mapper.setMappingFiles(myMappingFiles);
System.out.println("Mapping Person to PersonAnnotationBean...");
return (PersonAnnotationBean) mapper.map(sourceObject, PersonAnnotationBean.class);
}
示例9: mapToPerson
import org.dozer.DozerBeanMapper; //导入方法依赖的package包/类
public static Person mapToPerson(PersonAnnotationBean sourceObject) {
List<String> myMappingFiles = new ArrayList<String>();
myMappingFiles.add("dozerMappings.xml");
DozerBeanMapper mapper = new DozerBeanMapper();
mapper.setMappingFiles(myMappingFiles);
System.out.println("Mapping PersonAnnotationBean to Person...");
return (Person) mapper.map(sourceObject, Person.class);
}