Package jsonvalues

Interface JsObj

    • Method Detail

      • 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
      • 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:
        UserError - if this json object is empty
      • 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:
        UserError - if this json object is empty
      • intersection

        JsObj intersection​(JsObj that,
                           JsArray.TYPE ARRAY_AS)
        this.intersection(that, SET) returns an array with the elements that exist in both this and that this.intersection(that, MULTISET) returns an array with the elements that exist in both this and that, being duplicates allowed. this.intersection(that, LIST) returns an array with the elements that exist in both this and that, and are located at the same position.
        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)
        this.intersection_(that) behaves as this.intersection(that, LIST), but for those elements that are containers of the same type and are located at the same position, the result is their intersection. So this operation is kind of a 'recursive' intersection.
        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 this json object plus those pairs from the given json object that which keys don't exist in this. Taking that into account, it's not a commutative operation unless the elements associated with the keys that exist in both json objects are equals.
        Parameters:
        that - the given json object
        Returns:
        a new JsObj of the same type as the inputs (mutable or immutable)
      • union_

        JsObj union_​(JsObj that,
                     JsArray.TYPE ARRAY_AS)
        behaves like the union(JsObj) but, for those keys that exit in both this and that json objects, which associated elements are **containers of the same type**, the result is their union. In this case, we can specify if arrays are considered Sets, Lists, or MultiSets. So this operation is kind of a 'recursive' union.
        Parameters:
        that - the given json 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)
      • isObj

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

        boolean same​(JsObj other)