001 package edu.rice.cs.cunit.threadCheck.predicates;
002
003 import edu.rice.cs.cunit.threadCheck.PredicateLink;
004 import edu.rice.cs.cunit.threadCheck.Combine;
005
006 import java.lang.annotation.ElementType;
007 import java.lang.annotation.Retention;
008 import java.lang.annotation.RetentionPolicy;
009 import java.lang.annotation.Target;
010
011 /**
012 * An annotation used to designate methods that are not allowed to be run by a thread with the
013 * specified thread group name.
014 * @author Mathias Ricken
015 */
016 @Retention(RetentionPolicy.RUNTIME)
017 @Target({ElementType.CONSTRUCTOR,ElementType.METHOD,ElementType.TYPE})
018
019 @PredicateLink(value = NotThreadCheckPredicates.class, method = "checkGroup")
020 public @interface NotThreadWithGroupName {
021 /**
022 * Group name of the thread. If the regex member is true, then this is treated as a regular expression.
023 * @return group name or regular expression for the group name of the thread allowed to run
024 */
025 String value();
026
027 /**
028 * Determines if the string in the value member is a regular expression (true) or a plain string (false).
029 * @return true if the string in the value member is a regular expression
030 */
031 boolean regex() default false;
032
033
034 //
035 // nested interfaces
036 //
037
038 /**
039 * An annotation used to designate methods that are not allowed to be run by a thread whose thread group name
040 * is equal to the string in the field specified by class and field name.
041 */
042 @Retention(RetentionPolicy.RUNTIME)
043 @Target({ElementType.CONSTRUCTOR, ElementType.METHOD, ElementType.TYPE})
044
045 @PredicateLink(value = NotReflectionThreadCheckPredicates.class, method = "checkGroup")
046 public static @interface InField {
047 /**
048 * The class that contains the field specifying the group name of threads allowed to run.
049 * @return class containing the field
050 */
051 Class fieldClass();
052
053 /**
054 * The name of the field specifying the group name of threads allowed to run.
055 * @return name of the field
056 */
057 String fieldName();
058
059 //
060 // nested interfaces
061 //
062
063 /**
064 * An annotation used to designate methods that are not allowed to be run by a thread whose thread
065 * group name is equal to the string in the field specified by class name and field name.
066 */
067 @Retention(RetentionPolicy.RUNTIME)
068 @Target({ElementType.CONSTRUCTOR, ElementType.METHOD, ElementType.TYPE})
069
070 @PredicateLink(value = NotReflectionThreadCheckPredicates.class, method = "checkGroupByName")
071 public static @interface ByName {
072 /**
073 * The name of the class that contains the field specifying the name of threads allowed to run.
074 *
075 * @return class containing the field
076 */
077 String fieldClassName();
078
079 /**
080 * The name of the field specifying the name of threads allowed to run.
081 *
082 * @return name of the field
083 */
084 String fieldName();
085
086 //
087 // nested interfaces
088 //
089
090 /**
091 * Annotation used to designate methods that are not allowed to be run by a thread whose
092 * thread group name matches the string in any of the fields provided, i.e. the individual
093 * @NotThreadWithGroupName.InField.ByName annotations are combined using AND.
094 */
095 @Retention(RetentionPolicy.RUNTIME)
096 @Target({ElementType.CONSTRUCTOR,ElementType.METHOD,ElementType.TYPE})
097
098 @Combine(Combine.Mode.AND)
099 public static @interface None {
100 NotThreadWithGroupName.InField.ByName[] value();
101 }
102 }
103
104
105 /**
106 * Annotation used to designate methods that are not allowed to be run by a thread whose
107 * thread group name matches the string in any of the fields provided, i.e. the individual
108 * @NotThreadWithGroupName.InField annotations are combined using AND.
109 */
110 @Retention(RetentionPolicy.RUNTIME)
111 @Target({ElementType.CONSTRUCTOR,ElementType.METHOD,ElementType.TYPE})
112
113 @Combine(Combine.Mode.AND)
114 public static @interface None {
115 NotThreadWithGroupName.InField[] value();
116 }
117 }
118
119
120 /**
121 * Annotation used to designate methods that are not allowed to be run by a thread whose thread
122 * group name matches any of the names provided, i.e. the individual @NotThreadWithGroupName
123 * annotations are combined using AND.
124 */
125 @Retention(RetentionPolicy.RUNTIME)
126 @Target({ElementType.CONSTRUCTOR,ElementType.METHOD,ElementType.TYPE})
127
128 @Combine(Combine.Mode.AND)
129 public static @interface None {
130 NotThreadWithGroupName[] value();
131 }
132 }