Class BeanTypeUtils

java.lang.Object
com.aspectran.utils.BeanTypeUtils

public abstract class BeanTypeUtils extends Object
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 Details

    • BeanTypeUtils

      public BeanTypeUtils()
  • Method Details

    • getProperty

      public static Object getProperty(Class<?> type, String name) throws InvocationTargetException
      Invokes the static method of the specified class to get the bean property value.
      Parameters:
      type - the class for which to lookup
      name - 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 lookup
      name - the property name
      value - 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 check
      name - 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 check
      name - 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 check
      name - 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 check
      name - 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

      public static boolean hasReadableProperty(Class<?> type, String name)
    • hasWritableProperty

      public static boolean hasWritableProperty(Class<?> type, String name)
    • hasStaticReadableProperty

      public static boolean hasStaticReadableProperty(Class<?> type, String name)
    • hasStaticWritableProperty

      public static boolean hasStaticWritableProperty(Class<?> type, String name)