-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathGenerateExample.java
More file actions
30 lines (27 loc) · 1.01 KB
/
GenerateExample.java
File metadata and controls
30 lines (27 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package org.example;
import org.example.generator.Generator;
import java.lang.reflect.Field;
public class GenerateExample {
public static void main(String[] args) {
var gen = new Generator();
try {
int depth = 0;
Object generated = gen.generateValueOfType(org.example.classes.Cart.class, depth);
if (generated == null) {
System.out.println("Generated object is null");
return;
}
System.out.println("Generated " + generated);
System.out.println("With attributes:");
Field[] fields = generated.getClass().getDeclaredFields();
for (Field field : fields) {
field.setAccessible(true);
System.out.println(
"Field " + field.getName() + " with type:" + field.getType() + " and value:" + field.get(generated)
);
}
} catch (Throwable e) {
throw new RuntimeException(e);
}
}
}