Sha256: 852e680e0ad33a9d4bf768301b636f349ad682246e94d866001fc5fb7b5aa323

Contents?: true

Size: 1018 Bytes

Versions: 37

Compression:

Stored size: 1018 Bytes

Contents

package cukes.jbehave.examples.trader.converters;

import java.lang.reflect.Type;

import cukes.jbehave.examples.trader.model.Trader;
import cukes.jbehave.examples.trader.persistence.TraderPersister;
import org.jbehave.scenario.steps.ParameterConverters.InvalidParameterException;
import org.jbehave.scenario.steps.ParameterConverters.ParameterConverter;

public class TraderConverter implements ParameterConverter {
    private TraderPersister persister;

    public TraderConverter(TraderPersister persister) {
        this.persister = persister;
    }

    public boolean accept(Type type) {
        if (type instanceof Class) {
            return Trader.class.isAssignableFrom((Class<?>) type);
        }
        return false;
    }

    public Object convertValue(String value, Type type) {
        Trader trader = persister.retrieveTrader(value);
        if (trader == null) {
            throw new InvalidParameterException("Trader not found for name " + value, null);
        }
        return trader;
    }

}

Version data entries

37 entries across 37 versions & 4 rubygems

Version Path
aslakhellesoy-cucumber-0.1.100.1 examples/jbehave/src/main/java/cukes/jbehave/examples/trader/converters/TraderConverter.java
aslakhellesoy-cucumber-0.1.100.2 examples/jbehave/src/main/java/cukes/jbehave/examples/trader/converters/TraderConverter.java
aslakhellesoy-cucumber-0.1.100.3 examples/jbehave/src/main/java/cukes/jbehave/examples/trader/converters/TraderConverter.java
aslakhellesoy-cucumber-0.1.100.4 examples/jbehave/src/main/java/cukes/jbehave/examples/trader/converters/TraderConverter.java
aslakhellesoy-cucumber-0.1.100.5 examples/jbehave/src/main/java/cukes/jbehave/examples/trader/converters/TraderConverter.java
aslakhellesoy-cucumber-0.1.99.10 examples/jbehave/src/main/java/cukes/jbehave/examples/trader/converters/TraderConverter.java
aslakhellesoy-cucumber-0.1.99.11 examples/jbehave/src/main/java/cukes/jbehave/examples/trader/converters/TraderConverter.java
aslakhellesoy-cucumber-0.1.99.12 examples/jbehave/src/main/java/cukes/jbehave/examples/trader/converters/TraderConverter.java
aslakhellesoy-cucumber-0.1.99.13 examples/jbehave/src/main/java/cukes/jbehave/examples/trader/converters/TraderConverter.java
aslakhellesoy-cucumber-0.1.99.14 examples/jbehave/src/main/java/cukes/jbehave/examples/trader/converters/TraderConverter.java
aslakhellesoy-cucumber-0.1.99.15 examples/jbehave/src/main/java/cukes/jbehave/examples/trader/converters/TraderConverter.java
aslakhellesoy-cucumber-0.1.99.17 examples/jbehave/src/main/java/cukes/jbehave/examples/trader/converters/TraderConverter.java
aslakhellesoy-cucumber-0.1.99.18 examples/jbehave/src/main/java/cukes/jbehave/examples/trader/converters/TraderConverter.java
aslakhellesoy-cucumber-0.1.99.19 examples/jbehave/src/main/java/cukes/jbehave/examples/trader/converters/TraderConverter.java
aslakhellesoy-cucumber-0.1.99.20 examples/jbehave/src/main/java/cukes/jbehave/examples/trader/converters/TraderConverter.java
aslakhellesoy-cucumber-0.1.99.21 examples/jbehave/src/main/java/cukes/jbehave/examples/trader/converters/TraderConverter.java
aslakhellesoy-cucumber-0.1.99.22 examples/jbehave/src/main/java/cukes/jbehave/examples/trader/converters/TraderConverter.java
aslakhellesoy-cucumber-0.1.99.23 examples/jbehave/src/main/java/cukes/jbehave/examples/trader/converters/TraderConverter.java
aslakhellesoy-cucumber-0.1.99.5 examples/jbehave/src/main/java/cukes/jbehave/examples/trader/converters/TraderConverter.java
aslakhellesoy-cucumber-0.1.99.6 examples/jbehave/src/main/java/cukes/jbehave/examples/trader/converters/TraderConverter.java