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 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 = "checkName")
020 public @interface NotThreadWithName {
021 /**
022 * Name of the thread. If the regex member is true, then this is treated as a regular expression.
023 * @return name or regular expression for the name of the thread forbidden 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 // nested interfaces
035 //
036
037 /**
038 * An annotation used to designate methods that are not allowed to be run by a thread whose name is equal to the
039 * string in the field specified by class and field name.
040 */
041 @Retention(RetentionPolicy.RUNTIME)
042 @Target({ElementType.CONSTRUCTOR, ElementType.METHOD, ElementType.TYPE})
043
044 @PredicateLink(value = NotReflectionThreadCheckPredicates.class, method = "checkName")
045 public static @interface InField {
046 /**
047 * The class that contains the field specifying the name of threads allowed to run.
048 * @return class containing the field
049 */
050 Class fieldClass();
051
052 /**
053 * The name of the field specifying the name of threads allowed to run.
054 * @return name of the field
055 */
056 String fieldName();
057
058 //
059 // nested interfaces
060 //
061
062 /**
063 * An annotation used to designate methods that are not allowed to be run by a thread whose name is equal to the
064 * string in the field specified by class name and field name.
065 */
066 @Retention(RetentionPolicy.RUNTIME)
067 @Target({ElementType.CONSTRUCTOR, ElementType.METHOD, ElementType.TYPE})
068
069 @PredicateLink(value = NotReflectionThreadCheckPredicates.class, method = "checkNameByName")
070 public static @interface ByName {
071 /**
072 * The name of the class that contains the field specifying the name of threads allowed to run.
073 * @return class containing the field
074 */
075 String fieldClassName();
076
077 /**
078 * The name of the field specifying the name of threads allowed to run.
079 * @return name of the field
080 */
081 String fieldName();
082
083
084 //
085 // nested interfaces
086 //
087
088 /**
089 * Annotation used to designate methods that are not allowed to be run by a thread whose name matches
090 * the string in any of the fields provided, i.e. the individual @NotThreadWithName.InField.ByName
091 * annotations are combined using AND.
092 */
093 @Retention(RetentionPolicy.RUNTIME)
094 @Target({ElementType.CONSTRUCTOR,ElementType.METHOD,ElementType.TYPE})
095
096 @Combine(Combine.Mode.NOT)
097 public static @interface None {
098 NotThreadWithName.InField.ByName[] value();
099 }
100 }
101
102
103 /**
104 * Annotation used to designate methods that are not allowed to be run by a thread whose name matches
105 * the string in any of the fields provided, i.e. the individual @NotThreadWithName.InField annotations
106 * are combined using AND.
107 */
108 @Retention(RetentionPolicy.RUNTIME)
109 @Target({ElementType.CONSTRUCTOR,ElementType.METHOD,ElementType.TYPE})
110
111 @Combine(Combine.Mode.AND)
112 public static @interface None {
113 NotThreadWithName.InField[] value();
114 }
115 }
116
117 /**
118 * Annotation used to designate methods that are not allowed to be run by a thread whose name matches any
119 * of the names provided, i.e. the individual @NotThreadWithName annotations
120 * are combined using AND.
121 */
122 @Retention(RetentionPolicy.RUNTIME)
123 @Target({ElementType.CONSTRUCTOR,ElementType.METHOD,ElementType.TYPE})
124
125 @Combine(Combine.Mode.AND)
126 public static @interface None {
127 NotThreadWithName[] value();
128 }
129 }