Package org.apache.juneau.http.header
Class BasicIntegerHeader
java.lang.Object
org.apache.juneau.http.header.BasicHeader
org.apache.juneau.http.header.BasicIntegerHeader
- All Implemented Interfaces:
Serializable
,Cloneable
,Header
,NameValuePair
- Direct Known Subclasses:
Age
,MaxForwards
Category of headers that consist of a single integer value.
Example
Age: 300
See Also:
-
Constructor Summary
ConstructorDescriptionBasicIntegerHeader
(String name, Integer value) Constructor.BasicIntegerHeader
(String name, String value) Constructor.BasicIntegerHeader
(String name, Supplier<Integer> value) Constructor with delayed value. -
Method Summary
Modifier and TypeMethodDescriptionProvides the ability to perform fluent-style assertions on this header.getValue()
static BasicIntegerHeader
Static creator.static BasicIntegerHeader
Static creator.static BasicIntegerHeader
Static creator with delayed value.Return the value if present, otherwise returnother .Returns the header value as anInteger
.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
-
BasicIntegerHeader
Constructor.- Parameters:
name
- The header name.value
- The header value.
Must be parsable usingInteger.parseInt(String)
.
Can benull .- Throws:
IllegalArgumentException
- If name isnull or empty.
-
BasicIntegerHeader
Constructor.- Parameters:
name
- The header name.value
- The header value.
Can benull .- Throws:
IllegalArgumentException
- If name isnull or empty.
-
BasicIntegerHeader
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 usingInteger.parseInt(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.
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
-
asInteger
-
toInteger
Returns the header value as anInteger
.- Returns:
- The header value as an
Integer
. Can benull .
-
assertInteger
Provides the ability to perform fluent-style assertions on this header.Examples:
// Validates the response content is older than 1. client .get(URL ) .run() .getHeader("Age" ).asIntegerHeader().assertInteger().isGreaterThan(1);- 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
asInteger().orElse( .other )- Parameters:
other
- The value to be returned if there is no value present, can benull .- Returns:
- The value, if present, otherwise
other .
-