001package org.junit.experimental.theories;
002
003public abstract class PotentialAssignment {
004    public static class CouldNotGenerateValueException extends Exception {
005        private static final long serialVersionUID = 1L;
006    }
007
008    public static PotentialAssignment forValue(final String name, final Object value) {
009        return new PotentialAssignment() {
010            @Override
011            public Object getValue() throws CouldNotGenerateValueException {
012                return value;
013            }
014
015            @Override
016            public String toString() {
017                return String.format("[%s]", value);
018            }
019
020            @Override
021            public String getDescription()
022                    throws CouldNotGenerateValueException {
023                return name;
024            }
025        };
026    }
027
028    public abstract Object getValue() throws CouldNotGenerateValueException;
029
030    public abstract String getDescription() throws CouldNotGenerateValueException;
031}