本文整理汇总了Java中org.springframework.cglib.beans.BeanMap.create方法的典型用法代码示例。如果您正苦于以下问题:Java BeanMap.create方法的具体用法?Java BeanMap.create怎么用?Java BeanMap.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.cglib.beans.BeanMap
的用法示例。
在下文中一共展示了BeanMap.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: listToBean
import org.springframework.cglib.beans.BeanMap; //导入方法依赖的package包/类
/**
* 将List<Map<String,Object>>转换为List<T>
*
* @param maps
* @param clazz
* @return
* @throws InstantiationException
* @throws IllegalAccessException
*/
public static <T> List<T> listToBean(List<Object> maps, Class<T> clazz) throws InstantiationException, IllegalAccessException {
List<T> list = Lists.newArrayList();
if (maps != null && maps.size() > 0) {
Object map;
T bean;
for (int i = 0, size = maps.size(); i < size; i++) {
map = maps.get(i);
bean = clazz.newInstance();
BeanMap beanMap = BeanMap.create(bean);
list.add(bean);
}
}
return list;
}
示例2: mapToBean
import org.springframework.cglib.beans.BeanMap; //导入方法依赖的package包/类
/**
* 将map装换为javabean对象
*
* @param map
* @param bean
* @return
*/
public static <T> T mapToBean(Map map, T bean) {
// 转换BigInteger
Iterator<Map.Entry<String, Object>> it = map.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, Object> e = it.next();
String key = e.getKey();
Object value = e.getValue();
if (value instanceof BigInteger) {
map.put(key, ((BigInteger) value).longValue());
}
}
BeanMap beanMap = BeanMap.create(bean);
beanMap.putAll(map);
return bean;
}
示例3: beanToMap
import org.springframework.cglib.beans.BeanMap; //导入方法依赖的package包/类
/**
* 将对象装换为map
*
* @param bean
* @return
*/
public static <T> Map<String, Object> beanToMap(T bean) {
Map<String, Object> map = Maps.newHashMap();
if (bean != null) {
BeanMap beanMap = BeanMap.create(bean);
for (Object key : beanMap.keySet()) {
if (Objects.nonNull(beanMap.get(key))) {
map.put(key + "", beanMap.get(key));
}
}
}
return map;
}
示例4: beanToMap
import org.springframework.cglib.beans.BeanMap; //导入方法依赖的package包/类
/**
* Bean 转 Map
* @param bean
* @param <T>
* @return
*/
public static <T> Map<String, Object> beanToMap(T bean) {
Map<String, Object> map = Maps.newHashMap();
if (bean != null) {
BeanMap beanMap = BeanMap.create(bean);
for (Object key : beanMap.keySet()) {
map.put(key+"", beanMap.get(key));
}
}
return map;
}
示例5: beanToMap
import org.springframework.cglib.beans.BeanMap; //导入方法依赖的package包/类
/**
* 将对象装换为map
*
* @param obj
* @return
*/
public static <T> Map beanToMap(T obj) {
Map map = new HashMap();
if (obj != null) {
BeanMap beanMap = BeanMap.create(obj);
Iterator it = beanMap.entrySet().iterator();
for (Object key : beanMap.keySet()) {
map.put(key + "", beanMap.get(key));
}
}
return map;
}
示例6: objectToMap
import org.springframework.cglib.beans.BeanMap; //导入方法依赖的package包/类
/**
* convert object to Map
* @param obj
* @return
*/
@SuppressWarnings("rawtypes")
public static Map objectToMap(Object obj) {
if (obj == null)
return null;
return BeanMap.create(obj);
}
示例7: copytoSoapObject
import org.springframework.cglib.beans.BeanMap; //导入方法依赖的package包/类
private Object copytoSoapObject(Object param, Class<?> soapClass)
throws Exception {
Object soapObject = soapClass.newInstance();
if (soapObject instanceof java.lang.String) {
soapObject = param.toString();
} else {
BeanMap beanMap = BeanMap.create(soapObject);
DynamicDTO dto = (DynamicDTO) param;
for (String key : dto.properties()) {
beanMap.put(key, dto.getValue(key));
}
}
return soapObject;
}
示例8: DynamicDTO
import org.springframework.cglib.beans.BeanMap; //导入方法依赖的package包/类
public DynamicDTO(BaseModel model){
generator = new BeanGenerator();
valueMap = new TreeMap<String, Object>();
beanObject = model;
beanMap = BeanMap.create(model);
valueMap.putAll(beanMap);
}
示例9: getCloneBean
import org.springframework.cglib.beans.BeanMap; //导入方法依赖的package包/类
public Object getCloneBean() {
try {
Object tmpObject = generator.create();
BeanMap tmpMap = BeanMap.create(tmpObject);
tmpMap.putAll(valueMap);
return tmpObject;
} catch (Exception e) {
return null;
}
}
示例10: convert
import org.springframework.cglib.beans.BeanMap; //导入方法依赖的package包/类
/**
* 转换器,设置DynamicDTO的属性值到对应的Model对象
*
* @param target
*/
@SuppressWarnings("unchecked")
public void convert(BaseModel target) {
BeanMap tmp = BeanMap.create(target);
Iterator<String> keys = tmp.keySet().iterator();
String key = null;
while(keys.hasNext()){
key = keys.next();
if(beanMap.containsKey(key)){
StringConverter converter = new StringConverter();
TypeConverterManager.register(String.class, converter);
tmp.put(key, TypeConverterManager.convertType(beanMap.get(key), tmp.getPropertyType(key)));
}
}
}
示例11: objectMapToBean
import org.springframework.cglib.beans.BeanMap; //导入方法依赖的package包/类
public static <T> T objectMapToBean(Map<Object,Object> map, T bean) {
BeanMap beanMap = BeanMap.create(bean);
beanMap.putAll(map);
return bean;
}
示例12: generateBean
import org.springframework.cglib.beans.BeanMap; //导入方法依赖的package包/类
private void generateBean() throws Exception {
beanObject = generator.create();
beanMap = BeanMap.create(beanObject);
beanMap.putAll(valueMap);
}
示例13: mapToBean
import org.springframework.cglib.beans.BeanMap; //导入方法依赖的package包/类
/**
* 将map装换为javabean对象
*
* @param map
* @param bean
* @return
*/
public static <T> T mapToBean(Map<String,Object> map, T bean) {
BeanMap beanMap = BeanMap.create(bean);
beanMap.putAll(map);
return bean;
}
示例14: stringMapToBean
import org.springframework.cglib.beans.BeanMap; //导入方法依赖的package包/类
/**
* 将map装换为javabean对象
*
* @param map key value 为string 的map
* @param bean
* @return
*/
public static <T> T stringMapToBean(Map<String,String> map, T bean) {
BeanMap beanMap = BeanMap.create(bean);
beanMap.putAll(map);
return bean;
}
示例15: toMap
import org.springframework.cglib.beans.BeanMap; //导入方法依赖的package包/类
/**
* 将对象装成map形式
* @param src
* @return
*/
@SuppressWarnings("rawtypes")
public static Map toMap(Object src) {
return BeanMap.create(src);
}