Skip to content
Discussion options

You must be logged in to vote

Try this:

	static void createPojo(Class<?> clazz) {
		UnitSourceGenerator sourceGenerator = UnitSourceGenerator.create("my.cool.package");
		String clazzSimpleName = clazz.getSimpleName();

		ClassSourceGenerator classSourceGenerator = ClassSourceGenerator.create(TypeDeclarationSourceGenerator
                        .create(clazzSimpleName));

        Arrays.stream(clazz.getDeclaredFields())
                .forEach(field -> {
                	if (field.getType().getName().startsWith("java.lang")) {
                		classSourceGenerator
                        	.addField(VariableSourceGenerator.create(field.getType().getSimpleName() + " " +  field.getName())
                            …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@fjakop
Comment options

Answer selected by fjakop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants