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.Retention;
007 import java.lang.annotation.RetentionPolicy;
008 import java.lang.annotation.Target;
009 import java.lang.annotation.ElementType;
010
011 /**
012 * An annotation used to designate methods that are only allowed to be run when the
013 * method argument indexed are distinct.
014 * @author Mathias Ricken
015 */
016 @Retention(RetentionPolicy.RUNTIME)
017 @Target({ElementType.CONSTRUCTOR,ElementType.METHOD,ElementType.TYPE})
018
019 @PredicateLink(value = ThreadCheckPredicates.class, method = "checkDistinctArguments", arguments = true)
020 public @interface DistinctArguments {
021 /**
022 * Array of undices of the method argument that must be distinct.
023 * @return array of indices of the method argument to be distinct
024 */
025 int[] value();
026
027
028 //
029 // nested interfaces
030 //
031
032 /**
033 * Annotation used to designate methods that are only allowed to be run if
034 * one or more of the arguments are distinct, i.e. the individual
035 * @DistinctArguments annotations are combined using OR.
036 */
037 @Retention(RetentionPolicy.RUNTIME)
038 @Target({ElementType.CONSTRUCTOR,ElementType.METHOD,ElementType.TYPE})
039
040 @Combine(Combine.Mode.OR)
041 public static @interface Any {
042 DistinctArguments[] value();
043 }
044
045 /**
046 * Annotation used to designate methods that are only allowed to be run if
047 * all of the arguments are distinct, i.e. the individual
048 * @DistinctArguments annotations are combined using ALL.
049 */
050 @Retention(RetentionPolicy.RUNTIME)
051 @Target({ElementType.CONSTRUCTOR,ElementType.METHOD,ElementType.TYPE})
052
053 @Combine(Combine.Mode.AND)
054 public static @interface All {
055 DistinctArguments[] value();
056 }
057
058 /**
059 * Annotation used to designate methods that are only allowed to be run if
060 * none of the arguments are distinct, i.e. the individual
061 * @DistinctArguments annotations are combined using NOT.
062 */
063 @Retention(RetentionPolicy.RUNTIME)
064 @Target({ElementType.CONSTRUCTOR,ElementType.METHOD,ElementType.TYPE})
065
066 @Combine(Combine.Mode.NOT)
067 public static @interface None {
068 DistinctArguments[] value();
069 }
070 }