类 Beans

java.lang.Object
net.apexes.commons.lang.Beans

public final class Beans extends Object
作者:
HeDYn
  • 方法详细资料

    • setPropertyValue

      public static void setPropertyValue(Object bean, String propertyName, Object value) throws Exception
      设置bean对象的可写属性值,相当于调用属性对应的setter方法
      参数:
      bean -
      propertyName -
      value -
      抛出:
      Exception
    • getPropertyValue

      public static Object getPropertyValue(Object bean, String propertyName) throws Exception
      获取bean对象的可读属性值,相当于调用属性对应的getter方法
      参数:
      bean -
      propertyName - 属性名称
      返回:
      抛出:
      NoSuchMethodException
      Exception
    • getPropertiesValues

      public static Map<String,Object> getPropertiesValues(Object bean)
      返回包含指定对象的所有可读属性及值的Map,属性名称为key,属性值为value。 返回的Map中只包含有getter方法的属性。
      参数:
      bean -
      返回:
    • copier

      public static Beans.BeanCopier copier()
      返回:
    • copyProperties

      public static void copyProperties(Object source, Object target, String... ignoreProperties) throws Exception
      将一个对象的属性值赋给另一个对象的相同的属性 这两个对象必须都符合javaBean的标准
      参数:
      source - 要赋值的源对象
      target - 被赋值的目标对象
      ignoreProperties - 被忽略赋值的属性数组
      抛出:
      Exception
    • copyProperties

      public static void copyProperties(Object source, Object target, Beans.FieldConverter converter, String... ignoreProperties) throws Exception
      将一个对象的属性值赋给另一个对象的相同的属性 这两个对象必须都符合javaBean的标准
      参数:
      source -
      target -
      source - 要赋值的源对象
      target - 被赋值的目标对象
      converter -
      ignoreProperties - 被忽略赋值的属性数组
      抛出:
      Exception
    • capitalize

      public static String capitalize(String name)
      获取属性名称对应的不含set、get、is前缀的方法名称(按JavaBean规范)。与uncapitalize(String)互反
      参数:
      name -
      返回:
    • uncapitalize

      public static String uncapitalize(String name)
      获取与不含set、get、is前缀的方法名称对应的属性(按JavaBean规范)。与capitalize(String)互反
      参数:
      name -
      返回:
    • isAccessorPresent

      public static boolean isAccessorPresent(String prefix, String property, Class<?> bean)
    • getAccessor

      public static Method getAccessor(String prefix, String property, Class<?> bean)