Class IntegerTypeConverter

  • All Implemented Interfaces:
    TypeConverter

    public class IntegerTypeConverter
    extends Object
    implements TypeConverter
    Type converter for options of types Integer/Long annotated with IntegerOption (not for integer options without this annotation).
    • Constructor Detail

      • IntegerTypeConverter

        public IntegerTypeConverter()
    • Method Detail

      • convert

        public Object convert​(String optionName,
                              String valueStr,
                              TypeToken<?> pType,
                              Annotation pOption,
                              Path pSource,
                              LogManager logger)
                       throws InvalidConfigurationException
        Description copied from interface: TypeConverter
        Convert a String given by the user to an instance of a given type.

        Although the signature of this method does not enforce it, the class of the returned value needs to be assignable to "type" as defined by TypeToken.isSupertypeOf(java.lang.reflect.Type).

        Before this method is called, the caller ensures that all requirements for the option defined with the Option annotation are met.

        Specified by:
        convert in interface TypeConverter
        Parameters:
        optionName - The name of the option (should only be used for nice error messages).
        valueStr - The string to parse.
        pType - The target type.
        pOption - An optional second annotation for the option (this is one of the annotations marked with OptionDetailAnnotation).
        pSource - The file where the configuration option was read from. May contain a dummy value or null if the option was given somehow else.
        logger - A logger for warnings etc.
        Returns:
        An instance of the target type produced from the string representation-
        Throws:
        InvalidConfigurationException - If the user specified an invalid value.