net.sf.oval.constraint.AssertFieldConstraints Maven / Gradle / Ivy
/*******************************************************************************
* Portions created by Sebastian Thomschke are copyright (c) 2005-2011 Sebastian
* Thomschke.
*
* All Rights Reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sebastian Thomschke - initial implementation.
*******************************************************************************/
package net.sf.oval.constraint;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import net.sf.oval.configuration.annotation.Constraint;
import net.sf.oval.configuration.annotation.Constraints;
/**
* Check if the value satisfies the constraints defined for the specified field.
*
* @author Sebastian Thomschke
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.PARAMETER, ElementType.METHOD})
@Constraint(checkWith = AssertFieldConstraintsCheck.class)
public @interface AssertFieldConstraints
{
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.PARAMETER, ElementType.METHOD})
@Constraints
public @interface List
{
/**
* The AssertFieldConstraints constraints.
*/
AssertFieldConstraints[] value();
/**
* Formula returning true
if this constraint shall be evaluated and
* false
if it shall be ignored for the current validation.
*
* Important: The formula must be prefixed with the name of the scripting language that is used.
* E.g. groovy:_this.amount > 10
*
* Available context variables are:
* _this -> the validated bean
* _value -> the value to validate (e.g. the field value, parameter value, method return value,
* or the validated bean for object level constraints)
*/
String when() default "";
}
/**
* The class in which the field is declared. If omitted the current class and it's super
* classes are searched for a field with the given name.
* The default value Void.class means the current class.
*/
Class< ? > declaringClass() default Void.class;
/**
* The associated constraint profiles.
*/
String[] profiles() default {};
/**
* Name of the field. If not specified, the constraints of the field with the same name as
* the annotated constructor/method parameter are applied.
*/
String value() default "";
/**
* Formula returning true
if this constraint shall be evaluated and
* false
if it shall be ignored for the current validation.
*
* Important: The formula must be prefixed with the name of the scripting language that is used.
* E.g. groovy:_this.amount > 10
*
* Available context variables are:
* _this -> the validated bean
* _value -> the value to validate (e.g. the field value, parameter value, method return value,
* or the validated bean for object level constraints)
*/
String when() default "";
}