Class BasicUriHeader

java.lang.Object
org.apache.juneau.http.header.BasicHeader
org.apache.juneau.http.header.BasicUriHeader
All Implemented Interfaces:
Serializable, Cloneable, Header, NameValuePair
Direct Known Subclasses:
ContentLocation, Location, Referer

public class BasicUriHeader extends BasicHeader
Category of headers that consist of a single URL value.

Example

Location: http://www.w3.org/pub/WWW/People.html

See Also:
  • Constructor Details

  • Method Details

    • of

      public static BasicUriHeader of(String name, String value)
      Static creator.
      Parameters:
      name - The header name.
      value - The header value.
      Must be parsable by URI.create(String).
      Can be null.
      Returns:
      A new header bean, or null if the value is null.
      Throws:
      IllegalArgumentException - If name is null or empty.
    • of

      public static BasicUriHeader of(String name, URI value)
      Static creator.
      Parameters:
      name - The header name.
      value - The header value.
      Can be null.
      Returns:
      A new header bean, or null if the value is null.
      Throws:
      IllegalArgumentException - If name is null or empty.
    • of

      public static BasicUriHeader of(String name, Supplier<URI> value)
      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 be null.
      Returns:
      A new header bean, or null if the value is null.
      Throws:
      IllegalArgumentException - If name is null or empty.
    • getValue

      public String getValue()
      Specified by:
      getValue in interface NameValuePair
      Overrides:
      getValue in class BasicHeader
    • asUri

      public Optional<URI> asUri()
      Returns the header value as a URI wrapped in an Optional.
      Returns:
      The header value as a URI wrapped in an Optional. Never null.
    • toUri

      public URI toUri()
      Returns the header value as a URI wrapped in an Optional.
      Returns:
      The header value as a URI wrapped in an Optional. Never null.
    • orElse

      public URI orElse(URI other)
      Return the value if present, otherwise return other.

      This is a shortened form for calling asUri().orElse(other).

      Parameters:
      other - The value to be returned if there is no value present, can be null.
      Returns:
      The value, if present, otherwise other.