Package prezoom.model
Class MethodFactory
- java.lang.Object
-
- prezoom.model.MethodFactory
-
class MethodFactory extends Object
to generate maps that contain all non null filed names, values, getter methods, or setter method of a class. ordered as declared- Author:
- Zhijie Lan
create date: 2020/11/18
-
-
Field Summary
Fields Modifier and Type Field Description private static Map<String,Object>att_mapprivate static ObjectcurrentObjectprivate static Map<String,Method>getter_mapprivate static Map<String,Method>setter_map
-
Constructor Summary
Constructors Constructor Description MethodFactory()
-
Method Summary
Modifier and Type Method Description private static voidgenerateMaps(Object bean)generate all three maps at onesstatic Map<String,Method>getNonNullGetters(Object bean)to generate the map that has all the none null fields name and corresponding getter methodsstatic Map<String,Object>getNonNullProperties(Object bean)to generate the map that has all the none null fields name and corresponding valuesstatic Map<String,Method>getNonNullSetters(Object bean)to generate the map that has all the none null fields name and corresponding setter methodsprivate static Map<String,Object>sortAsDeclaredOrder(Object obj, Map<String,Object> unordered_mp)sorted the field names of the value maps as the declared order of the object classprivate static Map<String,Method>sortAsDeclaredOrder(Map<String,Method> unordered_mp, Object obj)sorted the field names of the method maps as the declared order of the object class
-
-
-
Method Detail
-
getNonNullProperties
public static Map<String,Object> getNonNullProperties(Object bean)
to generate the map that has all the none null fields name and corresponding values- Parameters:
bean- the target object- Returns:
- setter map, key: field names, value: values of fields
-
getNonNullGetters
public static Map<String,Method> getNonNullGetters(Object bean)
to generate the map that has all the none null fields name and corresponding getter methods- Parameters:
bean- the target object- Returns:
- setter map, key: field names, value: getter methods
-
getNonNullSetters
public static Map<String,Method> getNonNullSetters(Object bean)
to generate the map that has all the none null fields name and corresponding setter methods- Parameters:
bean- the target object- Returns:
- setter map, key: field names, value: setter methods
-
generateMaps
private static void generateMaps(Object bean)
generate all three maps at ones- Parameters:
bean- the target objects
-
sortAsDeclaredOrder
private static Map<String,Method> sortAsDeclaredOrder(Map<String,Method> unordered_mp, Object obj)
sorted the field names of the method maps as the declared order of the object class- Parameters:
unordered_mp- the unordered method mapobj- the target object- Returns:
- the ordered method map
-
sortAsDeclaredOrder
private static Map<String,Object> sortAsDeclaredOrder(Object obj, Map<String,Object> unordered_mp)
sorted the field names of the value maps as the declared order of the object class- Parameters:
unordered_mp- the unordered value mapobj- the target object- Returns:
- the ordered value map
-
-