Class HttpUriPart

java.lang.Object
org.apache.juneau.http.part.HttpPartBean
org.apache.juneau.http.part.HttpUriPart
All Implemented Interfaces:
HttpPart

public class HttpUriPart extends HttpPartBean
An HttpPart whose value is a URI.

Mirrors the semantics of BasicUriPart from juneau-rest-common-classic without the Apache HttpCore dependency.

Since:
10.0.0
  • Constructor Details

    • HttpUriPart

      public HttpUriPart(String name, String value)
      Constructor accepting a wire-format string value.
      Parameters:
      name - The part name. Must not be null.
      value - The wire value. May be null or empty.
    • HttpUriPart

      public HttpUriPart(String name, URI value)
      Constructor accepting a URI value.
      Parameters:
      name - The part name. Must not be null.
      value - The URI value. May be null.
    • HttpUriPart

      public HttpUriPart(String name, Supplier<URI> supplier)
      Constructor accepting a lazy URI supplier.
      Parameters:
      name - The part name. Must not be null.
      supplier - Supplier for the URI value. Must not be null.
  • Method Details

    • of

      public static HttpUriPart of(String name, URI value)
      Creates an HttpUriPart with the given name and URI value.
      Parameters:
      name - The part name. Must not be null.
      value - The URI value. May be null.
      Returns:
      A new instance. Never null.
    • ofString

      public static HttpUriPart ofString(String name, String value)
      Creates an HttpUriPart by parsing the given wire value.
      Parameters:
      name - The part name. Must not be null.
      value - The wire value. May be null or empty.
      Returns:
      A new instance. Never null.
    • ofLazy

      public static HttpUriPart ofLazy(String name, Supplier<URI> supplier)
      Creates an HttpUriPart with a lazy URI supplier.
      Parameters:
      name - The part name. Must not be null.
      supplier - Supplier for the URI value. Must not be null.
      Returns:
      A new instance. Never null.
    • asUri

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

      public URI orElse(URI other)
      Returns the value if present, otherwise returns other.
      Parameters:
      other - The default value.
      Returns:
      The value or other.
    • toUri

      public URI toUri()
      Returns the value as a URI, or null if not set.
      Returns:
      The URI value, possibly null.