Package com.aspectran.utils
Class BeanTypeUtils
java.lang.Object
com.aspectran.utils.BeanTypeUtils
BeanTypeUtils provides methods that allow simple, reflective access to
JavaBeans style properties. Methods are provided for all simple types.
This has been decoupled from BeanUtils.
Created: 2025-02-19
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Class
<?> getClassPropertyTypeForGetter
(Class<?> type, String name) Returns the class that the getter will return when reading a property value.static Class
<?> getClassPropertyTypeForSetter
(Class<?> type, String name) Returns the class that the setter expects to receive as a parameter when setting a property value.static Class
<?> getIndexedType
(Object bean, String indexedName) static Object
getProperty
(Class<?> type, String name) Invokes the static method of the specified class to get the bean property value.static Class
<?> getPropertyTypeForGetter
(Object bean, String name) Returns the class that the getter will return when reading a property value.static Class
<?> getPropertyTypeForSetter
(Object bean, String name) Returns the class that the setter expects to receive as a parameter when setting a property value.static boolean
hasReadableProperty
(Class<?> type, String name) static boolean
hasStaticReadableProperty
(Class<?> type, String name) static boolean
hasStaticWritableProperty
(Class<?> type, String name) static boolean
hasWritableProperty
(Class<?> type, String name) static void
setProperty
(Class<?> type, String name, Object value) Invokes the static method of the specified class to get the bean property value.
-
Constructor Details
-
BeanTypeUtils
public BeanTypeUtils()
-
-
Method Details
-
getProperty
Invokes the static method of the specified class to get the bean property value.- Parameters:
type
- the class for which to lookupname
- the property name- Returns:
- the property value (as an Object)
- Throws:
InvocationTargetException
- if the property accessor method throws an exception
-
setProperty
public static void setProperty(Class<?> type, String name, Object value) throws InvocationTargetException Invokes the static method of the specified class to get the bean property value.- Parameters:
type
- the class for which to lookupname
- the property namevalue
- the value to which this property is to be set- Throws:
InvocationTargetException
- if the property accessor method throws an exception
-
getPropertyTypeForGetter
public static Class<?> getPropertyTypeForGetter(@NonNull Object bean, String name) throws NoSuchMethodException Returns the class that the getter will return when reading a property value.- Parameters:
bean
- the bean to checkname
- the name of the property- Returns:
- the type of the property
- Throws:
NoSuchMethodException
- if an accessor method for this property cannot be found
-
getClassPropertyTypeForGetter
public static Class<?> getClassPropertyTypeForGetter(Class<?> type, @NonNull String name) throws NoSuchMethodException Returns the class that the getter will return when reading a property value.- Parameters:
type
- the class to checkname
- the name of the property- Returns:
- the type of the property
- Throws:
NoSuchMethodException
- if an accessor method for this property cannot be found
-
getPropertyTypeForSetter
public static Class<?> getPropertyTypeForSetter(@NonNull Object bean, String name) throws NoSuchMethodException Returns the class that the setter expects to receive as a parameter when setting a property value.- Parameters:
bean
- the bean to checkname
- the name of the property- Returns:
- the type of the property
- Throws:
NoSuchMethodException
- if an accessor method for this property cannot be found
-
getClassPropertyTypeForSetter
public static Class<?> getClassPropertyTypeForSetter(Class<?> type, @NonNull String name) throws NoSuchMethodException Returns the class that the setter expects to receive as a parameter when setting a property value.- Parameters:
type
- The class to checkname
- the name of the property- Returns:
- the type of the property
- Throws:
NoSuchMethodException
- if an accessor method for this property cannot be found
-
getIndexedType
public static Class<?> getIndexedType(Object bean, @NonNull String indexedName) throws InvocationTargetException - Throws:
InvocationTargetException
-
hasReadableProperty
-
hasWritableProperty
-
hasStaticReadableProperty
-
hasStaticWritableProperty
-