Class HttpPartBean

java.lang.Object
org.apache.juneau.http.part.HttpPartBean
All Implemented Interfaces:
HttpPart
Direct Known Subclasses:
HttpBooleanPart, HttpCsvArrayPart, HttpDatePart, HttpIntegerPart, HttpLongPart, HttpStringPart, HttpUriPart

public class HttpPartBean extends Object implements HttpPart
Root concrete implementation of HttpPart.

Holds a name/value pair representing a query parameter, form field, or path variable. The value may be supplied eagerly (as a String) or lazily (via a Supplier). A null value signals that the part should be omitted from the request.

Create instances via the static factory methods:

// Eager HttpPart p1 = HttpPartBean.of("status", "active"); // Lazy — evaluated at request-send time HttpPart p2 = HttpPartBean.of("page", () -> String.valueOf(currentPage()));

See Also:
Since:
9.2.1
  • Constructor Details

    • HttpPartBean

      protected HttpPartBean(String name, String value)
      Constructor.
      Parameters:
      name - The part name. Must not be null.
      value - The part value. May be null.
    • HttpPartBean

      protected HttpPartBean(String name, Supplier<String> valueSupplier)
      Constructor with lazy value supplier.
      Parameters:
      name - The part name. Must not be null.
      valueSupplier - Supplier that provides the value at request time. Must not be null.
  • Method Details

    • of

      public static HttpPartBean of(String name, String value)
      Creates an HttpPartBean with an eager string value.
      Parameters:
      name - The part name. Must not be null.
      value - The part value. May be null.
      Returns:
      A new instance. Never null.
    • of

      public static HttpPartBean of(String name, Supplier<String> valueSupplier)
      Creates an HttpPartBean with a lazy value supplier.

      The supplier is evaluated at request-send time; if it returns null the part is omitted.

      Parameters:
      name - The part name. Must not be null.
      valueSupplier - Supplier for the part value. Must not be null.
      Returns:
      A new instance. Never null.
    • getName

      public String getName()
      Description copied from interface: HttpPart
      Returns the part name.
      Specified by:
      getName in interface HttpPart
      Returns:
      The part name. Never null.
    • getValue

      public String getValue()
      Description copied from interface: HttpPart
      Returns the part value, or null if the part should be omitted.
      Specified by:
      getValue in interface HttpPart
      Returns:
      The part value, possibly null.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object