bryan.dollery wrote:
As there's been no error, and the code isn't creating an error object, and (from your post above) it does seem to be configuring the ConstraintViolation, perhaps it should just be called configureWithPath(), and configureWithMessageTemplate(). And, perhaps these two things should be kept separate, or perhaps overloaded simply as configure() which could take one, or the other, or both?
configure is too vague as we intend to extend the API in future revisions of the spec. We need to convey in the name that:
- we override the messageTemplate and not the message for example
- we need to say that this leads to the creation of a ConstraintViolation
buildConstraintViolationWithMessageTemplate (long) / addConstraintViolation
buildConstraintViolationWithTemplate / addConstraintViolation
buildViolationReportWithMessageTemplate / addViolationReport or addReport
buildViolationReportWithTemplate / addViolationReport or addReport
?
Quote:
And, if you don't mind me whinging on about names for a minute, why is it 'subNode'? I mean, I get it, but isn't really just node you're adding? Surely the 'sub' bit is down to context? :-)
The reason I used subNode and not node is because this path is relative to the path of the constraint currently validated and I wanted to convey this notion.
I could be convinced easily convinced "node" is a better name :)
Quote:
Refactoring: A colleage suggested to me last week that we might use cglib in a similar way to Mockito and Easymock, to create a proxy that can return the java.lang.reflect.Method of the method who's path we want. Something like:
Code:
Method streetMethod = new PathGenerator(Address).getStreet();
I haven't looked into it in detail yet, but it seems like a solid approach. From the method you could generate a string, if that's what you needed.
Nope. Though of it. It does not work for private methods or fields.
The only current solution is to use what JPA 2 is using ie generating a metamodel using an AnnotationProcessor. Let's see if that sticks before jumping this bandwagon.
Quote:
Also, if you don't mind me saying -- that's a dreadful implementation of a French postcode validator :-p
Well, it's valid :)