I'm in search of a tool or method to analyze standard JavaBeans source code (featuring getters and setters) and create json descriptors using tools like grunt
or ant
, or any other suitable option. Here's an example:
FilterBean.java:
package com.abc.beans;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
public class FilterBean implements Serializable {
private static final long serialVersionUID = 7490361447912259765L;
private Map<String, List<LabelValueBean>> filterMapList;
private String name;
public Map<String, List<LabelValueBean>> getFilterMapList() {
return this.filterMapList;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
}
LabelValueBean.java:
package com.abc.beans;
import java.io.Serializable;
import java.util.List;
public class LabelValueBean implements Serializable {
private static final long serialVersionUID = 1237198378921379812L;
private String label;
private Integer id;
private List<String> values;
public String getLabel() {
return this.label;
}
public void setLabel(String label) {
this.label = label;
}
public Integer getId() {
return this.idlabel;
}
public List<String> getValues() {
return this.values;
}
public void setValues(List<String> values) {
this.values = values;
}
}
The resulting output would resemble the following:
com.abc.beans.FilterBean.json:
{
"name" : {
"type" : "String",
"setter" : true
},
"filterMapList" : {
"type" : "Map",
"innerType" : "com.abc.beans.LabelValueBean",
"setter" : false
}
}
com.abc.beans.LabelValueBean.json:
{
"label" : {
"type" : "String",
"setter" : true
},
"values" : {
"type" : "Array",
"innerType" : "String",
"setter" : true
},
"id" : {
"type" : "Integer",
"setter" : false
}
}
Any suggestions?