Class JSCollection<T extends JSConvertable>
java.lang.Object
com.amalgamasimulation.desktop.html.js.JSCollection<T>
- Type Parameters:
T- the type of elements in the collection, which must implementJSConvertable
- All Implemented Interfaces:
JSConvertable
Represents a collection of JavaScript-convertible elements. It implements the
JSConvertable interface, allowing it to be converted to a JavaScript
array.- Author:
- Alexey Glazyrin
-
Field Summary
Fields inherited from interface com.amalgamasimulation.desktop.html.js.JSConvertable
NULL, UNDEFINED -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new JSCollection instanceJSCollection(List<T> value) Constructs a new JSCollection instance with the specified collection of elements. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds an element to the collection.static JSCollection<JSFunction> createFunctions(Collection<String> value) static <T> JSCollection<? extends JSConvertable> createPrimitive(Collection<T> value) Creates a new JSCollection instance from a collection of primitive values.voidintsize()toJS()Converts the collection to a JavaScript array string representation.
-
Constructor Details
-
JSCollection
Constructs a new JSCollection instance with the specified collection of elements.- Parameters:
value- the collection of elements to include in the JavaScript array
-
JSCollection
public JSCollection()Constructs a new JSCollection instance
-
-
Method Details
-
createPrimitive
Creates a new JSCollection instance from a collection of primitive values. Each value is wrapped in aJSPrimitiveobject.- Type Parameters:
T- the type of primitive values in the collection- Parameters:
value- the collection of primitive values- Returns:
- a new JSCollection instance containing the wrapped primitive values
-
createFunctions
-
add
Adds an element to the collection.- Parameters:
element- the element to add
-
set
-
size
public int size() -
toJS
Converts the collection to a JavaScript array string representation.- Specified by:
toJSin interfaceJSConvertable- Returns:
- the JavaScript array representation of the collection
-