Package jsonvalues

Class ImmutableJsons.ImmutableJsObjs

  • Enclosing class:
    ImmutableJsons

    public class ImmutableJsons.ImmutableJsObjs
    extends Object
    represents a factory of immutable Json objects
    • Method Detail

      • toImmutable

        public JsObj toImmutable​(JsObj mutable)
      • empty

        public JsObj empty()
        Returns the immutable empty object. The same instance is always returned.
        Returns:
        the singleton immutable empty JsObj
      • parse

        public TryObj parse​(String str)
        Tries to parse the string into an immutable object.
        Parameters:
        str - the string to be parsed
        Returns:
        a TryObj computation
      • parse

        public TryObj parse​(String str,
                            ParseBuilder builder)
        Tries to parse the string into an immutable object, performing the specified transformations during the parsing. It's faster to do certain operations right while the parsing instead of doing the parsing and applying them later.
        Parameters:
        str - string to be parsed
        builder - builder with the transformations that will be applied during the parsing
        Returns:
        a TryObj computation
      • of

        public JsObj of​(String key,
                        JsElem el)
        Returns a one-element immutable object.
        Parameters:
        key - name of a key
        el - JsElem to be associated to the key
        Returns:
        an immutable one-element JsObj
        Throws:
        UserError - if an elem is a mutable Json
      • of

        public JsObj of​(String key1,
                        JsElem el1,
                        String key2,
                        JsElem el2)
        Returns a two-element immutable object.
        Parameters:
        key1 - name of a key
        el1 - JsElem to be associated to the key1
        key2 - name of a key
        el2 - JsElem to be associated to the key2
        Returns:
        an immutable two-element JsObj
        Throws:
        UserError - if an elem is a mutable Json
      • of

        public JsObj of​(String key1,
                        JsElem el1,
                        String key2,
                        JsElem el2,
                        String key3,
                        JsElem el3)
        Returns a three-element immutable object.
        Parameters:
        key1 - name of a key
        el1 - JsElem to be associated to the key1
        key2 - name of a key
        el2 - JsElem to be associated to the key2
        key3 - name of a key
        el3 - JsElem to be associated to the key3
        Returns:
        an immutable three-element JsObj
        Throws:
        UserError - if an elem is a mutable Json
      • of

        public JsObj of​(String key1,
                        JsElem el1,
                        String key2,
                        JsElem el2,
                        String key3,
                        JsElem el3,
                        String key4,
                        JsElem el4)
        Returns a four-element immutable object.
        Parameters:
        key1 - name of a key
        el1 - JsElem to be associated to the key1
        key2 - name of a key
        el2 - JsElem to be associated to the key2
        key3 - name of a key
        el3 - JsElem to be associated to the key3
        key4 - name of a key
        el4 - JsElem to be associated to the key4
        Returns:
        an immutable four-element JsObj
        Throws:
        UserError - if an elem is a mutable Json
      • of

        public JsObj of​(String key1,
                        JsElem el1,
                        String key2,
                        JsElem el2,
                        String key3,
                        JsElem el3,
                        String key4,
                        JsElem el4,
                        String key5,
                        JsElem el5)
        Returns a five-element immutable object.
        Parameters:
        key1 - name of a key
        el1 - JsElem to be associated to the key1
        key2 - name of a key
        el2 - JsElem to be associated to the key2
        key3 - name of a key
        el3 - JsElem to be associated to the key3
        key4 - name of a key
        el4 - JsElem to be associated to the key4
        key5 - name of a key
        el5 - JsElem to be associated to the key5
        Returns:
        an immutable five-element JsObj
        Throws:
        UserError - if an elem is a mutable Json
      • of

        public JsObj of​(String key1,
                        JsElem el1,
                        String key2,
                        JsElem el2,
                        String key3,
                        JsElem el3,
                        String key4,
                        JsElem el4,
                        String key5,
                        JsElem el5,
                        String key6,
                        JsElem el6)
        Returns a six-element immutable object.
        Parameters:
        key1 - name of a key
        el1 - JsElem to be associated to the key1
        key2 - name of a key
        el2 - JsElem to be associated to the key2
        key3 - name of a key
        el3 - JsElem to be associated to the key3
        key4 - name of a key
        el4 - JsElem to be associated to the key4
        key5 - name of a key
        el5 - JsElem to be associated to the key5
        key6 - name of a key
        el6 - JsElem to be associated to the key6
        Returns:
        an immutable six-element JsObj
        Throws:
        UserError - if an elem is a mutable Json
      • of

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