I am looking for an API that will generate me source code that will generate objects equal to those that I passed to the library.
public static void main(String[] args) {
int[] arr = new int[3];
arr[0] = 3;
arr[1] = 4;
arr[2] = 5;
MagicCode.generateCode(arr);
}
Gotta generate
int[] arr = new int[3];
arr[0] = 3;
arr[1] = 4;
arr[2] = 5;
or
int[] arr = new int[] { 3, 4, 5 };
So, I want to pass an object and get the Java Source Code , which will create an object equal to my original object.
This should work not only for primitive types, but also for my own objects:
public static void main(String[] args) {
Condition condition = new Condition();
condition.setNumber(2);
MagicCode.generateCode(condition);
}
Gotta generate
Condition c1 = new Condition();
c1.setNumber(2);
as a string that can then be inserted into the Java source file.
EDIT
I do not want to get around the compiler.
, . , 1000 . - /. 1000 , .
, #toString(), Java . 1000 , .