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.StringToRegistrarRoleMap
,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
type K
and value type V
, respectively. This class converts a string into an
ImmutableMap mapping K
to V
. 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>
into K
and V
, respectively.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Combined converter and validator class for currency unit-to-string Map argument strings.static class
Combined converter and validator class for string-to-integer Map argument strings.static class
Combined converter/validator class for maps of registrar names to registrar roles.static class
Combined converter and validator class for string-to-string Map argument strings. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract K
Override to define how to parse rawKey into an object of type K.protected abstract V
parseValue
(String rawValue) Override to define how to parse rawValue into an object of type 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
-
Constructor Details
-
KeyValueMapParameter
-
KeyValueMapParameter
public KeyValueMapParameter()
-
-
Method Details
-
parseKey
Override to define how to parse rawKey into an object of type K. -
parseValue
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. -
convert
- Specified by:
convert
in interfacecom.beust.jcommander.IStringConverter<K>
- Specified by:
convert
in classParameterConverterValidator<com.google.common.collect.ImmutableMap<K,
V>>
-