Package feign

Enum CollectionFormat

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<CollectionFormat>

    public enum CollectionFormat
    extends java.lang.Enum<CollectionFormat>
    Various ways to encode collections in URL parameters.

    These specific cases are inspired by the OpenAPI specification.

    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      CSV
      Comma separated values, eg foo=bar,baz
      EXPLODED
      Parameter name repeated for each value, eg foo=bar&foo=baz
      PIPES
      Values separated with the pipe (|) character, eg foo=bar|baz
      SSV
      Space separated values, eg foo=bar baz
      TSV
      Tab separated values, eg foo=bar[tab]baz
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.CharSequence join​(java.lang.String field, java.util.Collection<java.lang.String> values, java.nio.charset.Charset charset)
      Joins the field and possibly multiple values with the given separator.
      static CollectionFormat valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static CollectionFormat[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Enum Constant Detail

      • CSV

        public static final CollectionFormat CSV
        Comma separated values, eg foo=bar,baz
      • SSV

        public static final CollectionFormat SSV
        Space separated values, eg foo=bar baz
      • TSV

        public static final CollectionFormat TSV
        Tab separated values, eg foo=bar[tab]baz
      • PIPES

        public static final CollectionFormat PIPES
        Values separated with the pipe (|) character, eg foo=bar|baz
      • EXPLODED

        public static final CollectionFormat EXPLODED
        Parameter name repeated for each value, eg foo=bar&foo=baz
    • Method Detail

      • values

        public static CollectionFormat[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (CollectionFormat c : CollectionFormat.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static CollectionFormat valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • join

        public java.lang.CharSequence join​(java.lang.String field,
                                           java.util.Collection<java.lang.String> values,
                                           java.nio.charset.Charset charset)
        Joins the field and possibly multiple values with the given separator.

        Calling EXPLODED.join("foo", ["bar"]) will return "foo=bar".

        Calling CSV.join("foo", ["bar", "baz"]) will return "foo=bar,baz".

        Null values are treated somewhat specially. With EXPLODED, the field is repeated without any "=" for backwards compatibility. With all other formats, null values are not included in the joined value list.

        Parameters:
        field - The field name corresponding to these values.
        values - A collection of value strings for the given field.
        charset - to encode the sequence
        Returns:
        The formatted char sequence of the field and joined values. If the value collection is empty, an empty char sequence will be returned.