Class SingleStringValueExtractor

java.lang.Object
org.glassfish.jersey.server.internal.inject.SingleStringValueExtractor
All Implemented Interfaces:
MultivaluedParameterExtractor<String>

final class SingleStringValueExtractor extends Object implements MultivaluedParameterExtractor<String>
Extract value of the parameter by returning the first string parameter value found in the list of string parameter values.

This class can be seen as a special, optimized, case of SingleValueExtractor.

  • Field Details

    • paramName

      private final String paramName
    • defaultValue

      private final String defaultValue
  • Constructor Details

    • SingleStringValueExtractor

      public SingleStringValueExtractor(String parameterName, String defaultValue)
      Create new single string value extractor.
      Parameters:
      parameterName - string parameter name.
      defaultValue - default value.
  • Method Details

    • getName

      public String getName()
      Description copied from interface: MultivaluedParameterExtractor
      Name of the parameter (map key) to be extracted from the supplied multivalued map.
      Specified by:
      getName in interface MultivaluedParameterExtractor<String>
      Returns:
      name of the extracted parameter.
    • getDefaultValueString

      public String getDefaultValueString()
      Description copied from interface: MultivaluedParameterExtractor
      Default entry value (string) that will be used in case the entry is not present in the supplied multivalued map.
      Specified by:
      getDefaultValueString in interface MultivaluedParameterExtractor<String>
      Returns:
      default (back-up) map entry value.
    • extract

      public String extract(javax.ws.rs.core.MultivaluedMap<String,String> parameters)
      Extract the map entry identified by a name (and using the configured default value) from the supplied multivalued map.

      This implementation return s the first String value found in the list of potential multiple string parameter values. Any other values in the multi-value list will be ignored.

      Specified by:
      extract in interface MultivaluedParameterExtractor<String>
      Parameters:
      parameters - map of parameters.
      Returns:
      extracted single string parameter value.