Class AbstractArrayArg<T>

  • Type Parameters:
    T - the type of elements the array contains
    All Implemented Interfaces:
    Arg<List<T>>
    Direct Known Subclasses:
    AbstractEntityArrayArg, ExcludeArg, StringArrayArg

    public abstract class AbstractArrayArg<T>
    extends AbstractArg<List<T>>
    Represents a comma-delimited array API argument.

    If you use this alongside a QueryParam, make sure that you include a Parameter with the 'explode' attribute set to Explode.FALSE, otherwise the serialization will not be correct.

    Author:
    tesarst
    • Field Detail

      • ARRAY_SCHEMA_DESCRIPTION_PREFIX

        public static final String ARRAY_SCHEMA_DESCRIPTION_PREFIX
        Prefix to use to describe the array schema in subclasses.
        See Also:
        ArraySchema, Constant Field Values
      • ARRAY_SCHEMA_COMPRESSION_DESCRIPTION

        public static final String ARRAY_SCHEMA_COMPRESSION_DESCRIPTION
        A description of the base64-gzip encoding to use in array schema descriptions in subclasses.
        See Also:
        ArraySchema, Constant Field Values
    • Constructor Detail

      • AbstractArrayArg

        protected AbstractArrayArg​(List<T> values)
    • Method Detail

      • valueOf

        protected static <T extends AbstractArrayArg<?>> T valueOf​(String arg,
                                                                   String ofWhat,
                                                                   Function<List<String>,​T> func,
                                                                   boolean decompressArg)
                                                            throws MalformedArgException
        Evaluate an input array argument.

        Split a string by the ',' comma character and trim the resulting pieces.

        This is meant to be used for parsing query arguments that use a comma as a delimiter.

        Parameters:
        arg - the string to process
        ofWhat - a description of what is expected
        func - a function to convert the resulting list of string to the specific array argument
        decompressArg - decompress the argument as per ArgUtils.decodeCompressedArg(String)
        Returns:
        trimmed strings exploded from the input.
        Throws:
        MalformedArgException - wrapping any raised IllegalArgumentException which may be caused by an empty string, an invalid base64-gzip encoded input or such an exception raised by the passed function