K
- the type of the keyT
- the type of the valuepublic class MapConverter<K,T> extends Object implements PropertyConverter<T>, Function<String,T>
Modifier and Type | Field and Description |
---|---|
private Function<String,K> |
keyConverter
Converts the string in the import file to the key in the mapping.
|
private Map<K,T> |
map
The mapping from the keys in the import file to the target value.
|
Constructor and Description |
---|
MapConverter(Map<K,T> map,
Function<String,K> keyConverter) |
Modifier and Type | Method and Description |
---|---|
T |
apply(String value) |
T |
convert(Class<? extends T> targetType,
String value)
Converts a value from import file to Java.
|
static <N extends Number,V> |
create(Map<N,V> map,
Class<N> numberClass)
Creates a new instance of a MapConverter that uses numbers to lookup the values.
|
static <V> MapConverter<String,V> |
create(Map<String,V> map)
Creates a new instance of a MapConverter that uses strings to lookup the values.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
of
@ConstructorProperties(value={"map","keyConverter"}) @Generated(value="lombok") public MapConverter(Map<K,T> map, Function<String,K> keyConverter)
public static <N extends Number,V> MapConverter<N,V> create(Map<N,V> map, Class<N> numberClass)
map
- mapping from the number to the valuesnumberClass
- the concrete class of the numberspublic static <V> MapConverter<String,V> create(Map<String,V> map)
map
- mapping from the string to the valuepublic T convert(Class<? extends T> targetType, String value)
PropertyConverter
convert
in interface PropertyConverter<T>
targetType
- the type of the target propertyvalue
- the value in the import fileCopyright © 2022 fastnate.org. All rights reserved.