Package org.apache.juneau.http.header
Class BasicLongHeader
java.lang.Object
org.apache.juneau.http.header.BasicHeader
org.apache.juneau.http.header.BasicLongHeader
- All Implemented Interfaces:
Serializable
,Cloneable
,Header
,NameValuePair
- Direct Known Subclasses:
ContentLength
Category of headers that consist of a single long value.
Example
Content-Length: 300
See Also:
-
Constructor Summary
ConstructorDescriptionBasicLongHeader
(String name, Long value) Constructor.BasicLongHeader
(String name, String value) Constructor.BasicLongHeader
(String name, Supplier<Long> value) Constructor with delayed value. -
Method Summary
Modifier and TypeMethodDescriptionasLong()
Provides the ability to perform fluent-style assertions on this header.getValue()
static BasicLongHeader
Static creator.static BasicLongHeader
Static creator.static BasicLongHeader
Static creator with delayed value.Return the value if present, otherwise returnother .toLong()
Returns the header value as aLong
.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
-
BasicLongHeader
Constructor.- Parameters:
name
- The header name.value
- The header value.
Must be parsable byLong.parseLong(String)
.
Can benull .- Throws:
IllegalArgumentException
- If name isnull or empty.
-
BasicLongHeader
Constructor.- Parameters:
name
- The header name.value
- The header value.
Can benull .- Throws:
IllegalArgumentException
- If name isnull or empty.
-
BasicLongHeader
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 parsable byLong.parseLong(String)
.
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.
Must be parsable byLong.parseLong(String)
.
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
-
asLong
-
toLong
Returns the header value as aLong
.- Returns:
- The header value as a
Long
. Can benull .
-
assertLong
Provides the ability to perform fluent-style assertions on this header.Examples:
// Validates the response body is not too large. client .get(URL ) .run() .getHeader("Length" ).asLongHeader().assertLong().isLessThan(100000);- 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
asLong().orElse( .other )- Parameters:
other
- The value to be returned if there is no value present, can benull .- Returns:
- The value, if present, otherwise
other .
-