001 package org.junit.experimental.theories;
002
003 import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
004 import static java.lang.annotation.ElementType.PARAMETER;
005
006 import java.lang.annotation.Retention;
007 import java.lang.annotation.RetentionPolicy;
008 import java.lang.annotation.Target;
009
010 /**
011 * Annotating a {@link org.junit.experimental.theories.Theory Theory} method
012 * parameter with @ParametersSuppliedBy causes it to be supplied with
013 * values from the named
014 * {@link org.junit.experimental.theories.ParameterSupplier ParameterSupplier}
015 * when run as a theory by the {@link org.junit.experimental.theories.Theories
016 * Theories} runner.
017 *
018 * In addition, annotations themselves can be annotated with
019 * @ParametersSuppliedBy, and then used similarly. ParameterSuppliedBy
020 * annotations on parameters are detected by searching up this hierarchy such
021 * that these act as syntactic sugar, making:
022 *
023 * <pre>
024 * @ParametersSuppliedBy(Supplier.class)
025 * public @interface SpecialParameter { }
026 *
027 * @Theory
028 * public void theoryMethod(@SpecialParameter String param) {
029 * ...
030 * }
031 * </pre>
032 *
033 * equivalent to:
034 *
035 * <pre>
036 * @Theory
037 * public void theoryMethod(@ParametersSuppliedBy(Supplier.class) String param) {
038 * ...
039 * }
040 * </pre>
041 */
042 @Retention(RetentionPolicy.RUNTIME)
043 @Target({ ANNOTATION_TYPE, PARAMETER })
044 public @interface ParametersSuppliedBy {
045
046 Class<? extends ParameterSupplier> value();
047
048 }