本文整理匯總了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);
}