类 MapUtil


  • public final class MapUtil
    extends Object
    This util class can be used for automatic conversion between dictionaries/maps and objects P.S: If your data cannot be transferred, please contact me via email by sending the data's detail to theodore0126@outlook.com.
    作者:
    TheodoreHills
    • 方法详细资料

      • SetMap

        public static Map<String,​Object> SetMap​(Object obj)
                                               throws Exception
        Dynamically convert object to dictionary/map
        参数:
        obj - Objects that need to be converted to Map
        返回:
        Converted HashMap
        抛出:
        Exception - Any Exception could be generated while converting
      • SetObject

        public static void SetObject​(Map<String,​Object> map,
                                     Object obj)
        Convert Map to Object
        参数:
        map - Map data to be convert
        obj - Target object should be explicitly given to a special instantiated object
      • GetFieldValue

        public static String GetFieldValue​(String fieldName,
                                           Object obj)
                                    throws Exception
        Get the specified field value, equivalent to obj.getFieldName
        参数:
        fieldName - Field name
        obj - object
        返回:
        A string of the object corresponding to the object value
        抛出:
        Exception - Abnormalities that may appear, such as java.lang.NullPointerException, etc.
      • SetFieldValue

        public static void SetFieldValue​(String fieldName,
                                         Object obj,
                                         Object fieldValue)
                                  throws Exception
        Set the specified field value, which is equivalent to obj.setFieldName(fieldValue)
        参数:
        fieldName - Field name
        obj - The object will be set
        fieldValue - Field Value
        抛出:
        Exception - Any Exception could be generated while converting