Antonio Goncalves created FORGE-1618:
----------------------------------------
Summary: 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
Components: Scaffold
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(URL url) {
}
@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(URL url) {
}
@Override
public boolean isValid(String value, ConstraintValidatorContext context) {
return false;
}
}
{code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:
http://www.atlassian.com/software/jira