]
Antonio Goncalves updated FORGE-1618:
-------------------------------------
Parent Issue: FORGE-1926 (was: FORGE-1615)
Command constraint-new-validator to create a new validator
implementation
-------------------------------------------------------------------------
Key: FORGE-1618
URL:
https://issues.jboss.org/browse/FORGE-1618
Project: Forge
Issue Type: Sub-task
Security Level: Public(Everyone can see)
Components: Java EE
Affects Versions: 2.1.1.Final
Reporter: Antonio Goncalves
Fix For: 2.x Future
An existing constraint can have several implementations of different types. The following
commands will create two implementations of the {{Max}} constraints: one for type
{{Number}} and one for {{String}} :
{code}
constraint-new-validator --named MaxValidatorForNumber --type Number --targetConstraint
Max
constraint-new-validator --named MaxValidatorForString --type String --targetConstraint
Max
{code}
The generated code would look like this for Number :
{code}
public class MaxValidatorForString implements ConstraintValidator<Max, Number> {
@Override
public void initialize(Max constraint) {
}
@Override
public boolean isValid(Number value, ConstraintValidatorContext context) {
return false;
}
}
{code}
And like that for String :
{code}
public class MaxValidatorForString implements ConstraintValidator<Max, String> {
@Override
public void initialize(Max constraint) {
}
@Override
public boolean isValid(String value, ConstraintValidatorContext context) {
return false;
}
}
{code}