Package jsonvalues

Class ImmutableJsons.ImmutableJsArrays

  • Enclosing class:
    ImmutableJsons

    public class ImmutableJsons.ImmutableJsArrays
    extends Object
    represents a factory of immutable Json arrays
    • Method Detail

      • empty

        public JsArray empty()
        Returns the immutable empty array. The same instance is always returned.
        Returns:
        the singleton immutable empty JsArray
      • of

        public JsArray of​(JsPair pair,
                          JsPair... others)
        Returns an immutable array from one or more pairs.
        Parameters:
        pair - a pair
        others - more optional pairs
        Returns:
        an immutable JsArray
        Throws:
        UserError - if an elem of a pair is mutable
      • of

        public JsArray of​(JsElem e,
                          JsElem e1)
        Returns an immutable two-element array.
        Parameters:
        e - a JsElem
        e1 - a JsElem
        Returns:
        an immutable two-element JsArray
        Throws:
        UserError - if an elem is a mutable Json
      • of

        public JsArray of​(JsElem e,
                          JsElem e1,
                          JsElem e2)
        Returns an immutable three-element array.
        Parameters:
        e - a JsElem
        e1 - a JsElem
        e2 - a JsElem
        Returns:
        an immutable three-element JsArray
        Throws:
        UserError - if an elem is a mutable Json
      • of

        public JsArray of​(JsElem e,
                          JsElem e1,
                          JsElem e2,
                          JsElem e3)
        Returns an immutable four-element array.
        Parameters:
        e - a JsElem
        e1 - a JsElem
        e2 - a JsElem
        e3 - a JsElem
        Returns:
        an immutable four-element JsArray
        Throws:
        UserError - if an elem is a mutable Json
      • of

        public JsArray of​(JsElem e,
                          JsElem e1,
                          JsElem e2,
                          JsElem e3,
                          JsElem e4)
        Returns an immutable five-element array.
        Parameters:
        e - a JsElem
        e1 - a JsElem
        e2 - a JsElem
        e3 - a JsElem
        e4 - a JsElem
        Returns:
        an immutable five-element JsArray
        Throws:
        UserError - if an elem is a mutable Json
      • of

        public JsArray of​(JsElem e,
                          JsElem e1,
                          JsElem e2,
                          JsElem e3,
                          JsElem e4,
                          JsElem... rest)
        Returns an immutable array.
        Parameters:
        e - a JsElem
        e1 - a JsElem
        e2 - a JsElem
        e3 - a JsElem
        e4 - a JsElem
        rest - more optional JsElem
        Returns:
        an immutable JsArray
        Throws:
        UserError - if an elem is a mutable Json
      • ofIterable

        public JsArray ofIterable​(Iterable<JsElem> iterable)
        returns an immutable json array from an iterable of json elements
        Parameters:
        iterable - the iterable of json elements
        Returns:
        an immutable json array
      • of

        public JsArray of​(String str,
                          String... others)
        Returns an immutable array from one or more strings.
        Parameters:
        str - a string
        others - more optional strings
        Returns:
        an immutable JsArray
      • of

        public JsArray of​(int number,
                          int... others)
        Returns an immutable array from one or more integers.
        Parameters:
        number - an integer
        others - more optional integers
        Returns:
        an immutable JsArray
      • of

        public JsArray of​(boolean bool,
                          boolean... others)
        Returns an immutable array from one or more booleans.
        Parameters:
        bool - an boolean
        others - more optional booleans
        Returns:
        an immutable JsArray
      • of

        public JsArray of​(long number,
                          long... others)
        Returns an immutable array from one or more longs.
        Parameters:
        number - a long
        others - more optional longs
        Returns:
        an immutable JsArray
      • of

        public JsArray of​(double number,
                          double... others)
        Returns an immutable array from one or more doubles.
        Parameters:
        number - a double
        others - more optional doubles
        Returns:
        an immutable JsArray
      • parse

        public TryArr parse​(String str)
        Tries to parse the string into an immutable json array.
        Parameters:
        str - the string to be parsed
        Returns:
        a TryArr computation