aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/junit/experimental/theories/ParameterSupplier.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/junit/experimental/theories/ParameterSupplier.java')
-rw-r--r--src/main/java/org/junit/experimental/theories/ParameterSupplier.java39
1 files changed, 37 insertions, 2 deletions
diff --git a/src/main/java/org/junit/experimental/theories/ParameterSupplier.java b/src/main/java/org/junit/experimental/theories/ParameterSupplier.java
index 9016c91..bac8b34 100644
--- a/src/main/java/org/junit/experimental/theories/ParameterSupplier.java
+++ b/src/main/java/org/junit/experimental/theories/ParameterSupplier.java
@@ -2,7 +2,42 @@ package org.junit.experimental.theories;
import java.util.List;
-
+/**
+ * Abstract parent class for suppliers of input data points for theories. Extend this class to customize how {@link
+ * org.junit.experimental.theories.Theories Theories} runner
+ * finds accepted data points. Then use your class together with <b>&#064;ParametersSuppliedBy</b> on input
+ * parameters for theories.
+ *
+ * <p>
+ * For example, here is a supplier for values between two integers, and an annotation that references it:
+ *
+ * <pre>
+ * &#064;Retention(RetentionPolicy.RUNTIME)
+ * <b>&#064;ParametersSuppliedBy</b>(BetweenSupplier.class)
+ * public @interface Between {
+ * int first();
+ *
+ * int last();
+ * }
+ *
+ * public static class BetweenSupplier extends <b>ParameterSupplier</b> {
+ * &#064;Override
+ * public List&lt;<b>PotentialAssignment</b>&gt; getValueSources(<b>ParameterSignature</b> sig) {
+ * List&lt;<b>PotentialAssignment</b>&gt; list = new ArrayList&lt;PotentialAssignment&gt;();
+ * Between annotation = (Between) sig.getSupplierAnnotation();
+ *
+ * for (int i = annotation.first(); i &lt;= annotation.last(); i++)
+ * list.add(<b>PotentialAssignment</b>.forValue("ints", i));
+ * return list;
+ * }
+ * }
+ * </pre>
+ * </p>
+ *
+ * @see org.junit.experimental.theories.ParametersSuppliedBy
+ * @see org.junit.experimental.theories.Theories
+ * @see org.junit.experimental.theories.FromDataPoints
+ */
public abstract class ParameterSupplier {
- public abstract List<PotentialAssignment> getValueSources(ParameterSignature sig);
+ public abstract List<PotentialAssignment> getValueSources(ParameterSignature sig) throws Throwable;
}