Class StringCollectionExtractor
- java.lang.Object
-
- org.glassfish.jersey.server.internal.inject.StringCollectionExtractor
-
- All Implemented Interfaces:
MultivaluedParameterExtractor<java.util.Collection<java.lang.String>>
- Direct Known Subclasses:
StringCollectionExtractor.ListString
,StringCollectionExtractor.SetString
,StringCollectionExtractor.SortedSetString
abstract class StringCollectionExtractor extends java.lang.Object implements MultivaluedParameterExtractor<java.util.Collection<java.lang.String>>
Extract parameter value as a specificString
Java collection type. This class can be seen as a special, optimized, case ofCollectionExtractor
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
StringCollectionExtractor.ListString
private static class
StringCollectionExtractor.SetString
private static class
StringCollectionExtractor.SortedSetString
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
defaultValue
private java.lang.String
parameter
-
Constructor Summary
Constructors Modifier Constructor Description protected
StringCollectionExtractor(java.lang.String parameterName, java.lang.String defaultValue)
Create new string collection parameter extractor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.util.Collection<java.lang.String>
extract(javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> parameters)
Extract the map entry identified by aname
(and using the configureddefault value
) from the suppliedmultivalued map
.java.lang.String
getDefaultValueString()
Default entry value (string) that will be used in case the entry is not present in the suppliedmultivalued map
.static StringCollectionExtractor
getInstance(java.lang.Class<?> collectionType, java.lang.String parameterName, java.lang.String defaultValue)
Get string collection extractor instance supporting the given collection class type for the parameter specified.java.lang.String
getName()
Name of the parameter (map key) to be extracted from the suppliedmultivalued map
.protected abstract java.util.Collection<java.lang.String>
newCollection()
Get a new string collection instance that will be used to store the extracted parameters.
-
-
-
Method Detail
-
getName
public java.lang.String getName()
Description copied from interface:MultivaluedParameterExtractor
Name of the parameter (map key) to be extracted from the suppliedmultivalued map
.- Specified by:
getName
in interfaceMultivaluedParameterExtractor<java.util.Collection<java.lang.String>>
- Returns:
- name of the extracted parameter.
-
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 suppliedmultivalued map
.- Specified by:
getDefaultValueString
in interfaceMultivaluedParameterExtractor<java.util.Collection<java.lang.String>>
- Returns:
- default (back-up) map entry value.
-
extract
public java.util.Collection<java.lang.String> extract(javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> parameters)
Description copied from interface:MultivaluedParameterExtractor
Extract the map entry identified by aname
(and using the configureddefault value
) from the suppliedmultivalued map
.- Specified by:
extract
in interfaceMultivaluedParameterExtractor<java.util.Collection<java.lang.String>>
- Parameters:
parameters
- multivalued parameter map.- Returns:
- custom Java type instance representing the extracted multivalued map entry.
-
newCollection
protected abstract java.util.Collection<java.lang.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(java.lang.Class<?> collectionType, java.lang.String parameterName, java.lang.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.
-
-