Class BasicStringPart

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

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

    • BasicStringPart

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

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

    • of

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

      public static BasicStringPart of(String name, Supplier<String> 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 BasicStringPart object, or null if the name or supplier is null.
    • assertString

      public org.apache.juneau.assertions.FluentStringAssertion<BasicStringPart> assertString()
      Provides the ability to perform fluent-style assertions on this part.
      Returns:
      A new fluent assertion object.
      Throws:
      AssertionError - If assertion failed.
    • getValue

      public String getValue()
      Specified by:
      getValue in interface NameValuePair
      Overrides:
      getValue in class BasicPart
    • asString

      Returns The part value as a String wrapped in an Optional.
      Returns:
      The part value as a String wrapped in an Optional. Never null.
    • orElse

      public String orElse(String 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.