Annotation Type ConditionalPostconditionAnnotation
-
@Documented @Retention(RUNTIME) @Target(ANNOTATION_TYPE) public @interface ConditionalPostconditionAnnotationA meta-annotation that indicates that an annotation E is a conditional postcondition annotation, i.e., E is a type-specialized version ofEnsuresQualifierIforEnsuresQualifierIf.List.- If E is a type-specialized version of
EnsuresQualifierIf, it must have- an element
expressionthat is an array ofStrings, analogous toEnsuresQualifierIf.expression(), and - an element
resultwith the same meaning asEnsuresQualifierIf.result().
- an element
- If E is a type-specialized version of
EnsuresQualifierIf.List, it must have an elementvaluethat is an array of conditional postcondition annotations, analogous toEnsuresQualifierIf.List.value().
The established postcondition P has type specified by the
qualifierfield of this annotation. If the annotation E has elements annotated byQualifierArgument, their values are copied to the arguments (elements) of annotation P with the same names. Different element names may be used in E and P, if aQualifierArgumentin E gives the name of the corresponding element in P.For example, the following code declares a postcondition annotation for the
MinLenqualifier:
The@ConditionalPostconditionAnnotation(qualifier = MinLen.class) @Target({ElementType.METHOD, ElementType.CONSTRUCTOR}) public @interface EnsuresMinLen { String[] expression(); boolean result(); @QualifierArgument("value") int targetValue() default 0;expressionelement holds the expressions to which the qualifier applies andtargetValueholds the value for thevalueargument ofMinLen.The following code then uses the annotation on a method that ensures
fieldto be@MinLen(4)upon returningtrue.@EnsuresMinLenIf(expression = "field", result = true, targetValue = 4") public boolean isFieldBool() { return field == "true" || field == "false"; }- See Also:
EnsuresQualifier,QualifierArgument
- If E is a type-specialized version of
-
-
Required Element Summary
Required Elements Modifier and Type Required Element Description java.lang.Class<? extends java.lang.annotation.Annotation>qualifierThe qualifier that will be established as a postcondition.
-
-
-
Element Detail
-
qualifier
java.lang.Class<? extends java.lang.annotation.Annotation> qualifier
The qualifier that will be established as a postcondition.This element is analogous to
EnsuresQualifierIf.qualifier().
-
-