All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cucumber.runtime.converters.ConverterWithNumberFormat Maven / Gradle / Ivy

There is a newer version: 1.2.6
Show newest version
package cucumber.runtime.converters;

import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

public abstract class ConverterWithNumberFormat extends ConverterWithFormat {
    private final List formats = new ArrayList();

    public ConverterWithNumberFormat(Locale locale, Class[] convertibleTypes) {
        super(convertibleTypes);
        formats.add(NumberFormat.getNumberInstance(locale));
    }

    @Override
    public T fromString(String string) {
        T number = super.fromString(string);
        return number == null ? null : downcast(number);
    }

    @Override
    public List getFormats() {
        return formats;
    }

    protected abstract T downcast(Number argument);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy