Class StringCollectionExtractor

java.lang.Object
org.glassfish.jersey.server.internal.inject.StringCollectionExtractor
All Implemented Interfaces:
MultivaluedParameterExtractor<Collection<String>>
Direct Known Subclasses:
StringCollectionExtractor.ListString, StringCollectionExtractor.SetString, StringCollectionExtractor.SortedSetString

abstract class StringCollectionExtractor extends Object implements MultivaluedParameterExtractor<Collection<String>>
Extract parameter value as a specific String Java collection type.

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

  • Field Details

    • parameter

      private final String parameter
    • defaultValue

      private final String defaultValue
  • Constructor Details

    • StringCollectionExtractor

      protected StringCollectionExtractor(String parameterName, String defaultValue)
      Create new string collection parameter extractor.
      Parameters:
      parameterName - parameter name.
      defaultValue - default parameter 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<Collection<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<Collection<String>>
      Returns:
      default (back-up) map entry value.
    • extract

      public Collection<String> extract(javax.ws.rs.core.MultivaluedMap<String,String> parameters)
      Description copied from interface: MultivaluedParameterExtractor
      Extract the map entry identified by a name (and using the configured default value) from the supplied multivalued map.
      Specified by:
      extract in interface MultivaluedParameterExtractor<Collection<String>>
      Parameters:
      parameters - multivalued parameter map.
      Returns:
      custom Java type instance representing the extracted multivalued map entry.
    • newCollection

      protected abstract Collection<String> newCollection()
      Get a new string collection instance that will be used to store the extracted parameters. The method is overridden by concrete implementations to return an instance of a proper collection sub-type.
      Returns:
      instance of a proper collection sub-type
    • getInstance

      public static StringCollectionExtractor getInstance(Class<?> collectionType, String parameterName, String defaultValue)
      Get string collection extractor instance supporting the given collection class type for the parameter specified.
      Parameters:
      collectionType - collection type to be supported by the extractor.
      parameterName - extracted parameter name.
      defaultValue - default parameter value.
      Returns:
      string collection extractor instance supporting the given collection class type.