001package org.junit.experimental.theories;
002
003import static java.lang.annotation.ElementType.FIELD;
004import static java.lang.annotation.ElementType.METHOD;
005
006import java.lang.annotation.Retention;
007import java.lang.annotation.RetentionPolicy;
008import java.lang.annotation.Target;
009
010/**
011 * Annotating an field or method with @DataPoint will cause the field value
012 * or the value returned by the method to be used as a potential parameter for
013 * theories in that class, when run with the
014 * {@link org.junit.experimental.theories.Theories Theories} runner.
015 * <p>
016 * A DataPoint is only considered as a potential value for parameters for
017 * which its type is assignable. When multiple {@code DataPoint}s exist 
018 * with overlapping types more control can be obtained by naming each DataPoint 
019 * using the value of this annotation, e.g. with
020 * <code>&#064;DataPoint({"dataset1", "dataset2"})</code>, and then specifying
021 * which named set to consider as potential values for each parameter using the
022 * {@link org.junit.experimental.theories.FromDataPoints &#064;FromDataPoints}
023 * annotation.
024 * <p>
025 * Parameters with no specified source (i.e. without &#064;FromDataPoints or
026 * other {@link org.junit.experimental.theories.ParametersSuppliedBy
027 * &#064;ParameterSuppliedBy} annotations) will use all {@code DataPoint}s that are
028 * assignable to the parameter type as potential values, including named sets of
029 * {@code DataPoint}s.
030 * 
031 * <pre>
032 * &#064;DataPoint
033 * public static String dataPoint = "value";
034 * 
035 * &#064;DataPoint("generated")
036 * public static String generatedDataPoint() {
037 *     return "generated value";
038 * }
039 * 
040 * &#064;Theory
041 * public void theoryMethod(String param) {
042 *     ...
043 * }
044 * </pre>
045 * 
046 * @see org.junit.experimental.theories.Theories
047 * @see org.junit.experimental.theories.Theory
048 * @see org.junit.experimental.theories.DataPoint
049 * @see org.junit.experimental.theories.FromDataPoints
050 */
051@Retention(RetentionPolicy.RUNTIME)
052@Target({FIELD, METHOD})
053public @interface DataPoint {
054    String[] value() default {};
055    Class<? extends Throwable>[] ignoredExceptions() default {};
056}