This commit is contained in:
Looly
2024-09-24 03:52:10 +08:00
parent 1b92f58bae
commit d8a7b9b440
23 changed files with 477 additions and 134 deletions

View File

@@ -38,6 +38,54 @@ public interface BeanDesc extends Serializable {
*/
Map<String, PropDesc> getPropMap(final boolean ignoreCase);
/**
* 获取Bean属性数量
*
* @return 字段数量
*/
default int size(){
return getPropMap(false).size();
}
/**
* 是否为空
*
* @return 是否为空
*/
default boolean isEmpty(){
return size() == 0;
}
/**
* 是否有可读字段即有getter方法或public字段
*
* @param checkTransient 是否检查transient字段true表示检查false表示不检查
* @return 是否有可读字段
*/
default boolean isReadable(final boolean checkTransient){
for (final Map.Entry<String, PropDesc> entry : getPropMap(false).entrySet()) {
if (entry.getValue().isReadable(checkTransient)) {
return true;
}
}
return false;
}
/**
* 是否有可写字段即有setter方法或public字段
*
* @param checkTransient 是否检查transient字段true表示检查false表示不检查
* @return 是否有可写字段
*/
default boolean isWritable(final boolean checkTransient){
for (final Map.Entry<String, PropDesc> entry : getPropMap(false).entrySet()) {
if (entry.getValue().isWritable(checkTransient)) {
return true;
}
}
return false;
}
/**
* 获取字段属性列表
*

View File

@@ -311,7 +311,11 @@ public class TypeUtil {
* @return {@link ParameterizedType}
* @since 4.5.2
*/
public static ParameterizedType toParameterizedType(final Type type, final int interfaceIndex) {
public static ParameterizedType toParameterizedType(Type type, final int interfaceIndex) {
if(type instanceof TypeReference){
type = ((TypeReference<?>) type).getType();
}
if (type instanceof ParameterizedType) {
return (ParameterizedType) type;
}