Enum BaseTypeConverter
- java.lang.Object
-
- java.lang.Enum<BaseTypeConverter>
-
- org.sosy_lab.common.configuration.converters.BaseTypeConverter
-
- All Implemented Interfaces:
Serializable
,Comparable<BaseTypeConverter>
,TypeConverter
public enum BaseTypeConverter extends Enum<BaseTypeConverter> implements TypeConverter
ATypeConverter
which handles all the trivial cases like ints, Strings, log levels, regexps, etc.This class should not have any relevance outside the
Configuration
class.
-
-
Enum Constant Summary
Enum Constants Enum Constant Description INSTANCE
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
convert(String optionName, String valueStr, TypeToken<?> pType, Annotation pSecondaryOption, Path pSource, LogManager logger)
Convert a String given by the user to an instance of a given type.static <T> Object
invokeStaticMethod(Class<?> type, String method, Class<T> paramType, T value, String optionName)
static Object
valueOf(Class<?> type, String optionName, String value)
Invoke the static "valueOf(String)" method on a class.static BaseTypeConverter
valueOf(String name)
Returns the enum constant of this type with the specified name.static BaseTypeConverter[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.-
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
-
Methods inherited from interface org.sosy_lab.common.configuration.converters.TypeConverter
convertDefaultValue, convertDefaultValueFromOtherInstance, getInstanceForNewConfiguration
-
-
-
-
Enum Constant Detail
-
INSTANCE
public static final BaseTypeConverter INSTANCE
-
-
Method Detail
-
values
public static BaseTypeConverter[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (BaseTypeConverter c : BaseTypeConverter.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static BaseTypeConverter valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
convert
public Object convert(String optionName, String valueStr, TypeToken<?> pType, Annotation pSecondaryOption, 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 interfaceTypeConverter
- Parameters:
optionName
- The name of the option (should only be used for nice error messages).valueStr
- The string to parse.pType
- The target type.pSecondaryOption
- An optional second annotation for the option (this is one of the annotations marked withOptionDetailAnnotation
).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.
-
valueOf
public static Object valueOf(Class<?> type, String optionName, String value) throws InvalidConfigurationException
Invoke the static "valueOf(String)" method on a class. Helpful for type converters.- Throws:
InvalidConfigurationException
-
invokeStaticMethod
public static <T> Object invokeStaticMethod(Class<?> type, String method, Class<T> paramType, T value, String optionName) throws InvalidConfigurationException
- Throws:
InvalidConfigurationException
-
-