类 PojoUtils


  • public class PojoUtils
    extends Object
    PojoUtils. Travel object deeply, and convert complex type to simple type.

    Simple type below will be remained:

    • Primitive Type, also include String, Number(Integer, Long), Date
    • Array of Primitive Type
    • Collection, eg: List, Map, Set etc.

    Other type will be covert to a map which contains the attributes and value pair of object.

    • 构造器详细资料

      • PojoUtils

        public PojoUtils()
    • 方法详细资料

      • generalize

        public static Object[] generalize​(Object[] objs)
      • generalize

        public static Object generalize​(Object pojo)
      • isPojo

        public static boolean isPojo​(Class<?> cls)
      • updatePropertyIfAbsent

        public static <T> void updatePropertyIfAbsent​(Supplier<T> getterMethod,
                                                      Consumer<T> setterMethod,
                                                      T newValue)
        Update the property if absent
        类型参数:
        T - the value type
        参数:
        getterMethod - the getter method
        setterMethod - the setter method
        newValue - the new value
        从以下版本开始:
        2.7.8
      • mapToPojo

        public static <T> T mapToPojo​(Map<String,​Object> map,
                                      Class<T> cls)
                               throws ReflectiveOperationException
        convert map to a specific class instance
        类型参数:
        T - the type of cls
        参数:
        map - map wait for convert
        cls - the specified class
        返回:
        class instance declare in param cls
        抛出:
        ReflectiveOperationException - if the instance creation is failed
        从以下版本开始:
        2.7.10