类 MapUtil
- java.lang.Object
-
- cn.vorbote.commons.MapUtil
-
public class MapUtil extends Object
This util class can be used for automatic conversion between dictionaries/maps and objects- 从以下版本开始:
- 0.0.1.PRE
- 作者:
- vorbote
-
-
构造器概要
构造器 构造器 说明 MapUtil()
-
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static StringGetFieldValue(String fieldName, Object obj)Get the specified field value, equivalent toobj.getFieldNamestatic voidSetFieldValue(String fieldName, Object obj, Object fieldValue)Set the specified field value, which is equivalent toobj.setFieldName(fieldValue)static Map<String,Object>SetMap(Object obj)Dynamically convert object to dictionary/mapstatic voidSetObject(Map<String,Object> map, Object obj)Convert Map to Object
-
-
-
方法详细资料
-
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 convertobj- 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 toobj.getFieldName- 参数:
fieldName- Field nameobj- object- 返回:
- A string of the object corresponding to the object value
- 抛出:
Exception- Abnormalities that may appear, such asjava.lang.NullPointerException, etc.
-
SetFieldValue
public static void SetFieldValue(String fieldName, Object obj, Object fieldValue) throws Exception
Set the specified field value, which is equivalent toobj.setFieldName(fieldValue)- 参数:
fieldName- Field nameobj- The object will be setfieldValue- Field Value- 抛出:
Exception- Any Exception could be generated while converting
-
-