Skip to content

Instantly share code, notes, and snippets.

@gunnarmorling
Created April 25, 2011 12:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gunnarmorling/940438 to your computer and use it in GitHub Desktop.
Save gunnarmorling/940438 to your computer and use it in GitHub Desktop.
HV-431: New approach by removing creational context from ConstraintDef completely
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 ) );
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 ));
@hferentschik
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment