001 /******************************************************************************* 002 * Portions created by Sebastian Thomschke are copyright (c) 2005-2011 Sebastian 003 * Thomschke. 004 * 005 * All Rights Reserved. This program and the accompanying materials 006 * are made available under the terms of the Eclipse Public License v1.0 007 * which accompanies this distribution, and is available at 008 * http://www.eclipse.org/legal/epl-v10.html 009 * 010 * Contributors: 011 * Sebastian Thomschke - initial implementation. 012 *******************************************************************************/ 013 package net.sf.oval.guard; 014 015 import java.lang.annotation.Documented; 016 import java.lang.annotation.ElementType; 017 import java.lang.annotation.Retention; 018 import java.lang.annotation.RetentionPolicy; 019 import java.lang.annotation.Target; 020 021 /** 022 * Before the annotated method is executed the expression is evaluated.<br> 023 * This evaluation happens <u>after</u> the single parameter constraints were validated 024 * and only if no parameter constraint violations were detected. 025 * <br> 026 * If constraint violations occur, the annotated method will not be executed 027 * instead it will throw a ConstraintsViolatedException exception. 028 * 029 * @author Sebastian Thomschke 030 */ 031 @Documented 032 @Retention(RetentionPolicy.RUNTIME) 033 @Target({ElementType.METHOD}) 034 public @interface Pre 035 { 036 037 /** 038 * error code passed to the ConstraintViolation object 039 */ 040 String errorCode() default "net.sf.oval.guard.Pre"; 041 042 /** 043 * formula in the given expression language describing the constraint. the formula must return true if the constraint is satisfied. 044 * <br> 045 * available variables are:<br> 046 * <b>_this</b> -> the validated bean<br> 047 * <b>_args[]</b> -> the current parameter values<br> 048 * additionally variables matching the parameter names are available<br> 049 */ 050 String expr(); 051 052 /** 053 * the expression language that is used 054 */ 055 String lang(); 056 057 /** 058 * message to be used for the ContraintsViolatedException 059 * 060 * @see net.sf.oval.exception.ConstraintsViolatedException 061 */ 062 String message() default "net.sf.oval.guard.Pre.violated"; 063 064 /** 065 * The associated constraint profiles. 066 */ 067 String[] profiles() default {}; 068 069 /** 070 * severity passed to the ConstraintViolation object 071 */ 072 int severity() default 0; 073 }