Package jsonvalues

Interface JsObj

    • Method Detail

      • _empty_

        static JsObj _empty_()
        Returns a mutable empty object.
        Returns:
        a mutable empty JsObj
      • _of_

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

        static JsObj _of_​(String key1,
                          JsElem el1,
                          String key2,
                          JsElem el2)
        Returns a mutable two-pair 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:
        a two-pair mutable JsObj
        Throws:
        UnsupportedOperationException - if an elem is an immutable Json
      • _of_

        static JsObj _of_​(String key1,
                          JsElem el1,
                          String key2,
                          JsElem el2,
                          String key3,
                          JsElem el3)
        Returns a mutable three-pair 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:
        a three-pair mutable JsObj
        Throws:
        UnsupportedOperationException - if an elem is an immutable Json
      • _of_

        static JsObj _of_​(String key1,
                          JsElem el1,
                          String key2,
                          JsElem el2,
                          String key3,
                          JsElem el3,
                          String key4,
                          JsElem el4)
        Returns a mutable four-pair 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:
        a mutable four-pair JsObj
        Throws:
        UnsupportedOperationException - if an elem is an immutable Json
      • _of_

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

        static 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 mutable six-pair object.
        Parameters:
        key1 - name parse a key
        el1 - JsElem to be associated to the key1
        key2 - name parse a key
        el2 - JsElem to be associated to the key2
        key3 - name parse a key
        el3 - JsElem to be associated to the key3
        key4 - name parse a key
        el4 - JsElem to be associated to the key4
        key5 - name parse a key
        el5 - JsElem to be associated to the key5
        key6 - name parse a key
        el6 - JsElem to be associated to the key6
        Returns:
        a mutable six-element JsObj
        Throws:
        UnsupportedOperationException - if an elem is an immutable Json
      • _of_

        static JsObj _of_​(Map<String,​JsElem> map)
        Returns a mutable object from a map of elements.
        Parameters:
        map - the map of JsElem
        Returns:
        a mutable JsObj
        Throws:
        UnsupportedOperationException - if an elem of the map is an immutable Json
      • _parse_

        static TryObj _parse_​(String str)
        Tries to parse the string into a mutable json object.
        Parameters:
        str - the string to be parsed
        Returns:
        a TryObj computation
      • equals

        default boolean equals​(JsObj that,
                               JsArray.TYPE ARRAY_AS)
        return true if this obj is equal to the given as a parameter. In the case of ARRAY_AS=LIST, this method is equivalent to JsObj.equals(Object).
        Parameters:
        that - the given array
        ARRAY_AS - enum to specify if arrays are considered as lists or sets or multisets
        Returns:
        true if both objs are equals
      • _parse_

        static TryObj _parse_​(String str,
                              ParseOptions options)
        Tries to parse the string into an mutable object, performing some operations while 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
        options - a Options with the filters and maps that will be applied during the parsing
        Returns:
        a TryObj computation
      • collector

        static Collector<JsPair,​JsObj,​JsObj> collector()
        Returns a collector that accumulates the pairs from a stream into an immutable object.
        Returns:
        a Collector which collects all the pairs of elements into an immutable JsObj, in encounter order
      • _collector_

        static Collector<JsPair,​JsObj,​JsObj> _collector_()
        Returns a collector that accumulates the pairs from a stream into an mutable object.
        Returns:
        a Collector which collects all the pairs of elements into an mutable JsObj, in encounter order
      • empty

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

        Set<String> fields()
        Returns a set containing each key fo this object.
        Returns:
        a Set containing each key of this JsObj
      • head

        Map.Entry<String,​JsElem> head()
        Returns a pair with an arbitrary key of this object and its associated element. When using head and tail to process a JsObj, the key of the pair returned must be passed in to get the tail using the method tail(String).
        Returns:
        an arbitrary Map.Entry<String,JsElem> of this JsObj
        Throws:
        UnsupportedOperationException - if this json object is empty
      • of

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

        static 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:
        UnsupportedOperationException - if an elem is a mutable Json
      • of

        static JsObj of​(String key1,
                        JsElem el1,
                        String key2,
                        JsElem el2,
                        String key3,
                        JsElem el3)
        Returns a three-element immutable json 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:
        UnsupportedOperationException - if an elem is a mutable Json
      • of

        static 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:
        UnsupportedOperationException - if an elem is a mutable Json
      • of

        static 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:
        UnsupportedOperationException - if an elem is a mutable Json
      • of

        static 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:
        UnsupportedOperationException - if an elem is a mutable Json
      • of

        static JsObj of​(Map<String,​JsElem> map)
        Returns a immutable object from a map of elements.
        Parameters:
        map - the map of JsElem
        Returns:
        an immutable JsObj
        Throws:
        UnsupportedOperationException - if an elem of the map is a mutable Json
      • parse

        static 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

        static TryObj parse​(String str,
                            ParseOptions options)
        Tries to parse the string into an immutable object, performing some operations 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
        options - a Options with the filters and maps that will be applied during the parsing
        Returns:
        a TryObj computation
      • remove

        default JsObj remove​(String key)
        Removes the key from this object if it's present.
        Specified by:
        remove in interface Json<JsObj>
        Parameters:
        key - the key to be removed
        Returns:
        a new JsObj without the key or the same this JsObj if the key is not present
      • tail

        JsObj tail​(String key)
        Returns a new object with all the entries of this json object except the one with the given key.
        Parameters:
        key - the given key, which associated pair will be excluded
        Returns:
        a new JsObj
        Throws:
        UnsupportedOperationException - if this json object is empty
      • intersection

        JsObj intersection​(JsObj that,
                           JsArray.TYPE ARRAY_AS)
        Returns the intersection of this object and another, defining characteristics like order and duplicates occurrence in arrays with the given ARRAY_AS parameter.
        Parameters:
        that - the other obj
        ARRAY_AS - option to define if arrays are considered SETS, LISTS OR MULTISET
        Returns:
        a new JsObj of the same type as the inputs (mutable or immutable)
      • intersection_

        JsObj intersection_​(JsObj that,
                            JsArray.TYPE ARRAY_AS)
        Returns the intersection of this object and another given as parameter applying recursively the intersection to those elements which are Json of the same type and are located at the same key and defining characteristics like order and duplicates occurrence in arrays with the given ARRAY_AS parameter.
        Parameters:
        that - the other object
        ARRAY_AS - option to define if arrays are considered SETS, LISTS OR MULTISET
        Returns:
        a new JsObj of the same type as the inputs (mutable or immutable)
      • union

        JsObj union​(JsObj that)
        Returns the union of this object and another given as a parameter.
        Parameters:
        that - the other object
        Returns:
        a new JsObj of the same type as the inputs (mutable or immutable)
      • union_

        JsObj union_​(JsObj that,
                     JsArray.TYPE ARRAY_AS)
        Returns the union of this object and another given as parameter applying recursively the union to those elements which are Json of the same type and are located at the same key and defining characteristics like order and duplicates occurrence in arrays with the given ARRAY_AS parameter.
        Parameters:
        that - the other object
        ARRAY_AS - option to define if arrays are considered SETS, LISTS OR MULTISET
        Returns:
        a new JsObj of the same type as the inputs (mutable or immutable)
      • of

        static 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:
        UnsupportedOperationException - if an elem of a pair is mutable
      • _of_

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

        default boolean isObj()
        Specified by:
        isObj in interface JsElem
        Returns:
        true if this JsElem is a JsObj
      • isArray

        default boolean isArray()
        Specified by:
        isArray in interface JsElem
        Returns:
        true if this JsElem is a JsArray