Bekreth / jetedge

A Java library to take POJO classes and create a stream of randomized instances.
Apache License 2.0
6 stars 8 forks source link

Annotation for standard PojoGenerator actions #120

Open brizzbuzz opened 6 years ago

brizzbuzz commented 6 years ago

What shortcoming will this fix cover

The standard usage of a JetEdge POJO generator goes something as follows

private static PojoGenerator<MyClass> myClassGenerator = new PojoGeneratorBuilder<>(MyClass.class).build()

public static generateMyClass() { 
    return myClassGenerator.generatePojo();
}
public static generateMyClassList(int size) { 
    return myClassGenerator.generatePojoList(10); 
}
public static generateMyClassStream() { 
    return myClassGenerator.generatePojoStream(); 
}

I proposed adding a Lombok inspired annotation to JetEdge along the lines of

@Generator
private static PojoGenerator<MyClass> myClassGenerator = new PojoGeneratorBuilder<>(MyClass.class).build()

That will generate boilerplate code for all standard pojo generation strategies for that generator

Why its important to make this change

Cuts down on boilerplate code needed to access your beautiful new pojo generators

How much time I would invest in making this patch (if I had the free time to do it)

I'd say not very much but when I sat down to make my own annotation for something completely different I ended up finding a bug in Intellij that I had to report so who knows. Realistically not very much