Random data generator in java
i have to fill every property of a given object with a random value.
All properties are native java type (int, double, String, etc)
I canuse reflection
I can use Spring DirectFieldAccessor
I don't want to re-invent the square wheel so I prefer to ask.
For now I came up with this : Get all properties name with
Field field : myObject.getClass().getDeclaredFields()
Iterate over those field and get their class.
Then use a giant switch statement for each known native java type and
generate a random value.
What do you think?
No comments:
Post a Comment