Class BasicCsvHeader

java.lang.Object
org.apache.juneau.http.header.BasicHeader
org.apache.juneau.http.header.BasicCsvHeader
All Implemented Interfaces:
Serializable, Cloneable, Header, NameValuePair
Direct Known Subclasses:
Allow, ContentLanguage, Thrown, Upgrade, Via

public class BasicCsvHeader extends BasicHeader
Category of headers that consist of a comma-delimited list of string values.

Example

Allow: GET, PUT

See Also:
  • Constructor Details

  • Method Details

    • of

      public static BasicCsvHeader of(String name, String value)
      Static creator.
      Parameters:
      name - The header name.
      value - The header value.
      Must be a comma-delimited list.
      Can be null.
      Returns:
      A new header bean, or null if the value is null.
      Throws:
      IllegalArgumentException - If name is null or empty.
    • of

      public static BasicCsvHeader of(String name, String... value)
      Static creator.
      Parameters:
      name - The header name.
      value - The header value.
      Can be null.
      Returns:
      A new header bean, or null if the value is null.
      Throws:
      IllegalArgumentException - If name is null or empty.
    • of

      public static BasicCsvHeader of(String name, Supplier<String[]> value)
      Static creator with delayed value.

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

      Parameters:
      name - The header name.
      value - The supplier of the header value.
      Can be null.
      Returns:
      A new header bean, or null if the value is null.
      Throws:
      IllegalArgumentException - If name is null or empty.
    • getValue

      public String getValue()
      Specified by:
      getValue in interface NameValuePair
      Overrides:
      getValue in class BasicHeader
    • asArray

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

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

      Returns:
      The header value as an array wrapped in an Optional. Never null.
    • toArray

      public String[] toArray()
      Returns the header value as an array.

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

      Returns:
      The header value as an array. Can be null.
    • asList

      public Optional<List<String>> asList()
      Returns the header value as a list wrapped in an Optional.

      The list is unmodifiable.

      Returns:
      The header value as a list wrapped in an Optional. Never null.
    • toList

      public List<String> toList()
      Returns the header value as a list.

      The list is unmodifiable.

      Returns:
      The header value as a list. Can be null.
    • contains

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

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

      Provides the ability to perform fluent-style assertions on this header.
      Returns:
      A new fluent assertion object.
      Throws:
      AssertionError - If assertion failed.
    • 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.