Annotation Interface Implementation.Validator
- Enclosing class:
Implementation
A class annotated with Implementation.Validator
will be automatically searched for and instantiated as a
Validator
by guice.
Example
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
@Constraint(String.class)
public @interface MaxString {
int value();
String message() default "The given String is too long";
}
@Validator(annotation = MaxString.class)
public class MaxStringLengthValidator implements Validator {
@Override
public boolean apply(Object argument, Object annotation, InvocationContext<? context) {
MaxString maxString = (MaxString) annotation;
return String.valueOf(argument).length() < maxString.value();
}
}
-
Required Element Summary
Required ElementsModifier and TypeRequired ElementDescription@NotNull Class
<? extends Annotation> Gets the annotation theValidator
should be mapped to.