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 * Chris Pheby - inspectInterfaces 013 *******************************************************************************/ 014 package net.sf.oval.guard; 015 016 import java.lang.annotation.Documented; 017 import java.lang.annotation.ElementType; 018 import java.lang.annotation.Retention; 019 import java.lang.annotation.RetentionPolicy; 020 import java.lang.annotation.Target; 021 022 /** 023 * This annotation needs to be applied to classes where 024 * OVal's programming by contract features shall be used.<br> 025 * <br> 026 * The GuardAspect will weave the required AOP code into all 027 * classes annotated with @Guarded. 028 * 029 * @author Sebastian Thomschke 030 */ 031 @Documented 032 @Retention(RetentionPolicy.RUNTIME) 033 @Target(ElementType.TYPE) 034 public @interface Guarded 035 { 036 /** 037 * Automatically apply field constraints to the corresponding parameters of 038 * constructors declared within the same class. 039 * A corresponding parameter is a parameter with the same name and type as the field. 040 */ 041 boolean applyFieldConstraintsToConstructors() default false; 042 043 /** 044 * Automatically apply field constraints to the single parameter of the corresponding 045 * setter methods declared within the same class. 046 * A corresponding setter method is a method following the JavaBean convention and 047 * its parameter has as the same type as the field. 048 */ 049 boolean applyFieldConstraintsToSetters() default false; 050 051 /** 052 * Declares if parameter values of constructors and methods are expected to be not null. 053 * This can be weakened by using the @net.sf.oval.constraint.exclusion.Nullable annotation on specific parameters. 054 */ 055 boolean assertParametersNotNull() default false; 056 057 /** 058 * Declares if invariants are automatically checked after constructor execution and 059 * prior and after calls to non-private methods. 060 */ 061 boolean checkInvariants() default true; 062 063 /** 064 * Declares if annotations can be applied to interfaces that this class implements - supporting a documentation 065 * function 066 */ 067 boolean inspectInterfaces() default false; 068 }