Created
April 25, 2011 12:20
-
-
Save gunnarmorling/940438 to your computer and use it in GitHub Desktop.
HV-431: New approach by removing creational context from ConstraintDef completely
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ConstraintMapping mapping = new ConstraintMapping(); | |
mapping.type( Marathon.class ) | |
.property( "name", METHOD ) | |
.constraint( new SizeDef() | |
.message( "name too short" ) | |
.min( 3 ) ) | |
.constraint( new NotNullDef() ) | |
.property( "numberOfHelpers", FIELD ) | |
.constraint( new MinDef().value( 1 ) ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ConstraintMapping mapping = new ConstraintMapping(); | |
mapping.type( Marathon.class ) | |
.constraint( GenericConstraintDef.from( MarathonConstraint.class ) | |
.param( "minRunner", 1 ) ) | |
.property( "name", METHOD ) | |
.constraint( new SizeDef() | |
.message( "name too short" ) | |
.min( 3 )); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sure, we cannot prevent it, but I have the "feeling" it is less likely this way :-)
I actually like the ConstraintDef.create better. It might be a little longer, but it seems indeed more unified.