|
Currently the constraint type needs to be specified twice when using GenericConstraintDef:
new GenericConstraintDef<MyConstraint>( MyConstraint.class )
.param( "myParam", 2 );
This could be avoided e.g. by providing a static factory method which leverages type inference:
GenericConstraintDef.getInstance( MyConstraint.class )
.param( "myParam", 2 );
Or we provide a parameterless constructor used by anonymous subclasses and retrieve the value of the type parameter internally:
new GenericConstraintDef<LuggageCountMatchesPassengerCount>(){}
.param( "myParam", 2 );
The latter would break compatability though if we want to enforce subclassing by making GenericConstraintDef an anonymous class.
|