Class PojoUtils

java.lang.Object
org.apache.dubbo.common.utils.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.

TODO: exact PojoUtils to scope bean

  • Constructor Details

    • PojoUtils

      public PojoUtils()
  • Method Details

    • generalize

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

      public static Object[] realize(Object[] objs, Class<?>[] types)
    • realize

      public static Object[] realize(Object[] objs, Class<?>[] types, Type[] gtypes)
    • generalize

      public static Object generalize(Object pojo)
    • realize

      public static Object realize(Object pojo, Class<?> type)
    • realize

      public static Object realize(Object pojo, Class<?> type, Type genericType)
    • 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
      Type Parameters:
      T - the value type
      Parameters:
      getterMethod - the getter method
      setterMethod - the setter method
      newValue - the new value
      Since:
      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
      Type Parameters:
      T - the type of cls
      Parameters:
      map - map wait for convert
      cls - the specified class
      Returns:
      class instance declare in param cls
      Throws:
      ReflectiveOperationException - if the instance creation is failed
      Since:
      2.7.10