Class HttpCsvArrayPart

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

public class HttpCsvArrayPart extends HttpPartBean
An HttpPart whose value is a comma-delimited list of strings.

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

Since:
10.0.0
  • Constructor Details

    • HttpCsvArrayPart

      public HttpCsvArrayPart(String name, String... value)
      Constructor accepting an array of values.
      Parameters:
      name - The part name. Must not be null.
      value - The array of values. May be null.
    • HttpCsvArrayPart

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

      public HttpCsvArrayPart(String name, Supplier<String[]> supplier)
      Constructor accepting a lazy supplier of array values.
      Parameters:
      name - The part name. Must not be null.
      supplier - Supplier for the array value. Must not be null.
  • Method Details

    • of

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

      public static HttpCsvArrayPart ofString(String name, String value)
      Creates an HttpCsvArrayPart by parsing the given comma-delimited 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 HttpCsvArrayPart ofLazy(String name, Supplier<String[]> supplier)
      Creates an HttpCsvArrayPart with a lazy array supplier.
      Parameters:
      name - The part name. Must not be null.
      supplier - Supplier for the array value. Must not be null.
      Returns:
      A new instance. Never null.
    • asArray

      public Optional<String[]> asArray()
      Returns the value as a copy of the underlying array, wrapped in an Optional.
      Returns:
      The array value, wrapped in an Optional. Never null.
    • asList

      public Optional<List<String>> asList()
      Returns the value as an unmodifiable List, wrapped in an Optional.
      Returns:
      The list value, wrapped in an Optional. Never null.
    • contains

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

      public boolean containsIgnoreCase(String val)
      Returns true if this part contains the given value (case-insensitive).
      Parameters:
      val - The value to check for.
      Returns:
      true if the value is present.
    • toArray

      public String[] toArray()
      Returns a copy of the underlying array, or null if not set.
      Returns:
      The array, possibly null.
    • toList

      public List<String> toList()
      Returns the value as an unmodifiable List, or null if not set.
      Returns:
      The list, possibly null.
    • orElse

      public String[] orElse(String[] other)
      Returns the value if present, otherwise returns other.
      Parameters:
      other - The default value.
      Returns:
      The value or other.