Package org.apache.dubbo.common.utils
Class PojoUtils
java.lang.Object
org.apache.dubbo.common.utils.PojoUtils
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.
TODO: exact PojoUtils to scope bean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Objectgeneralize(Object pojo) static Object[]generalize(Object[] objs) static booleanstatic <T> Tconvert map to a specific class instancestatic Object[]static Object[]static Objectstatic Objectstatic <T> voidupdatePropertyIfAbsent(Supplier<T> getterMethod, Consumer<T> setterMethod, T newValue) Update the property if absent
-
Constructor Details
-
PojoUtils
public PojoUtils()
-
-
Method Details
-
generalize
-
realize
-
realize
-
generalize
-
realize
-
realize
-
isPojo
-
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 methodsetterMethod- the setter methodnewValue- the new value- Since:
- 2.7.8
-
mapToPojo
public static <T> T mapToPojo(Map<String, Object> map, Class<T> cls) throws ReflectiveOperationExceptionconvert map to a specific class instance- Type Parameters:
T- the type ofcls- Parameters:
map- map wait for convertcls- the specified class- Returns:
- class instance declare in param
cls - Throws:
ReflectiveOperationException- if the instance creation is failed- Since:
- 2.7.10
-