Interface ParameterMap

All Superinterfaces:
MapAdaptable<String,Object>
All Known Implementing Classes:
LocalParameterMap, MockParameterMap

public interface ParameterMap extends MapAdaptable<String,Object>
An interface for accessing parameters in a backing map. Parameters are immutable and have string keys and string values.

The accessor methods offered by this class taking a target type argument only need to support conversions to well know types like String, Number subclasses, Boolean and so on.

Author:
Keith Donald
  • Method Summary

    Modifier and Type
    Method
    Description
    Adapts this parameter map to an AttributeMap.
    boolean
    contains(String parameterName)
    Does the parameter with the provided name exist in this map?
    get(String parameterName)
    Get a parameter value, returning null if no value is found.
    <T> T
    get(String parameterName, Class<T> targetType)
    Get a parameter value, converting it from String to the target type.
    <T> T
    get(String parameterName, Class<T> targetType, T defaultValue)
    Get a parameter value, converting it from String to the target type or returning the defaultValue if not found.
    get(String parameterName, String defaultValue)
    Get a parameter value, returning the defaultValue if no value is found.
    getArray(String parameterName)
    Get a multi-valued parameter value, returning null if no value is found.
    <T> T[]
    getArray(String parameterName, Class<T> targetElementType)
    Get a multi-valued parameter value, converting each value to the target type or returning null if no value is found.
    getBoolean(String parameterName)
    Returns a boolean parameter value in the map, returning null if no value was found.
    getBoolean(String parameterName, Boolean defaultValue)
    Returns a boolean parameter value in the map, returning the defaultValue if no value was found.
    getInteger(String parameterName)
    Returns an integer parameter value in the map, returning null if no value was found.
    getInteger(String parameterName, Integer defaultValue)
    Returns an integer parameter value in the map, returning the defaultValue if no value was found.
    getLong(String parameterName)
    Returns a long parameter value in the map, returning null if no value was found.
    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.
    <T extends Number>
    T
    getNumber(String parameterName, Class<T> targetType)
    Returns a number parameter value in the map that is of the specified type, returning null if no value was found.
    <T extends Number>
    T
    getNumber(String parameterName, Class<T> targetType, T defaultValue)
    Returns a number parameter value in the map of the specified type, returning the defaultValue if no value was found.
    getRequired(String parameterName)
    Get the value of a required parameter.
    <T> T
    getRequired(String parameterName, Class<T> targetType)
    Get the value of a required parameter and convert it to the target type.
    getRequiredArray(String parameterName)
    Get a required multi-valued parameter value.
    <T> T[]
    getRequiredArray(String parameterName, Class<T> targetElementType)
    Get a required multi-valued parameter value, converting each value to the target type.
    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.
    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.
    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
    Get the value of a required multipart file parameter.
    <T extends Number>
    T
    getRequiredNumber(String parameterName, Class<T> targetType)
    Returns a number parameter value in the map, throwing an exception if the parameter is not present or could not be converted.
    boolean
    Is this parameter map empty, with a size of 0?
    int
    Returns the number of parameters in this map.

    Methods inherited from interface org.springframework.binding.collection.MapAdaptable

    asMap
  • Method Details

    • isEmpty

      boolean isEmpty()
      Is this parameter map empty, with a size of 0?
      Returns:
      true if empty, false if not
    • size

      int size()
      Returns the number of parameters in this map.
      Returns:
      the parameter count
    • contains

      boolean contains(String parameterName)
      Does the parameter with the provided name exist in this map?
      Parameters:
      parameterName - the parameter name
      Returns:
      true if so, false otherwise
    • get

      String get(String parameterName)
      Get a parameter value, returning null if no value is found.
      Parameters:
      parameterName - the parameter name
      Returns:
      the parameter value
    • get

      String get(String parameterName, String defaultValue)
      Get a parameter value, returning the defaultValue if no value is found.
      Parameters:
      parameterName - the parameter name
      defaultValue - the default
      Returns:
      the parameter value
    • getArray

      String[] getArray(String parameterName)
      Get a multi-valued parameter value, returning null if no value is found. If the parameter is single valued an array with a single element is returned.
      Parameters:
      parameterName - the parameter name
      Returns:
      the parameter value array
    • getArray

      <T> T[] getArray(String parameterName, Class<T> targetElementType) throws ConversionExecutionException
      Get a multi-valued parameter value, converting each value to the target type or returning null if no value is found.
      Parameters:
      parameterName - the parameter name
      targetElementType - the target type of the array's elements
      Returns:
      the converterd parameter value array
      Throws:
      ConversionExecutionException - when the value could not be converted
    • get

      <T> T get(String parameterName, Class<T> targetType) throws ConversionExecutionException
      Get a parameter value, converting it from String to the target type.
      Parameters:
      parameterName - the name of the parameter
      targetType - the target type of the parameter value
      Returns:
      the converted parameter value, or null if not found
      Throws:
      ConversionExecutionException - when the value could not be converted
    • get

      <T> T get(String parameterName, Class<T> targetType, T defaultValue) throws ConversionExecutionException
      Get a parameter value, converting it from String to the target type or returning the defaultValue if not found.
      Parameters:
      parameterName - name of the parameter to get
      targetType - the target type of the parameter value
      defaultValue - the default value
      Returns:
      the converted parameter value, or the default if not found
      Throws:
      ConversionExecutionException - when a value could not be converted
    • getRequired

      String getRequired(String parameterName) throws IllegalArgumentException
      Get the value of a required parameter.
      Parameters:
      parameterName - the name of the parameter
      Returns:
      the parameter value
      Throws:
      IllegalArgumentException - when the parameter is not found
    • getRequiredArray

      String[] getRequiredArray(String parameterName) throws IllegalArgumentException
      Get a required multi-valued parameter value.
      Parameters:
      parameterName - the name of the parameter
      Returns:
      the parameter value
      Throws:
      IllegalArgumentException - when the parameter is not found
    • getRequiredArray

      <T> T[] getRequiredArray(String parameterName, Class<T> targetElementType) throws IllegalArgumentException, ConversionExecutionException
      Get a required multi-valued parameter value, converting each value to the target type.
      Parameters:
      parameterName - the name of the parameter
      Returns:
      the parameter value
      Throws:
      IllegalArgumentException - when the parameter is not found
      ConversionExecutionException - when a value could not be converted
    • getRequired

      <T> T getRequired(String parameterName, Class<T> targetType) throws IllegalArgumentException, ConversionExecutionException
      Get the value of a required parameter and convert it to the target type.
      Parameters:
      parameterName - the name of the parameter
      targetType - the target type of the parameter value
      Returns:
      the converted parameter value
      Throws:
      IllegalArgumentException - when the parameter is not found
      ConversionExecutionException - when the value could not be converted
    • getNumber

      <T extends Number> T getNumber(String parameterName, Class<T> targetType) throws ConversionExecutionException
      Returns a number parameter value in the map that is of the specified type, returning null if no value was found.
      Parameters:
      parameterName - the parameter name
      targetType - the target number type
      Returns:
      the number parameter value
      Throws:
      ConversionExecutionException - when the value could not be converted
    • getNumber

      <T extends Number> T getNumber(String parameterName, Class<T> targetType, T defaultValue) throws ConversionExecutionException
      Returns a number parameter value in the map of the specified type, returning the defaultValue if no value was found.
      Parameters:
      parameterName - the parameter name
      defaultValue - the default
      Returns:
      the number parameter value
      Throws:
      ConversionExecutionException - when the value could not be converted
    • getRequiredNumber

      <T extends Number> T getRequiredNumber(String parameterName, Class<T> targetType) throws IllegalArgumentException, ConversionExecutionException
      Returns a number parameter value in the map, throwing an exception if the parameter is not present or could not be converted.
      Parameters:
      parameterName - the parameter name
      Returns:
      the number parameter value
      Throws:
      IllegalArgumentException - if the parameter is not present
      ConversionExecutionException - when the value could not be converted
    • getInteger

      Integer getInteger(String parameterName) throws ConversionExecutionException
      Returns an integer parameter value in the map, returning null if no value was found.
      Parameters:
      parameterName - the parameter name
      Returns:
      the integer parameter value
      Throws:
      ConversionExecutionException - when the value could not be converted
    • getInteger

      Integer getInteger(String parameterName, Integer defaultValue) throws ConversionExecutionException
      Returns an integer parameter value in the map, returning the defaultValue if no value was found.
      Parameters:
      parameterName - the parameter name
      defaultValue - the default
      Returns:
      the integer parameter value
      Throws:
      ConversionExecutionException - when the value could not be converted
    • getRequiredInteger

      Integer getRequiredInteger(String parameterName) throws IllegalArgumentException, ConversionExecutionException
      Returns an integer parameter value in the map, throwing an exception if the parameter is not present or could not be converted.
      Parameters:
      parameterName - the parameter name
      Returns:
      the integer parameter value
      Throws:
      IllegalArgumentException - if the parameter is not present
      ConversionExecutionException - when the value could not be converted
    • getLong

      Long getLong(String parameterName) throws ConversionExecutionException
      Returns a long parameter value in the map, returning null if no value was found.
      Parameters:
      parameterName - the parameter name
      Returns:
      the long parameter value
      Throws:
      ConversionExecutionException - when the value could not be converted
    • getLong

      Long getLong(String parameterName, Long defaultValue) throws ConversionExecutionException
      Returns a long parameter value in the map, returning the defaultValue if no value was found.
      Parameters:
      parameterName - the parameter name
      defaultValue - the default
      Returns:
      the long parameter value
      Throws:
      ConversionExecutionException - when the value could not be converted
    • getRequiredLong

      Long getRequiredLong(String parameterName) throws IllegalArgumentException, ConversionExecutionException
      Returns a long parameter value in the map, throwing an exception if the parameter is not present or could not be converted.
      Parameters:
      parameterName - the parameter name
      Returns:
      the long parameter value
      Throws:
      IllegalArgumentException - if the parameter is not present
      ConversionExecutionException - when the value could not be converted
    • getBoolean

      Boolean getBoolean(String parameterName) throws ConversionExecutionException
      Returns a boolean parameter value in the map, returning null if no value was found.
      Parameters:
      parameterName - the parameter name
      Returns:
      the long parameter value
      Throws:
      ConversionExecutionException - when the value could not be converted
    • getBoolean

      Boolean getBoolean(String parameterName, Boolean defaultValue) throws ConversionExecutionException
      Returns a boolean parameter value in the map, returning the defaultValue if no value was found.
      Parameters:
      parameterName - the parameter name
      defaultValue - the default
      Returns:
      the boolean parameter value
      Throws:
      ConversionExecutionException - when the value could not be converted
    • getRequiredBoolean

      Boolean getRequiredBoolean(String parameterName) throws IllegalArgumentException, ConversionExecutionException
      Returns a boolean parameter value in the map, throwing an exception if the parameter is not present or could not be converted.
      Parameters:
      parameterName - the parameter name
      Returns:
      the boolean parameter value
      Throws:
      IllegalArgumentException - if the parameter is not present
      ConversionExecutionException - when the value could not be converted
    • getMultipartFile

      org.springframework.web.multipart.MultipartFile getMultipartFile(String parameterName)
      Get a multi-part file parameter value, returning null if no value is found.
      Parameters:
      parameterName - the parameter name
      Returns:
      the multipart file
    • getRequiredMultipartFile

      org.springframework.web.multipart.MultipartFile getRequiredMultipartFile(String parameterName)
      Get the value of a required multipart file parameter.
      Parameters:
      parameterName - the name of the parameter
      Returns:
      the parameter value
      Throws:
      IllegalArgumentException - when the parameter is not found
    • asAttributeMap

      AttributeMap<Object> asAttributeMap()
      Adapts this parameter map to an AttributeMap.
      Returns:
      the underlying map as a unmodifiable attribute map