Skip to content
Reference > Classes

List

Definition

List var = .... ;

Extends

Extended By

None

Description

An ordered collection of data used for random access based on position. Entries are stored in the order added (Backed by Java ArrayList)

Method Summary

Owner Name Return Type Description
List constructor(list_elements) Object Initialize a list with specified elements
List add(values) Object Adds the values to the end of the list.
Collection addAll(valuesToAdd) Object adds all elements to this collection
List batch(batchSize) List Divides the list into batches (a list of lists), based on the supplied batch size. For example, a list of 13 elements batched using 5 would result in a list of three lists, first list containing elements 1..5, a second list of elements 6..10 and the final third list containing the remaining elements 11..13.
Collection clear() Boolean Removes all elements in this collection. Returns true if this operation removed at least 1 element, returns false if it was empty
List contains(value) Boolean Returns true if the element is in the list.
List get(index) Object Returns the value at the supplied index or null if index is null, or out of bound.
Object getClassName() String Returns the string name of this object's class type.
List indexOf(value) Integer Returns the index of the first occurrence of the specified element is in this list, returns -1 if no such index exists.
Iterable iterator() Iterator Returns an iterator over this containers objects
List jsonPath(jsonPath) Object returns the json at the path, null string is this object, use dot to delimit path
List remove(index) Object Removes the value at the index. Returns the removed element.
List set(index, element) Object Replaces the element at the specified position in this list with the specified element. Returns the replaced element.
Collection size() Integer Returns the size of this collection
Collection sort() List Returns a list with the specified collection sorted according the elements' natural ordering. This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort
List splice(index, howmany, values) Integer Inserts, deletes or replaces items in this list. Returns ths size of the resulting list.
Object toJson() String Returns a json representation of this object.

Method Definitions


constructor(list_elements)

List list = new List(Object ... list_elements)

Description

Initialize a list with specified elements

Parameter Definition

Name Type Description
list_elements Object ...  Element to be added in list construction

add(values)

Object List::add(Object ... values)

Description

Adds the values to the end of the list.

Parameter Definition

Name Type Description
values Object ...  ordered list of values

batch(batchSize)

List List::batch(Integer batchSize)

Description

Divides the list into batches (a list of lists), based on the supplied batch size. For example, a list of 13 elements batched using 5 would result in a list of three lists, first list containing elements 1..5, a second list of elements 6..10 and the final third list containing the remaining elements 11..13.

Parameter Definition

Name Type Description
batchSize Integer  the maximum size of each batch

contains(value)

Boolean List::contains(Object value)

Description

Returns true if the element is in the list.

Parameter Definition

Name Type Description
value Object  element

get(index)

Object List::get(Integer index)

Description

Returns the value at the supplied index or null if index is null, or out of bound.

Parameter Definition

Name Type Description
index Integer  zero based index

indexOf(value)

Integer List::indexOf(Object value)

Description

Returns the index of the first occurrence of the specified element is in this list, returns -1 if no such index exists.

Parameter Definition

Name Type Description
value Object  element

jsonPath(jsonPath)

Object List::jsonPath(String jsonPath)

Description

returns the json at the path, null string is this object, use dot to delimit path

Parameter Definition

Name Type Description
jsonPath String  dot(.) delimited path

remove(index)

Object List::remove(Integer index)

Description

Removes the value at the index. Returns the removed element.

Parameter Definition

Name Type Description
index Integer  position of value to remove

set(index,element)

Object List::set(Integer index, Object element)

Description

Replaces the element at the specified position in this list with the specified element. Returns the replaced element.

Parameter Definition

Name Type Description
index Integer  position
element Object  value

splice(index,howmany,values)

Integer List::splice(Integer index, Integer howmany, Object ... values)

Description

Inserts, deletes or replaces items in this list. Returns ths size of the resulting list.

Parameter Definition

Name Type Description
index Integer  zero based index
howmany Integer  number of items to replace
values Object ...  values to use in replacement