I have following information in JSON format.
[
{
"name": "A",
"value": {
"isValueApplicable": "true"
}
},
{
"name": "B",
"parameters": [
{
"name": "x",
"isMandatory": "true"
},
{
"name": "y",
"isMandatory": "true"
}
]
},
{
"name": "C",
"parameters": [
{
"name": "x",
"isMandatory": "true"
},
{
"name": "y",
"isMandatory": "false"
}
]
}
]
What I want is, a class is created with following methods :
public Structure getA (String value) {
}
public Structure getB (String xValue, String yValue) {
}
public Structure getC (String xValue) {
}
public Structure getC (String xValue, String yValue) {
}
The important part here is, these methods should be created dynamically based on the information given in JSON. So, for A only value is applicable. For B, both values x and y are needed. But for C, only x value is mandatory and user can provide value for y, hence the 2 different methods.
Q. Is it possible in java to generate the methods at compile time after reading the JSON, like if the parameters are mandatory i will create method with those many parameters. If the value if not applicable then i will create method without any parameter.