Package google.registry.tools.params
Class KeyValueMapParameter<K,V>
- java.lang.Object
-
- google.registry.tools.params.ParameterConverterValidator<com.google.common.collect.ImmutableMap<K,V>>
-
- google.registry.tools.params.KeyValueMapParameter<K,V>
-
- Type Parameters:
K
- instance key typeV
- instance value type
- All Implemented Interfaces:
com.beust.jcommander.IParameterValidator
,com.beust.jcommander.IStringConverter<com.google.common.collect.ImmutableMap<K,V>>
- Direct Known Subclasses:
KeyValueMapParameter.CurrencyUnitToStringMap
,KeyValueMapParameter.StringToIntegerMap
,KeyValueMapParameter.StringToStringMap
,TransitionListParameter
public abstract class KeyValueMapParameter<K,V> extends ParameterConverterValidator<com.google.common.collect.ImmutableMap<K,V>>
Combined converter and validator class for key-value map JCommander argument strings.These strings have the form
<K-str>=<V-str>,[<K-str>=<V-str>]*
where<K-str>
and<V-str>
are strings that can be parsed into instances of some key typeK
and value typeV
, respectively. This class converts a string into an ImmutableMap mappingK
toV
. Validation and conversion share the same logic; validation is just done by attempting conversion and throwing exceptions if need be.Subclasses must implement parseKey() and parseValue() to define how to parse
<K-str>
and<V-str>
intoK
andV
, respectively.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
KeyValueMapParameter.CurrencyUnitToStringMap
Combined converter and validator class for currency unit-to-string Map argument strings.static class
KeyValueMapParameter.StringToIntegerMap
Combined converter and validator class for string-to-integer Map argument strings.static class
KeyValueMapParameter.StringToStringMap
Combined converter and validator class for string-to-string Map argument strings.
-
Constructor Summary
Constructors Constructor Description KeyValueMapParameter()
KeyValueMapParameter(java.lang.String messageForInvalid)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description com.google.common.collect.ImmutableMap<K,V>
convert(java.lang.String keyValueMapString)
protected abstract K
parseKey(java.lang.String rawKey)
Override to define how to parse rawKey into an object of type K.protected abstract V
parseValue(java.lang.String rawValue)
Override to define how to parse rawValue into an object of type V.protected com.google.common.collect.ImmutableMap<K,V>
processMap(com.google.common.collect.ImmutableMap<K,V> map)
Override to perform any post-processing on the map.-
Methods inherited from class google.registry.tools.params.ParameterConverterValidator
validate
-
-
-
-
Method Detail
-
parseKey
protected abstract K parseKey(java.lang.String rawKey)
Override to define how to parse rawKey into an object of type K.
-
parseValue
protected abstract V parseValue(java.lang.String rawValue)
Override to define how to parse rawValue into an object of type V.
-
processMap
protected com.google.common.collect.ImmutableMap<K,V> processMap(com.google.common.collect.ImmutableMap<K,V> map)
Override to perform any post-processing on the map.
-
-