[hibernate-issues] [Hibernate-JIRA] Commented: (HV-404) Simplify creation of ConstraintDef derivations

Gunnar Morling (JIRA) noreply at atlassian.com
Sat Dec 4 13:36:13 EST 2010


    [ http://opensource.atlassian.com/projects/hibernate/browse/HV-404?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=39292#action_39292 ] 

Gunnar Morling commented on HV-404:
-----------------------------------

I pushed a first draft to https://github.com/gunnarmorling/hibernate-validator/tree/simplified_constraint_defs

> Simplify creation of ConstraintDef derivations
> ----------------------------------------------
>
>                 Key: HV-404
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-404
>             Project: Hibernate Validator
>          Issue Type: Improvement
>          Components: engine
>    Affects Versions: 4.1.0.Final
>            Reporter: Gunnar Morling
>            Assignee: Hardy Ferentschik
>
> When working with the programmatic constraint declaration API one typically creates a constraint definition type (derivation of ConstraintDef) for each constraint type.
> In its current form the API requires that in each such ConstraintDef sub-type the methods message(), payload() and groups() are overridden to have the fluent invocation style working properly. If for instance message() were not overridden in SizeDef, invoking this method would return the type ConstraintDef, hindering to call later on a specific SizeDef member such as min().
> This can be improved by making ConstraintDef a so called self referential type as follows:
> {code:java} 
> public abstract class ConstraintDef<C extends ConstraintDef<C, A>, A extends Annotation> {
>     //...
>     public C message(String message) {
>         //...
>     }
> }
> {code} 
> That way overriding said methods in concrete definition types is not necessary any more while still allowing the fluent invocation style, as message() would return SizeDef when called on a SizeDef instance.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list