Class BasicUriPart

java.lang.Object
org.apache.juneau.http.part.BasicPart
org.apache.juneau.http.part.BasicUriPart
All Implemented Interfaces:
NameValuePair, Headerable

public class BasicUriPart extends BasicPart
A NameValuePair that consists of a single URL value.
See Also:
  • Constructor Details

    • BasicUriPart

      public BasicUriPart(String name, URI value)
      Constructor.
      Parameters:
      name - The part name. Must not be null.
      value - The part value. Can be null.
    • BasicUriPart

      public BasicUriPart(String name, Supplier<URI> value)
      Constructor.
      Parameters:
      name - The part name. Must not be null.
      value - The part value supplier. Can be null or supply null.
    • BasicUriPart

      public BasicUriPart(String name, String value)
      Constructor.

      null and empty values are treated as null. Otherwise parses using URI.create(String).

      Parameters:
      name - The part name. Must not be null.
      value - The part value. Can be null.
  • Method Details

    • of

      public static BasicUriPart of(String name, URI value)
      Static creator.
      Parameters:
      name - The part name.
      value - The part value.
      Returns:
      A new BasicUriPart object, or null if the name or value is null.
    • of

      public static BasicUriPart of(String name, Supplier<URI> value)
      Static creator with delayed value.

      Part value is re-evaluated on each call to NameValuePair.getValue().

      Parameters:
      name - The part name.
      value - The part value supplier.
      Returns:
      A new BasicUriPart object, or null if the name or supplier is null.
    • asUri

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

      public URI toUri()
      Returns The part value as a URI.
      Returns:
      The part value as a URI, or null if the value null.
    • orElse

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

      This is a shortened form for calling asString().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.