01: /*******************************************************************************
02: * Portions created by Sebastian Thomschke are copyright (c) 2005-2007 Sebastian
03: * Thomschke.
04: *
05: * All Rights Reserved. This program and the accompanying materials
06: * are made available under the terms of the Eclipse Public License v1.0
07: * which accompanies this distribution, and is available at
08: * http://www.eclipse.org/legal/epl-v10.html
09: *
10: * Contributors:
11: * Sebastian Thomschke - initial implementation.
12: *******************************************************************************/package net.sf.oval.constraint;
13:
14: import java.lang.annotation.Documented;
15: import java.lang.annotation.ElementType;
16: import java.lang.annotation.Retention;
17: import java.lang.annotation.RetentionPolicy;
18: import java.lang.annotation.Target;
19:
20: import net.sf.oval.ConstraintViolation;
21: import net.sf.oval.configuration.annotation.Constraint;
22: import net.sf.oval.constraint.CheckWithCheck.SimpleCheck;
23:
24: /**
25: * Check the value by a method of the same class that takes the value as argument and returns true if valid
26: * and false if invalid<br>
27: *
28: * @author Sebastian Thomschke
29: */
30: @Documented
31: @Retention(RetentionPolicy.RUNTIME)
32: @Target({ElementType.FIELD,ElementType.PARAMETER,ElementType.METHOD,ElementType.TYPE})
33: @Constraint(checkWith=CheckWithCheck.class)
34: public @interface CheckWith {
35: /**
36: * error code passed to the ConstraintViolation object
37: */
38: String errorCode() default "net.sf.oval.constraints.CheckWith";
39:
40: /**
41: * this constraint will be ignored if the value to check is null
42: */
43: boolean ignoreIfNull() default true;
44:
45: /**
46: * message to be used for the ContraintsViolatedException
47: *
48: * @see ConstraintViolation
49: */
50: String message() default "net.sf.oval.constraints.CheckWith.violated";
51:
52: /**
53: * severity passed to the ConstraintViolation object
54: */
55: int severity() default 0;
56:
57: /**
58: * The associated validation profiles.
59: */
60: String[] profiles() default {};
61:
62: /**
63: * Check class to use for validation. If this class is an inner class
64: * it needs be declared as a <b>static</b> class. Otherwise
65: * check instantiation will fail.
66: *
67: * @see net.sf.oval.constraint.CheckWithCheck.SimpleCheck
68: */
69: Class<? extends SimpleCheck> value();
70: }
|