Package jsonvalues

Interface JsArray

    • Method Detail

      • equals

        default boolean equals​(JsArray array,
                               JsArray.TYPE ARRAY_AS)
        Returns true if this array is equal to the given as a parameter. In the case of ARRAY_AS=LIST, this method is equivalent to JsArray.equals(Object).
        Parameters:
        array - the given array
        ARRAY_AS - option to define if arrays are considered SETS, LISTS OR MULTISET
        Returns:
        true if both arrays are equals according to ARRAY_AS parameter
      • appendAll

        JsArray appendAll​(JsArray array)
        Adds all the elements of the given array, starting from the head, to the back of this array.
        Parameters:
        array - the JsArray of elements to be added to the back
        Returns:
        a new JsArray
      • prependAll

        JsArray prependAll​(JsArray array)
        Adds all the elements of the array, starting from the last, to the front of this array.
        Parameters:
        array - the JsArray of elements to be added to the front
        Returns:
        a new JsArray
      • append

        JsArray append​(JsElem elem,
                       JsElem... others)
        Adds one or more elements, starting from the first, to the back of this array.
        Parameters:
        elem - the JsElem to be added to the back.
        others - more optional JsElem to be added to the back
        Returns:
        a new JsArray
      • prepend

        JsArray prepend​(JsElem elem,
                        JsElem... others)
        Adds one or more elements, starting from the last, to the front of this array.
        Parameters:
        elem - the JsElem to be added to the front.
        others - more optional JsElem to be added to the front
        Returns:
        a new JsArray
      • head

        JsElem head()
        Returns the first element of this array.
        Returns:
        the first JsElem of this JsArray
        Throws:
        UserError - if this JsArray is empty
      • init

        JsArray init()
        Returns all the elements of this array except the last one.
        Returns:
        JsArray with all the JsElem except the last one
        Throws:
        UserError - if this JsArray is empty
      • last

        JsElem last()
        Returns the last element of this array.
        Returns:
        the last JsElem of this JsArray
        Throws:
        UserError - if this JsArray is empty
      • tail

        JsArray tail()
        Returns a json array consisting of all elements of this array except the first one.
        Returns:
        a JsArray consisting of all the elements of this JsArray except the head
        Throws:
        UserError - if this JsArray is empty.
      • intersection

        JsArray intersection​(JsArray 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 array
        ARRAY_AS - option to define if arrays are considered SETS, LISTS OR MULTISET
        Returns:
        a new JsArray of the same type as the inputs (mutable or immutable)
      • intersection_

        JsArray intersection_​(JsArray that)
        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 array
        Returns:
        a JsArray of the same type as the inputs (mutable or immutable)
      • union

        JsArray union​(JsArray that,
                      JsArray.TYPE ARRAY_AS)
        this.union(that, SET) returns this plus those elements from that that don't exist in this. this.union(that, MULTISET) returns this plus those elements from that appended to the back. this.union(that, LIST) returns this plus those elements from that which position is >= this.size().
        Parameters:
        that - the other array
        ARRAY_AS - option to define if arrays are considered SETS, LISTS OR MULTISET
        Returns:
        a new json array of the same type as the inputs (mutable or immutable)
      • union_

        JsArray union_​(JsArray that)
        returns this plus those elements from that which position is >= this.size(), and, at the positions where a container of the same type exists in both this and that, the result is their union. This operations doesn't make any sense if arrays are not considered lists, because there is no notion of order.
        Parameters:
        that - the other array
        Returns:
        a new JsArray of the same type as the inputs (mutable or immutable)
      • isArray

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

        boolean same​(JsArray other)