Class SingleStringValueExtractor

  • All Implemented Interfaces:
    MultivaluedParameterExtractor<java.lang.String>

    final class SingleStringValueExtractor
    extends java.lang.Object
    implements MultivaluedParameterExtractor<java.lang.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 Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.String defaultValue  
      private java.lang.String paramName  
    • Constructor Summary

      Constructors 
      Constructor Description
      SingleStringValueExtractor​(java.lang.String parameterName, java.lang.String defaultValue)
      Create new single string value extractor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String extract​(javax.ws.rs.core.MultivaluedMap<java.lang.String,​java.lang.String> parameters)
      Extract the map entry identified by a name (and using the configured default value) from the supplied multivalued map.
      java.lang.String getDefaultValueString()
      Default entry value (string) that will be used in case the entry is not present in the supplied multivalued map.
      java.lang.String getName()
      Name of the parameter (map key) to be extracted from the supplied multivalued map.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • paramName

        private final java.lang.String paramName
      • defaultValue

        private final java.lang.String defaultValue
    • Constructor Detail

      • SingleStringValueExtractor

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

      • getDefaultValueString

        public java.lang.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<java.lang.String>
        Returns:
        default (back-up) map entry value.
      • extract

        public java.lang.String extract​(javax.ws.rs.core.MultivaluedMap<java.lang.String,​java.lang.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<java.lang.String>
        Parameters:
        parameters - map of parameters.
        Returns:
        extracted single string parameter value.