Package prezoom.model

Class 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

    • Constructor Detail

      • MethodFactory

        MethodFactory()
    • 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 map
        obj - 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 map
        obj - the target object
        Returns:
        the ordered value map