本文整理了Java中cn.hutool.core.bean.BeanUtil.isBean()
方法的一些代码示例,展示了BeanUtil.isBean()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BeanUtil.isBean()
方法的具体详情如下:
包路径:cn.hutool.core.bean.BeanUtil
类名称:BeanUtil
方法名:isBean
[英]判断是否为Bean对象
判定方法是是否存在只有一个参数的setXXX方法
[中]判断是否为豆对象
判定方法是是否存在只有一个参数的setXXX方法
代码示例来源:origin: looly/hutool
@Override
public int hash(T t) {
if (null == t || false == BeanUtil.isBean(t.getClass())) {
// 非Bean放在同一子分组中
return 0;
}
final Object value = ReflectUtil.getFieldValue(t, fieldName);
int hash = fieldNameList.indexOf(value);
if (hash < 0) {
fieldNameList.add(value);
return fieldNameList.size() - 1;
} else {
return hash;
}
}
});
代码示例来源:origin: looly/hutool
@Override
public int hash(T t) {
if (null == t || false == BeanUtil.isBean(t.getClass())) {
// 非Bean放在同一子分组中
return 0;
}
final Object value = ReflectUtil.getFieldValue(t, fieldName);
int hash = fieldNameList.indexOf(value);
if (hash < 0) {
fieldNameList.add(value);
return fieldNameList.size() - 1;
} else {
return hash;
}
}
});
代码示例来源:origin: looly/hutool
@Override
protected T convertInternal(Object value) {
if(value instanceof Map || value instanceof ValueProvider || BeanUtil.isBean(value.getClass())) {
//限定被转换对象类型
return BeanCopier.create(value, ReflectUtil.newInstanceIfPossible(this.beanClass), copyOptions).copy();
}
return null;
}
代码示例来源:origin: looly/hutool
@Override
protected T convertInternal(Object value) {
if(value instanceof Map || value instanceof ValueProvider || BeanUtil.isBean(value.getClass())) {
//限定被转换对象类型
return BeanCopier.create(value, ReflectUtil.newInstanceIfPossible(this.beanClass), copyOptions).copy();
}
return null;
}
代码示例来源:origin: looly/hutool
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
protected Map<?, ?> convertInternal(Object value) {
Map map = null;
if(value instanceof Map){
map = MapUtil.createMap(TypeUtil.getClass(this.mapType));
convertMapToMap((Map)value, map);
}else if(BeanUtil.isBean(value.getClass())){
map = BeanUtil.beanToMap(value);
}else{
throw new UnsupportedOperationException(StrUtil.format("Unsupport toMap value type: {}", value.getClass().getName()));
}
return map;
}
代码示例来源:origin: looly/hutool
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
protected Map<?, ?> convertInternal(Object value) {
Map map = null;
if(value instanceof Map){
map = MapUtil.createMap(TypeUtil.getClass(this.mapType));
convertMapToMap((Map)value, map);
}else if(BeanUtil.isBean(value.getClass())){
map = BeanUtil.beanToMap(value);
}else{
throw new UnsupportedOperationException(StrUtil.format("Unsupport toMap value type: {}", value.getClass().getName()));
}
return map;
}
代码示例来源:origin: looly/hutool
if (BeanUtil.isBean(rowType)) {
return new BeanConverter<T>(rowType).convert(value, defaultValue);
代码示例来源:origin: looly/hutool
if (BeanUtil.isBean(rowType)) {
return new BeanConverter<T>(rowType).convert(value, defaultValue);
代码示例来源:origin: looly/hutool
rowMap = (Map) rowBean;
} else if(BeanUtil.isBean(rowBean.getClass())){
if (MapUtil.isEmpty(this.headerAlias)) {
rowMap = BeanUtil.beanToMap(rowBean, new LinkedHashMap<String, Object>(), false, false);
代码示例来源:origin: looly/hutool
rowMap = (Map) rowBean;
} else if(BeanUtil.isBean(rowBean.getClass())){
if (MapUtil.isEmpty(this.headerAlias)) {
rowMap = BeanUtil.beanToMap(rowBean, new LinkedHashMap<String, Object>(), false, false);
代码示例来源:origin: cn.hutool/hutool-all
@Override
public int hash(T t) {
if (null == t || false == BeanUtil.isBean(t.getClass())) {
// 非Bean放在同一子分组中
return 0;
}
final Object value = ReflectUtil.getFieldValue(t, fieldName);
int hash = fieldNameList.indexOf(value);
if (hash < 0) {
fieldNameList.add(value);
return fieldNameList.size() - 1;
} else {
return hash;
}
}
});
代码示例来源:origin: cn.hutool/hutool-all
@Override
protected T convertInternal(Object value) {
if(value instanceof Map || value instanceof ValueProvider || BeanUtil.isBean(value.getClass())) {
//限定被转换对象类型
return BeanCopier.create(value, ReflectUtil.newInstanceIfPossible(this.beanClass), copyOptions).copy();
}
return null;
}
代码示例来源:origin: cn.hutool/hutool-all
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
protected Map<?, ?> convertInternal(Object value) {
Map map = null;
if (value instanceof Map) {
final Type[] typeArguments = TypeUtil.getTypeArguments(value.getClass());
if (null != typeArguments //
&& 2 == typeArguments.length//
&& this.keyType.equals(typeArguments[0]) //
&& this.valueType.equals(typeArguments[1])) {
//对于键值对类型一致的Map对象,不再做转换,直接返回原对象
return (Map) value;
}
map = MapUtil.createMap(TypeUtil.getClass(this.mapType));
convertMapToMap((Map) value, map);
} else if (BeanUtil.isBean(value.getClass())) {
map = BeanUtil.beanToMap(value);
} else {
throw new UnsupportedOperationException(StrUtil.format("Unsupport toMap value type: {}", value.getClass().getName()));
}
return map;
}
代码示例来源:origin: cn.hutool/hutool-all
if (BeanUtil.isBean(rowType)) {
return new BeanConverter<T>(rowType).convert(value, defaultValue);
代码示例来源:origin: cn.hutool/hutool-all
rowMap = (Map) rowBean;
} else if(BeanUtil.isBean(rowBean.getClass())){
if (MapUtil.isEmpty(this.headerAlias)) {
rowMap = BeanUtil.beanToMap(rowBean, new LinkedHashMap<String, Object>(), false, false);
内容来源于网络,如有侵权,请联系作者删除!