Class ArrayObject
- java.lang.Object
-
- org.pepstock.charba.client.commons.Array
-
- org.pepstock.charba.client.commons.ArrayObject
-
- All Implemented Interfaces:
IsJSType
@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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ArrayObject.ArrayFilterCallback
Java script FUNCTION callback called to filter the array.static interface
ArrayObject.ArrayFindCallback
Java script FUNCTION callback called to find an element in the array.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ArrayObject
filter(ArrayObject.ArrayFilterCallback callback)
Creates a new array with all elements that pass the test implemented by the provided function.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.static <E extends NativeObjectContainer>
ArrayObjectfromOrEmpty(E item)
Creates a java script array of objects starting from a native object containers and the array will have ONE 1 element.static <E extends NativeObjectContainer>
ArrayObjectfromOrEmpty(E[] items)
Creates a java script array of objects starting from an array of native object containers.static <E extends NativeObjectContainer>
ArrayObjectfromOrEmpty(List<E> items)
Creates a java script array of objects starting from a list of native object containers.static ArrayObject
fromOrEmpty(NativeObject item)
Creates a java script array of objects starting from a native object containers and the array will have ONE 1 element.static <E extends NativeObjectContainer>
ArrayObjectfromOrNull(E item)
Creates a java script array of objects starting from a native object containers and the array will have ONE 1 element.static <E extends NativeObjectContainer>
ArrayObjectfromOrNull(E[] items)
Creates a java script array of objects starting from an array of native object containers.static <E extends NativeObjectContainer>
ArrayObjectfromOrNull(List<E> items)
Creates a java script array of objects starting from a list of native object containers.static ArrayObject
fromOrNull(NativeObject item)
Creates a java script array of objects starting from a native object and the array will have ONE 1 element.NativeObject
get(int index)
Gets the value at a given index.
-
-
-
Method Detail
-
fromOrNull
@JsOverlay public static ArrayObject fromOrNull(NativeObject item)
Creates a java script array of objects starting from a native object and the array will have ONE 1 element.- Parameters:
item
- single object to load in the new java script array.- Returns:
- new array instance of ONE 1 element or
null
if argument isnull
-
fromOrEmpty
@JsOverlay public static ArrayObject fromOrEmpty(NativeObject item)
Creates a java script array of objects starting from a native object containers and the array will have ONE 1 element.- Parameters:
item
- single object 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 NativeObjectContainer> ArrayObject 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 isnull
-
fromOrEmpty
@JsOverlay public static <E extends NativeObjectContainer> ArrayObject 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 NativeObjectContainer> ArrayObject 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 isnull
or length to 0
-
fromOrEmpty
@JsOverlay public static <E extends NativeObjectContainer> ArrayObject 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 NativeObjectContainer> ArrayObject 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 isnull
or empty
-
fromOrEmpty
@JsOverlay public static <E extends NativeObjectContainer> ArrayObject 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.
-
-