I'm in the process of writing a javadoc Taglet that is intended to be used in the class overview block, and which will render a table describing the validation constraints for the class and the properties in the class. This will initially be used in internal projects, and I'll release the code and open-source it if there is interest in using this.
I'm really just looking for input on whether this is useful, any suggestions, and one long shot request for help on an issue not related to validator.
For the sample, here are the test classes:
Code:
/**
* @att.det.validationConstraints
*/
@ValidStuff(message = "must be valid stuff")
public class Stuff extends BaseStuff {
private int foo;
private String bar;
private Thing thing;
private Thing anotherThing;
public int getFoo() { return foo; }
@Size(min = 3, max = 5)
@Pattern(regexp = "abc.*")
public String getBar() { return bar; }
@Valid
public Thing getThing() { return thing; }
@NotNull
@Valid
public Thing getAnotherThing() { return anotherThing; }
... setters ...
}
public class BaseStuff {
private int junk;
@Min(value = 7)
public int getJunk() { return junk; }
public void setJunk(int junk) { this.junk = junk; }
}
Here is what the output looks like right now (don't know to display this "inline"):
https://imagebin.ca/v/3TFfMSz7tn13You can see the following from that example:
* Any constraints on the entire class don't specify a property name
* Properties with multiple constraints list them on separate lines
* Base class property constraints are treated exactly the same
* If the property is cascading (@Valid is present), it adds "See class <classname>"
The last one probably looks a little dumb, as you'd probably prefer to have that be a link to the class in question. I'd like to figure out how to do that. Some of you might be thinking "duh, just use "{@link <classname>.class}", but you'd be wrong, as taglets are executed after tags are parsed, and it can only generate pure text. There might be a javadoc API that I can use to generate the correct output, but I'm not aware of one.
The table title and column headers are not internationalized, not sure how to do that effectively.
Any comments or suggestions?