public class LocalParameterMap extends Object implements ParameterMap, Serializable
Map implementation.
This base provides convenient operations for accessing parameters in a typed-manner.| Constructor and Description |
|---|
LocalParameterMap(Map parameters)
Creates a new parameter map from the provided map.
|
LocalParameterMap(Map parameters,
ConversionService conversionService)
Creates a new parameter map from the provided map.
|
| Modifier and Type | Method and Description |
|---|---|
AttributeMap |
asAttributeMap()
Adapts this parameter map to an
AttributeMap. |
Map |
asMap()
Returns this object's contents as a
Map. |
boolean |
contains(String parameterName)
Does the parameter with the provided name exist in this map?
|
boolean |
equals(Object o) |
String |
get(String parameterName)
Get a parameter value, returning
null if no value is found. |
Object |
get(String parameterName,
Class targetType)
Get a parameter value, converting it from
String to the target type. |
Object |
get(String parameterName,
Class targetType,
Object defaultValue)
Get a parameter value, converting it from
String to the target type or returning the defaultValue
if not found. |
String |
get(String parameterName,
String defaultValue)
Get a parameter value, returning the defaultValue if no value is found.
|
String[] |
getArray(String parameterName)
Get a multi-valued parameter value, returning
null if no value is found. |
Object[] |
getArray(String parameterName,
Class targetElementType)
Get a multi-valued parameter value, converting each value to the target type or returning
null if
no value is found. |
Boolean |
getBoolean(String parameterName)
Returns a boolean parameter value in the map, returning
null if no value was found. |
Boolean |
getBoolean(String parameterName,
Boolean defaultValue)
Returns a boolean parameter value in the map, returning the defaultValue if no value was found.
|
Integer |
getInteger(String parameterName)
Returns an integer parameter value in the map, returning
null if no value was found. |
Integer |
getInteger(String parameterName,
Integer defaultValue)
Returns an integer parameter value in the map, returning the defaultValue if no value was found.
|
Long |
getLong(String parameterName)
Returns a long parameter value in the map, returning
null if no value was found. |
Long |
getLong(String parameterName,
Long defaultValue)
Returns a long parameter value in the map, returning the defaultValue if no value was found.
|
org.springframework.web.multipart.MultipartFile |
getMultipartFile(String parameterName)
Get a multi-part file parameter value, returning
null if no value is found. |
Number |
getNumber(String parameterName,
Class targetType)
Returns a number parameter value in the map that is of the specified type, returning
null if no
value was found. |
Number |
getNumber(String parameterName,
Class targetType,
Number defaultValue)
Returns a number parameter value in the map of the specified type, returning the defaultValue if no value was
found.
|
String |
getRequired(String parameterName)
Get the value of a required parameter.
|
Object |
getRequired(String parameterName,
Class targetType)
Get the value of a required parameter and convert it to the target type.
|
String[] |
getRequiredArray(String parameterName)
Get a required multi-valued parameter value.
|
Object[] |
getRequiredArray(String parameterName,
Class targetElementType)
Get a required multi-valued parameter value, converting each value to the target type.
|
Boolean |
getRequiredBoolean(String parameterName)
Returns a boolean parameter value in the map, throwing an exception if the parameter is not present or could not
be converted.
|
Integer |
getRequiredInteger(String parameterName)
Returns an integer parameter value in the map, throwing an exception if the parameter is not present or could not
be converted.
|
Long |
getRequiredLong(String parameterName)
Returns a long parameter value in the map, throwing an exception if the parameter is not present or could not be
converted.
|
org.springframework.web.multipart.MultipartFile |
getRequiredMultipartFile(String parameterName)
Get the value of a required multipart file parameter.
|
Number |
getRequiredNumber(String parameterName,
Class targetType)
Returns a number parameter value in the map, throwing an exception if the parameter is not present or could not
be converted.
|
int |
hashCode() |
boolean |
isEmpty()
Is this parameter map empty, with a size of 0?
|
int |
size()
Returns the number of parameters in this map.
|
String |
toString() |
public LocalParameterMap(Map parameters)
It is expected that the contents of the backing map adhere to the parameter map contract; that is, map entries have string keys, string values, and remain unmodifiable.
parameters - the contents of this parameter mappublic LocalParameterMap(Map parameters, ConversionService conversionService)
It is expected that the contents of the backing map adhere to the parameter map contract; that is, map entries have string keys, string values, and remain unmodifiable.
parameters - the contents of this parameter mapconversionService - a helper for performing type conversion of map entry valuespublic Map asMap()
MapAdaptableMap. The returned map may or may not be modifiable depending on this
implementation.
Warning: this operation may be called frequently; if so care should be taken so that the map contents (if calculated) be cached as appropriate.
asMap in interface MapAdaptablepublic boolean isEmpty()
ParameterMapisEmpty in interface ParameterMappublic int size()
ParameterMapsize in interface ParameterMappublic boolean contains(String parameterName)
ParameterMapcontains in interface ParameterMapparameterName - the parameter namepublic String get(String parameterName)
ParameterMapnull if no value is found.get in interface ParameterMapparameterName - the parameter namepublic String get(String parameterName, String defaultValue)
ParameterMapget in interface ParameterMapparameterName - the parameter namedefaultValue - the defaultpublic String[] getArray(String parameterName)
ParameterMapnull if no value is found. If the parameter is
single valued an array with a single element is returned.getArray in interface ParameterMapparameterName - the parameter namepublic Object[] getArray(String parameterName, Class targetElementType) throws ConversionExecutionException
ParameterMapnull if
no value is found.getArray in interface ParameterMapparameterName - the parameter nametargetElementType - the target type of the array's elementsConversionExecutionException - when the value could not be convertedpublic Object get(String parameterName, Class targetType) throws ConversionExecutionException
ParameterMapString to the target type.get in interface ParameterMapparameterName - the name of the parametertargetType - the target type of the parameter valueConversionExecutionException - when the value could not be convertedpublic Object get(String parameterName, Class targetType, Object defaultValue) throws ConversionExecutionException
ParameterMapString to the target type or returning the defaultValue
if not found.get in interface ParameterMapparameterName - name of the parameter to gettargetType - the target type of the parameter valuedefaultValue - the default valueConversionExecutionException - when a value could not be convertedpublic String getRequired(String parameterName) throws IllegalArgumentException
ParameterMapgetRequired in interface ParameterMapparameterName - the name of the parameterIllegalArgumentException - when the parameter is not foundpublic String[] getRequiredArray(String parameterName) throws IllegalArgumentException
ParameterMapgetRequiredArray in interface ParameterMapparameterName - the name of the parameterIllegalArgumentException - when the parameter is not foundpublic Object[] getRequiredArray(String parameterName, Class targetElementType) throws IllegalArgumentException, ConversionExecutionException
ParameterMapgetRequiredArray in interface ParameterMapparameterName - the name of the parameterIllegalArgumentException - when the parameter is not foundConversionExecutionException - when a value could not be convertedpublic Object getRequired(String parameterName, Class targetType) throws IllegalArgumentException, ConversionExecutionException
ParameterMapgetRequired in interface ParameterMapparameterName - the name of the parametertargetType - the target type of the parameter valueIllegalArgumentException - when the parameter is not foundConversionExecutionException - when the value could not be convertedpublic Number getNumber(String parameterName, Class targetType) throws ConversionExecutionException
ParameterMapnull if no
value was found.getNumber in interface ParameterMapparameterName - the parameter nametargetType - the target number typeConversionExecutionException - when the value could not be convertedpublic Number getNumber(String parameterName, Class targetType, Number defaultValue) throws ConversionExecutionException
ParameterMapgetNumber in interface ParameterMapparameterName - the parameter namedefaultValue - the defaultConversionExecutionException - when the value could not be convertedpublic Number getRequiredNumber(String parameterName, Class targetType) throws IllegalArgumentException, ConversionExecutionException
ParameterMapgetRequiredNumber in interface ParameterMapparameterName - the parameter nameIllegalArgumentException - if the parameter is not presentConversionExecutionException - when the value could not be convertedpublic Integer getInteger(String parameterName) throws ConversionExecutionException
ParameterMapnull if no value was found.getInteger in interface ParameterMapparameterName - the parameter nameConversionExecutionException - when the value could not be convertedpublic Integer getInteger(String parameterName, Integer defaultValue) throws ConversionExecutionException
ParameterMapgetInteger in interface ParameterMapparameterName - the parameter namedefaultValue - the defaultConversionExecutionException - when the value could not be convertedpublic Integer getRequiredInteger(String parameterName) throws IllegalArgumentException, ConversionExecutionException
ParameterMapgetRequiredInteger in interface ParameterMapparameterName - the parameter nameIllegalArgumentException - if the parameter is not presentConversionExecutionException - when the value could not be convertedpublic Long getLong(String parameterName) throws ConversionExecutionException
ParameterMapnull if no value was found.getLong in interface ParameterMapparameterName - the parameter nameConversionExecutionException - when the value could not be convertedpublic Long getLong(String parameterName, Long defaultValue) throws ConversionExecutionException
ParameterMapgetLong in interface ParameterMapparameterName - the parameter namedefaultValue - the defaultConversionExecutionException - when the value could not be convertedpublic Long getRequiredLong(String parameterName) throws IllegalArgumentException, ConversionExecutionException
ParameterMapgetRequiredLong in interface ParameterMapparameterName - the parameter nameIllegalArgumentException - if the parameter is not presentConversionExecutionException - when the value could not be convertedpublic Boolean getBoolean(String parameterName) throws ConversionExecutionException
ParameterMapnull if no value was found.getBoolean in interface ParameterMapparameterName - the parameter nameConversionExecutionException - when the value could not be convertedpublic Boolean getBoolean(String parameterName, Boolean defaultValue) throws ConversionExecutionException
ParameterMapgetBoolean in interface ParameterMapparameterName - the parameter namedefaultValue - the defaultConversionExecutionException - when the value could not be convertedpublic Boolean getRequiredBoolean(String parameterName) throws IllegalArgumentException, ConversionExecutionException
ParameterMapgetRequiredBoolean in interface ParameterMapparameterName - the parameter nameIllegalArgumentException - if the parameter is not presentConversionExecutionException - when the value could not be convertedpublic org.springframework.web.multipart.MultipartFile getMultipartFile(String parameterName)
ParameterMapnull if no value is found.getMultipartFile in interface ParameterMapparameterName - the parameter namepublic org.springframework.web.multipart.MultipartFile getRequiredMultipartFile(String parameterName) throws IllegalArgumentException
ParameterMapgetRequiredMultipartFile in interface ParameterMapparameterName - the name of the parameterIllegalArgumentException - when the parameter is not foundpublic AttributeMap asAttributeMap()
ParameterMapAttributeMap.asAttributeMap in interface ParameterMap