Class BasicCsvArrayPart

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

public class BasicCsvArrayPart extends BasicPart
A NameValuePair that consists of a comma-delimited list of string values.
See Also:
  • Constructor Details

    • BasicCsvArrayPart

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

      public BasicCsvArrayPart(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.
    • BasicCsvArrayPart

      public BasicCsvArrayPart(String name, String value)
      Constructor.

      null values are treated as null. Otherwise parses as a comma-delimited list with whitespace trimmed.

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

    • of

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

      public static BasicCsvArrayPart 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 BasicCsvArrayPart object, or null if the name or supplier is null.
    • getValue

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

      public boolean contains(String val)
      Returns true if this part contains the specified value.
      Parameters:
      val - The value to check for.
      Returns:
      true if this part contains the specified value.
    • containsIgnoreCase

      public boolean containsIgnoreCase(String val)
      Returns true if this part contains the specified value using String.equalsIgnoreCase(String).
      Parameters:
      val - The value to check for.
      Returns:
      true if this part contains the specified value.
    • assertList

      Provides the ability to perform fluent-style assertions on this part.
      Returns:
      A new fluent assertion object.
      Throws:
      AssertionError - If assertion failed.
    • toList

      public List<String> toList()
      Returns The part value as a List.

      The list is unmodifiable.

      Returns:
      The part value as a List, or null if the value null.
    • asList

      public Optional<List<String>> asList()
      Returns The part value as a List wrapped in an Optional.

      The list is unmodifiable.

      Returns:
      The part value as a List wrapped in an Optional. Never null.
    • toArray

      public String[] toArray()
      Returns The part value as an array.

      The array is a copy of the value of this part.

      Returns:
      The part value as an array, or null if the value null.
    • asArray

      public Optional<String[]> asArray()
      Returns The part value as an array wrapped in an Optional.

      Array is a copy of the value of this part.

      Returns:
      The part value as an array 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 asArray().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.