Package org.fastnate.data.properties
Class MapConverter<K,T>
java.lang.Object
org.fastnate.data.properties.MapConverter<K,T>
- Type Parameters:
K- the type of the keyT- the type of the value
- All Implemented Interfaces:
Function<String,,T> PropertyConverter<T>
Converts a string from an import file to an object by using an explicit mapping.
- Author:
- Tobias Liefke
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionConverts a value from import file to Java.static <V> MapConverter<String, V> Creates a new instance of a MapConverter that uses strings to lookup the values.static <N extends Number,V>
MapConverter<N, V> Creates a new instance of a MapConverter that uses numbers to lookup the values.
-
Constructor Details
-
MapConverter
Creates a newMapConverterinstance.- Parameters:
map- The mapping from the keys in the import file to the target value.keyConverter- Converts the string in the import file to the key in the mapping.
-
-
Method Details
-
create
Creates a new instance of a MapConverter that uses numbers to lookup the values.- Parameters:
map- mapping from the number to the valuesnumberClass- the concrete class of the numbers- Returns:
- the created converter
-
create
Creates a new instance of a MapConverter that uses strings to lookup the values.- Parameters:
map- mapping from the string to the value- Returns:
- the created converter
-
apply
-
convert
Description copied from interface:PropertyConverterConverts a value from import file to Java.- Specified by:
convertin interfacePropertyConverter<K>- Parameters:
targetType- the type of the target propertyvalue- the value in the import file- Returns:
- the value in Java
-