Package org.apache.juneau.http.header
Class BasicDateHeader
java.lang.Object
org.apache.juneau.http.header.BasicHeader
org.apache.juneau.http.header.BasicDateHeader
- All Implemented Interfaces:
Serializable
,Cloneable
,Header
,NameValuePair
- Direct Known Subclasses:
Date
,Expires
,IfModifiedSince
,IfRange
,IfUnmodifiedSince
,LastModified
,RetryAfter
Category of headers that consist of a single HTTP-date.
Example
If-Modified-Since: Sat, 29 Oct 1994 19:43:31 GMT
See Also:
-
Constructor Summary
ConstructorDescriptionBasicDateHeader
(String name, String value) Constructor.BasicDateHeader
(String name, ZonedDateTime value) Constructor.BasicDateHeader
(String name, Supplier<ZonedDateTime> value) Constructor with delayed value. -
Method Summary
Modifier and TypeMethodDescriptionProvides the ability to perform fluent-style assertions on this header.Returns the header value as aZonedDateTime
wrapped in anOptional
.getValue()
static BasicDateHeader
Static creator.static BasicDateHeader
of
(String name, ZonedDateTime value) Static creator.static BasicDateHeader
of
(String name, Supplier<ZonedDateTime> value) Static creator with delayed value.orElse
(ZonedDateTime other) Return the value if present, otherwise returnother .Returns the header value as aZonedDateTime
.Methods inherited from class org.apache.juneau.http.header.BasicHeader
assertName, assertStringValue, asString, equals, equalsIgnoreCase, get, getElements, getName, hashCode, isNotEmpty, isPresent, of, of, orElse, toString
-
Constructor Details
-
BasicDateHeader
Constructor.- Parameters:
name
- The header name.value
- The header value.
Must be an RFC-1123 formated string (e.g."Sat, 29 Oct 1994 19:43:31 GMT" ).
Can benull .- Throws:
IllegalArgumentException
- If name isnull or empty.
-
BasicDateHeader
Constructor.- Parameters:
name
- The header name.value
- The header value.
Can benull .- Throws:
IllegalArgumentException
- If name isnull or empty.
-
BasicDateHeader
Constructor with delayed value.Header value is re-evaluated on each call to
getValue()
.- Parameters:
name
- The header name.value
- The supplier of the header value.
Can benull .- Throws:
IllegalArgumentException
- If name isnull or empty.
-
-
Method Details
-
of
Static creator.- Parameters:
name
- The header name.value
- The header value.
Must be an RFC-1123 formated string (e.g."Sat, 29 Oct 1994 19:43:31 GMT" ).
Can benull .- Returns:
- A new header bean, or
null if the value isnull . - Throws:
IllegalArgumentException
- If name isnull or empty.
-
of
Static creator.- Parameters:
name
- The header name.value
- The header value.
Can benull .- Returns:
- A new header bean, or
null if the value isnull . - Throws:
IllegalArgumentException
- If name isnull or empty.
-
of
Static creator with delayed value.Header value is re-evaluated on each call to
getValue()
.- Parameters:
name
- The header name.value
- The supplier of the header value.
Can benull .- Returns:
- A new header bean, or
null if the value isnull . - Throws:
IllegalArgumentException
- If name isnull or empty.
-
getValue
- Specified by:
getValue
in interfaceNameValuePair
- Overrides:
getValue
in classBasicHeader
-
asZonedDateTime
Returns the header value as aZonedDateTime
wrapped in anOptional
.- Returns:
- The header value as a
ZonedDateTime
wrapped in anOptional
. Nevernull .
-
toZonedDateTime
Returns the header value as aZonedDateTime
.- Returns:
- The header value as a
ZonedDateTime
. Can benull .
-
assertZonedDateTime
Provides the ability to perform fluent-style assertions on this header.Examples:
// Validates the response body content is not expired. client .get(URL ) .run() .getHeader("Expires" ).asDateHeader().assertZonedDateTime().isLessThan(new Date());- Returns:
- A new fluent assertion object.
- Throws:
AssertionError
- If assertion failed.
-
orElse
Return the value if present, otherwise returnother .This is a shortened form for calling
asZonedDateTime().orElse( .other )- Parameters:
other
- The value to be returned if there is no value present, can benull .- Returns:
- The value, if present, otherwise
other .
-