aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/junit/experimental/theories/PotentialAssignment.java
blob: 0c008d0e6e091e3fdad6b12f14ee6c01c7614efd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package org.junit.experimental.theories;

public abstract class PotentialAssignment {
	public static class CouldNotGenerateValueException extends Exception {
		private static final long serialVersionUID= 1L;
	}
	
	public static PotentialAssignment forValue(final String name, final Object value) {
		return new PotentialAssignment() {		
			@Override
			public Object getValue() throws CouldNotGenerateValueException {
				return value;
			}
			
			@Override
			public String toString() {
				return String.format("[%s]", value);
			}

			@Override
			public String getDescription()
					throws CouldNotGenerateValueException {
				return name;
			}
		};
	}
	
	public abstract Object getValue() throws CouldNotGenerateValueException;
	
	public abstract String getDescription() throws CouldNotGenerateValueException;
}