Enum Class CollectionFormat

java.lang.Object
java.lang.Enum<CollectionFormat>
org.apache.juneau.rest.client.CollectionFormat
All Implemented Interfaces:
Serializable, Comparable<CollectionFormat>, Constable

Specifies how collection-valued query/form parameters are serialized to a single string.

When a parameter value is an Iterable or array, the elements are joined using the delimiter corresponding to the selected format. REPEATED instead emits one name=value pair per element.

Since:
9.2.1
  • Enum Constant Details

    • COMMA

      public static final CollectionFormat COMMA
      Elements joined with , — e.g. colors=red,green,blue.
    • PIPE

      public static final CollectionFormat PIPE
      Elements joined with | — e.g. colors=red|green|blue.
    • SPACE

      public static final CollectionFormat SPACE
      Elements joined with a space — e.g. colors=red green blue.
    • TAB

      public static final CollectionFormat TAB
      Elements joined with \t (tab) — e.g. colors=red\tgreen\tblue.
    • REPEATED

      public static final CollectionFormat REPEATED
      One parameter per element — e.g. colors=red&colors=green&colors=blue. Handled specially by the request builder.
  • Method Details

    • values

      public static CollectionFormat[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static CollectionFormat valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • getDelimiter

      public String getDelimiter()
      Returns the delimiter string, or null for REPEATED.
      Returns:
      The delimiter, possibly null.
    • join

      public String join(Iterable<?> values)
      Serializes the given values to a single string using this format's delimiter.

      Only valid for non-REPEATED formats.

      Parameters:
      values - The values to join. Must not be null.
      Returns:
      The joined string. Never null.
      Throws:
      IllegalArgumentException - If called on REPEATED.