01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: * $Header:$
18: */
19: package org.apache.beehive.controls.api.bean;
20:
21: import java.lang.annotation.RetentionPolicy;
22: import java.lang.annotation.Retention;
23: import java.lang.annotation.ElementType;
24: import java.lang.annotation.Target;
25:
26: /**
27: * AnnotationConstraints defines meta-annotations that allow
28: * specification of additional constraints that aren't
29: * expressible using J2SE 5.0 meta-annotations.
30: *
31: * Actual enforcement of these semantics is implementation dependent.
32: * An <code>apt</code>-based reference implementation is provided by
33: * {@link org.apache.beehive.controls.runtime.bean.AnnotationConstraintValidator}.
34: *
35: * @see org.apache.beehive.controls.runtime.bean.AnnotationConstraintValidator
36: */
37: public interface AnnotationConstraints {
38: /**
39: * Defines a number of simple constraints on the way annotation members
40: * can be used together.
41: *
42: * @see MembershipRule
43: */
44: public enum MembershipRuleValues {
45: AT_LEAST_ONE, AT_MOST_ONE, EXACTLY_ONE, ALL_IF_ANY
46: }
47:
48: /**
49: * Provides a mechanism for enforcing constraints between members of
50: * an annotation (such a mechanism is absent from J2SE 5.0; for example,
51: * given an annotation with members 'a' and 'b' there is no way to say
52: * that they are mutually exclusive).
53: *
54: * @see MembershipRuleValues
55: */
56: @Target({ElementType.ANNOTATION_TYPE})
57: @Retention(RetentionPolicy.RUNTIME)
58: public @interface MembershipRule {
59: /** Required, the membership rule.*/
60: MembershipRuleValues value();
61:
62: /** Optional list of member names to apply rule against. Empty array implies all members. */
63: String[] memberNames() default {};
64: }
65:
66: /**
67: * Defines whether the annotation decorated by this
68: * annotation can overriden externally (a marker interface).
69: */
70: @Target({ElementType.ANNOTATION_TYPE})
71: @Retention(RetentionPolicy.RUNTIME)
72: public @interface AllowExternalOverride {
73: }
74:
75: /**
76: * Specifies the version of the control runtime required by this annotation.
77: */
78: @Target({ElementType.ANNOTATION_TYPE,ElementType.METHOD})
79: @Retention(RetentionPolicy.RUNTIME)
80: public @interface RequiredRuntimeVersion {
81: String value(); // no default
82: }
83: }
|