Skip to content

Commit

Permalink
完善 com.feilong.json.JsonToJavaConfig.classMap javadoc fix #617
Browse files Browse the repository at this point in the history
  • Loading branch information
venusdrogon committed Nov 13, 2023
1 parent 7792390 commit b79a72c
Showing 1 changed file with 180 additions and 4 deletions.
184 changes: 180 additions & 4 deletions feilong-json/src/main/java/com/feilong/json/JsonToJavaConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,50 @@ public class JsonToJavaConfig extends AbstractConfig{
//---------------------------------------------------------------

/**
* The class map.
* 用来设置复杂自定义对象转换.
*
* <h3>示例:</h3>
*
* <blockquote>
* 有以下两个bean
*
* <pre class="code">
*
* public class MyBean{
*
* private Long id;
*
* private Person person;
*
* <span style="color:green">//setter/getter省略</span>
*
* }
*
* public class Person{
*
* private String name;
*
* private Date dateAttr;
*
* <span style="color:green">//setter/getter省略</span>
* }
*
* 现在需要把这段json 转成MyBean
*
* String json = "{'mybean':{'data':[{'name':'get'}]}}";
*
* 代码写法如下:
*
* Map{@code <String, Class<?>>} classMap = newHashMap();
* classMap.put("data", Person.class);
*
* JsonToJavaConfig jsonToJavaConfig = new JsonToJavaConfig(MyBean.class);
* jsonToJavaConfig.setClassMap(classMap);
*
* MyBean myBean = JsonUtil.toBean(json, jsonToJavaConfig);
* </pre>
*
* </blockquote>
*
* @see com.feilong.lib.json.JsonConfig#setClassMap(Map)
*/
Expand Down Expand Up @@ -252,7 +295,50 @@ public JsonToJavaConfig(Class<?> rootClass, JavaIdentifierTransformer javaIdenti
* @param rootClass
* the root class
* @param classMap
* the class map
* 用来设置复杂自定义对象转换.
*
* <h3>示例:</h3>
*
* <blockquote>
* 有以下两个bean
*
* <pre class="code">
*
* public class MyBean{
*
* private Long id;
*
* private Person person;
*
* <span style="color:green">//setter/getter省略</span>
*
* }
*
* public class Person{
*
* private String name;
*
* private Date dateAttr;
*
* <span style="color:green">//setter/getter省略</span>
* }
*
* 现在需要把这段json 转成MyBean
*
* String json = "{'mybean':{'data':[{'name':'get'}]}}";
*
* 代码写法如下:
*
* Map{@code <String, Class<?>>} classMap = newHashMap();
* classMap.put("data", Person.class);
*
* JsonToJavaConfig jsonToJavaConfig = new JsonToJavaConfig(MyBean.class);
* jsonToJavaConfig.setClassMap(classMap);
*
* MyBean myBean = JsonUtil.toBean(json, jsonToJavaConfig);
* </pre>
*
* </blockquote>
*/
public JsonToJavaConfig(Class<?> rootClass, Map<String, Class<?>> classMap){
super();
Expand Down Expand Up @@ -461,7 +547,52 @@ public void setRootClass(Class<?> rootClass){
}

/**
* Gets the class map.
* 用来设置复杂自定义对象转换.
*
* <h3>示例:</h3>
*
* <blockquote>
* 有以下两个bean
*
* <pre class="code">
*
* public class MyBean{
*
* private Long id;
*
* private Person person;
*
* <span style="color:green">//setter/getter省略</span>
*
* }
*
* public class Person{
*
* private String name;
*
* private Date dateAttr;
*
* <span style="color:green">//setter/getter省略</span>
* }
*
* 现在需要把这段json 转成MyBean
*
* String json = "{'mybean':{'data':[{'name':'get'}]}}";
*
* 代码写法如下:
*
* Map{@code <String, Class<?>>} classMap = newHashMap();
* classMap.put("data", Person.class);
*
* JsonToJavaConfig jsonToJavaConfig = new JsonToJavaConfig(MyBean.class);
* jsonToJavaConfig.setClassMap(classMap);
*
* MyBean myBean = JsonUtil.toBean(json, jsonToJavaConfig);
* </pre>
*
* </blockquote>
*
* @see com.feilong.lib.json.JsonConfig#setClassMap(Map)
*
* @return the classMap
*/
Expand All @@ -470,7 +601,52 @@ public Map<String, Class<?>> getClassMap(){
}

/**
* 设置 class map.
* 用来设置复杂自定义对象转换.
*
* <h3>示例:</h3>
*
* <blockquote>
* 有以下两个bean
*
* <pre class="code">
*
* public class MyBean{
*
* private Long id;
*
* private Person person;
*
* <span style="color:green">//setter/getter省略</span>
*
* }
*
* public class Person{
*
* private String name;
*
* private Date dateAttr;
*
* <span style="color:green">//setter/getter省略</span>
* }
*
* 现在需要把这段json 转成MyBean
*
* String json = "{'mybean':{'data':[{'name':'get'}]}}";
*
* 代码写法如下:
*
* Map{@code <String, Class<?>>} classMap = newHashMap();
* classMap.put("data", Person.class);
*
* JsonToJavaConfig jsonToJavaConfig = new JsonToJavaConfig(MyBean.class);
* jsonToJavaConfig.setClassMap(classMap);
*
* MyBean myBean = JsonUtil.toBean(json, jsonToJavaConfig);
* </pre>
*
* </blockquote>
*
* @see com.feilong.lib.json.JsonConfig#setClassMap(Map)
*
* @param classMap
* the classMap to set
Expand Down

0 comments on commit b79a72c

Please sign in to comment.