Class MultiValueCodec

java.lang.Object
io.jenkins.plugins.restlistparam.util.MultiValueCodec

public final class MultiValueCodec extends Object
Converts the value of a REST Multi List Parameter between its list form and its text form, a compact Json array of Json strings such as ["a","c"].

parse(encode(list)) yields list for every list of non-null strings.

  • Method Details

    • parse

      public static List<String> parse(String input)
      Reads a value supplied as a single string. A strict (RFC 4627) Json array whose elements are all Json strings becomes the list of those strings; the empty string and [] become the empty list; any other string, including malformed or non-strict Json such as [a,b], becomes a one-element list holding the string verbatim. The string is never split on a delimiter.
      Parameters:
      input - The supplied string
      Returns:
      The list of elements, or null when input is null
    • encode

      public static String encode(List<String> elements)
      Writes a list as a compact Json array of Json strings, with no whitespace between tokens. Every element is written as a Json string, even when its text is itself Json.
      Parameters:
      elements - The elements, none of them null
      Returns:
      The Json array text