Class ArrayObject


  • @JsType(isNative=true,
            name="Array",
            namespace="<global>")
    public final class ArrayObject
    extends Array
    Array object which maps the java script object.
    A simple wrapper around a homogeneous native array of object (extension of java script objects) values.
    Author:
    Andrea "Stock" Stocchero
    • Method Detail

      • fromOrNull

        @JsOverlay
        public static <E extends NativeObjectContainerArrayObject fromOrNull​(E item)
        Creates a java script array of objects starting from a native object containers and the array will have ONE 1 element.
        Type Parameters:
        E - type of native object containers
        Parameters:
        item - single object to load in the new java script array.
        Returns:
        new array instance of ONE 1 element or null if argument is null
      • fromOrEmpty

        @JsOverlay
        public static <E extends NativeObjectContainerArrayObject fromOrEmpty​(E item)
        Creates a java script array of objects starting from a native object containers and the array will have ONE 1 element.
        Type Parameters:
        E - type of native object containers
        Parameters:
        item - list of objects to load in the new java script array.
        Returns:
        new array instance of ONE 1 element or an empty array if argument is null
      • fromOrNull

        @JsOverlay
        public static <E extends NativeObjectContainerArrayObject fromOrNull​(E[] items)
        Creates a java script array of objects starting from an array of native object containers.
        Type Parameters:
        E - type of native object containers
        Parameters:
        items - list of objects to load in the new java script array.
        Returns:
        new array instance of objects or null if argument is null or length to 0
      • fromOrEmpty

        @JsOverlay
        public static <E extends NativeObjectContainerArrayObject fromOrEmpty​(E[] items)
        Creates a java script array of objects starting from an array of native object containers.
        Type Parameters:
        E - type of native object containers
        Parameters:
        items - list of objects to load in the new java script array.
        Returns:
        new array instance of objects or an empty array if argument is null or length to 0
      • fromOrNull

        @JsOverlay
        public static <E extends NativeObjectContainerArrayObject fromOrNull​(List<E> items)
        Creates a java script array of objects starting from a list of native object containers.
        Type Parameters:
        E - type of native object containers
        Parameters:
        items - list of objects to load in the new java script array.
        Returns:
        new array instance of objects or null if the argument is null or empty
      • fromOrEmpty

        @JsOverlay
        public static <E extends NativeObjectContainerArrayObject fromOrEmpty​(List<E> items)
        Creates a java script array of objects starting from a list of native object containers.
        Type Parameters:
        E - type of native object containers
        Parameters:
        items - list of objects to load in the new java script array.
        Returns:
        new array instance of objects or an empty array if argument is null or empty
      • get

        @JsOverlay
        public NativeObject get​(int index)
        Gets the value at a given index. If no value exists at the given index, a type-conversion error will occur in Development Mode and unpredictable behavior may occur in Production Mode. If the numeric value returned is non-integral, it will cause a warning in Development Mode, and may affect the results of mathematical expressions.
        Parameters:
        index - the index to be retrieved
        Returns:
        the value at the given index
      • filter

        public ArrayObject filter​(ArrayObject.ArrayFilterCallback callback)
        Creates a new array with all elements that pass the test implemented by the provided function.
        Parameters:
        callback - is a predicate, to test each element of the array.
        Return a value that coerces to true to keep the element, or to false otherwise.
        Returns:
        a new array with the elements that pass the test.
        If no elements pass the test, an empty array will be returned.
      • find

        public NativeObject find​(ArrayObject.ArrayFindCallback callback)
        Returns the value of the first element in the provided array that satisfies the provided testing function.
        If no values satisfy the testing function, undefined is returned.
        Parameters:
        callback - function to execute on each value in the array,
        Returns:
        the value of the first element in the array that satisfies the provided testing function.
        Otherwise, undefined is returned.