Package org.apache.juneau.http.header
Class BasicBooleanHeader
java.lang.Object
org.apache.juneau.http.header.BasicHeader
org.apache.juneau.http.header.BasicBooleanHeader
- All Implemented Interfaces:
Serializable
,Cloneable
,Header
,NameValuePair
Category of headers that consist of a single boolean value.
Example
Foo: true
See Also:
-
Constructor Summary
ConstructorDescriptionBasicBooleanHeader
(String name, Boolean value) Constructor.BasicBooleanHeader
(String name, String value) Constructor.BasicBooleanHeader
(String name, Supplier<Boolean> value) Constructor with delayed value. -
Method Summary
Modifier and TypeMethodDescriptionProvides the ability to perform fluent-style assertions on this header.getValue()
boolean
isTrue()
Returnstrue if the header value istrue .static BasicBooleanHeader
Static creator.static BasicBooleanHeader
Static creator.static BasicBooleanHeader
Static creator with delayed value.Return the value if present, otherwise returnother .Returns the header value as aBoolean
.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
-
BasicBooleanHeader
Constructor.- Parameters:
name
- The header name.value
- The header value.
Must be parsable byBoolean.parseBoolean(String)
.
Can benull .- Throws:
IllegalArgumentException
- If name isnull or empty.
-
BasicBooleanHeader
Constructor.- Parameters:
name
- The header name.value
- The header value.
Can benull .- Throws:
IllegalArgumentException
- If name isnull or empty.
-
BasicBooleanHeader
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 byBoolean.parseBoolean(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
-
asBoolean
-
toBoolean
Returns the header value as aBoolean
.- Returns:
- The header value as a
Boolean
. Can benull .
-
isTrue
Returnstrue if the header value istrue .- Returns:
true if the header value istrue .
-
assertBoolean
Provides the ability to perform fluent-style assertions on this header.Examples:
// Validates the response header Foo is true. client .get(URL ) .run() .getHeader("Foo" ).asBooleanHeader().assertBoolean().isTrue();- 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
asBoolean().orElse( .other )- Parameters:
other
- The value to be returned if there is no value present, can benull .- Returns:
- The value, if present, otherwise
other .
-