Class ResourceAttributes
java.lang.Object
com.janeirodigital.shapetrees.core.resources.ResourceAttributes
- Direct Known Subclasses:
RelationAttributes
The HttpClientHeaders object is a multi-map with some constructors and put-ers tailored to the
shapetrees-java libraries. The only behavior that's at all HTTP-specific is the
parseLinkHeaders factory which includes logic for HTTP Link headers.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionconstruct a case-insensitive ResourceAttributes containerResourceAttributes
(String attr, String value) construct a case-insensitive ResourceAttributes container and set attr to value if both are not null.ResourceAttributes
(Map<String, List<String>> newMap) Construct ResourceAttributes with passed map, which may be case-sensitive. -
Method Summary
Modifier and TypeMethodDescriptionReturns an unmodifiable List of all of the header string values of the given named header.firstValue
(String name) Returns anOptional
containing the first header string value of the given named (and possibly multi-valued) header.boolean
isEmpty()
Identifies whether the ResourceAttributes are emptymake a new HttpClientHeaders with the additional attr/value set.void
set attr to value if both are not null.static RelationAttributes
parseLinkHeaders
(List<String> headerValues) Re-use HttpClientHeaders to capture link headers as a mapping from link relation to list of values This is really a constructor but a named static function clarifies its intention.void
replaces the list of attrs (without regard to nulls)String[]
Returns an array with alternating attributes and values.Returns a map of attributes to lists of valuestoString()
-
Field Details
-
attributes
-
-
Constructor Details
-
ResourceAttributes
public ResourceAttributes()construct a case-insensitive ResourceAttributes container -
ResourceAttributes
construct a case-insensitive ResourceAttributes container and set attr to value if both are not null.- Parameters:
attr
- attribute (header) name to setvalue
- String value to assign to attr
-
ResourceAttributes
Construct ResourceAttributes with passed map, which may be case-sensitive.- Parameters:
newMap
- replacement for myMapOfLists
-
-
Method Details
-
parseLinkHeaders
Re-use HttpClientHeaders to capture link headers as a mapping from link relation to list of values This is really a constructor but a named static function clarifies its intention.- Parameters:
headerValues
- Header values for Link headers- Returns:
- subset of this matching the pattern
-
maybePlus
make a new HttpClientHeaders with the additional attr/value set.- Parameters:
attr
- attribute (header) name to setvalue
- String value to assign to attr- Returns:
- original HttpClientHeaders if no change is made; otherwise a new copy.
-
maybeSet
set attr to value if both are not null.- Parameters:
attr
- attribute (header) name to setvalue
- String value to assign to attr
-
setAll
replaces the list of attrs (without regard to nulls)- Parameters:
attr
- attribute (header) name to setvalues
- String values to assign to attr
-
toMultimap
Returns a map of attributes to lists of values -
toList
Returns an array with alternating attributes and values.- Parameters:
exclusions
- set of headers to exclude from returned array. (This is useful for HttpRequest.Builder().)
-
firstValue
Returns anOptional
containing the first header string value of the given named (and possibly multi-valued) header. If the header is not present, then the returnedOptional
is empty.- Parameters:
name
- the header name- Returns:
- an
Optional<String>
containing the first named header string value, if present
-
allValues
Returns an unmodifiable List of all of the header string values of the given named header. Always returns a List, which may be empty if the header is not present.- Parameters:
name
- the header name- Returns:
- a List of headers string values
-
isEmpty
public boolean isEmpty()Identifies whether the ResourceAttributes are empty- Returns:
- True when there are no attributes
-
toString
-