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

fi.jubic.easyconfig.internal.parameter.IntegerParameterParser Maven / Gradle / Ivy

There is a newer version: 0.10.4
Show newest version
package fi.jubic.easyconfig.internal.parameter;

import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

class IntegerParameterParser extends PrimitiveParameterParser {
    private static final Set> SUPPORTED_CLASSES = Stream
            .of(int.class, Integer.class)
            .collect(Collectors.toSet());

    @Override
    Set> supportedClasses() {
        return SUPPORTED_CLASSES;
    }

    @Override
    Optional parse(String stringValue) {
        try {
            return Optional.of(Integer.valueOf(stringValue));
        }
        catch (NumberFormatException ignore) {
            return Optional.empty();
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy