Package org.apache.juneau.http.header
Class BasicStringHeader
java.lang.Object
org.apache.juneau.http.header.BasicHeader
org.apache.juneau.http.header.BasicStringHeader
- All Implemented Interfaces:
Serializable,Cloneable,Header,NameValuePair
- Direct Known Subclasses:
AcceptRanges,Authorization,BasicMediaRangesHeader,BasicMediaTypeHeader,CacheControl,ClientVersion,Connection,ContentEncoding,ContentRange,Expect,Forwarded,From,Host,Origin,Pragma,ProxyAuthenticate,ProxyAuthorization,Range,Server,Trailer,TransferEncoding,UserAgent,Vary,Warning,WwwAuthenticate
Category of headers that consist of a single string value.
Example
Host: www.myhost.com:8080
See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionBasicStringHeader(String name, String value) Constructor.BasicStringHeader(String name, Supplier<String> value) Constructor with delayed value. -
Method Summary
Modifier and TypeMethodDescriptionProvides the ability to perform fluent-style assertions on this header.asString()Returns the value of this header as a string.getValue()static BasicStringHeaderStatic creator.static BasicStringHeaderStatic creator with delayed value.static BasicStringHeaderCreates aHeaderfrom a name/value pair string (e.g.Return the value if present, otherwise returnother .Methods inherited from class org.apache.juneau.http.header.BasicHeader
assertName, assertStringValue, equals, equalsIgnoreCase, get, getElements, getName, hashCode, isNotEmpty, isPresent, of, of, toString
-
Constructor Details
-
BasicStringHeader
Constructor.- Parameters:
name- The header name.value- The header value.
Can benull .- Throws:
IllegalArgumentException- If name isnull or empty.
-
BasicStringHeader
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.
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.
-
ofPair
Creates aHeaderfrom a name/value pair string (e.g."Foo: bar" )- Parameters:
pair- The pair string.- Returns:
- A new header bean.
-
assertString
Provides the ability to perform fluent-style assertions on this header.Examples:
// Validates the content type header is provided. client .get(URL ) .run() .getHeader("Content-Type" ).assertString().exists();- Returns:
- A new fluent assertion object.
- Throws:
AssertionError- If assertion failed.
-
asString
Description copied from class:BasicHeaderReturns the value of this header as a string.- Overrides:
asStringin classBasicHeader- Returns:
- The value of this header as a string, or
Optional.empty()if the value isnull
-
getValue
- Specified by:
getValuein interfaceNameValuePair- Overrides:
getValuein classBasicHeader
-
orElse
Return the value if present, otherwise returnother .This is a shortened form for calling
asString().orElse( .other )- Overrides:
orElsein classBasicHeader- Parameters:
other- The value to be returned if there is no value present, can benull .- Returns:
- The value, if present, otherwise
other .
-