Class AnyList
-
-
Constructor Summary
Constructors Constructor Description AnyList()See AnyList(int). AnyList(int capacity)Construct a new list with AnyList.length of zero and optional initial capacity.
-
Method Summary
Modifier and Type Method Description final voidadd(@Nullable() @Nullable() Object item)Add itemto the end of this list.final voidaddAll(@NonNull() @NotNull() AnyList list)Add all the items of listto the end of this list.final AnyListaddThis(@Nullable() @Nullable() Object item)Add itemto the end of this list.final AnyListcopy()Return a shallow copy of this list. final AnyListfilter(@NonNull() @NotNull() Function1<Object, Boolean> predicate)Return a new list which contains the items of this list that match a specified predicate function. final Objectfirst()Return (nullable) The first item in this list. static AnyListfrom(@NonNull() @NotNull() List<Object> list)final Objectget(int index)Return (nullable) The item in this list at the specified index.final booleanincludes(@Nullable() @Nullable() Object item)Return trueif this list containsitem.final intindexOf(@Nullable() @Nullable() Object item)See indexOf(Object, int). final intindexOf(@Nullable() @Nullable() Object item, int start)Return first index in this list of item, or-1if not found.final voidinsertAll(int index, @NonNull() @NotNull() AnyList list)Insert all items of listinto this list, before the item (if any) atindex.final voidinsertAt(int index, @Nullable() @Nullable() Object item)Insert iteminto this list, before the item (if any) atindex.Iterator<Object>iterator()final Objectlast()Return (nullable) The last item in this list. final intlastIndexOf(@Nullable() @Nullable() Object item)See lastIndexOf(Object, int). final intlastIndexOf(@Nullable() @Nullable() Object item, int start)Return last index in this list of item, or-1if not found.static AnyListof(@Nullable() @Nullable() Array<Object> items)Return a new list of item type object?, containing the specifieditems.AnyListreversed()Return a reversed copy of this list. final voidset(int index, @Nullable() @Nullable() Object item)Set the item in this list at the specified index.static AnyListshare(@NonNull() @NotNull() ListBase list)Return a new com.sap.cloud.mobile.odata.AnyList that shares the ListBase.untypedList as the listparameter.final Objectsingle()Return (nullable) A single item from this list. final AnyListslice(int start)See slice(int, int). final AnyListslice(int start, int end)Return a slice of this list from index start(inclusive) to indexend(exclusive).final voidsortBy(@NonNull() @NotNull() Function2<Object, Object, Boolean> increasing)Sort this list in place (stable sort, O(n log n) complexity). final AnyListsorted()Return a sorted copy of this list using this list's default AnyList.comparer for ordering (stable sort, O(n log n) complexity). final AnyListsortedBy(@NonNull() @NotNull() Function2<Object, Object, Boolean> increasing)Return a sorted copy of this list (stable sort, O(n log n) complexity). List<Object>toGeneric()-
-
Constructor Detail
-
AnyList
AnyList()
See AnyList(int).
-
AnyList
AnyList(int capacity)
Construct a new list with AnyList.length of zero and optional initial
capacity. A list can expand in length beyond its initial capacity, but best performance will be obtained if the initial capacity is close to (and not less than) the list's maximum length.- Parameters:
capacity- Optional initial capacity.
-
-
Method Detail
-
add
final void add(@Nullable() @Nullable() Object item)
Add
itemto the end of this list.- Parameters:
item- (nullable) Item to be added.
-
addAll
final void addAll(@NonNull() @NotNull() AnyList list)
Add all the items of
listto the end of this list.- Parameters:
list- Items to be added.
-
addThis
@NonNull()@NotNull() final AnyList addThis(@Nullable() @Nullable() Object item)
Add
itemto the end of this list.- Parameters:
item- (nullable) Item to be added.- Returns:
This list.
-
copy
@NonNull()@NotNull() final AnyList copy()
Return a shallow copy of this list.
- Returns:
A shallow copy of this list.
-
filter
@NonNull()@NotNull() final AnyList filter(@NonNull() @NotNull() Function1<Object, Boolean> predicate)
Return a new list which contains the items of this list that match a specified predicate function. Ordering is preserved.
- Parameters:
predicate- Function to be applied to each item of this list.- Returns:
A new list which contains the items of this list that match a specified predicate function. Ordering is preserved.
-
first
@Nullable()@Nullable() final Object first()
Return (nullable) The first item in this list.
- Throws:
com.sap.cloud.mobile.odata.core.EmptyListException if the list is empty.
- Returns:
(nullable) The first item in this list.
-
get
@Nullable()@Nullable() final Object get(int index)
Return (nullable) The item in this list at the specified
index.- Throws:
com.sap.cloud.mobile.odata.core.ListIndexException if
indexis out of range (0 to AnyList.length - 1).
- Parameters:
index- Zero-based index.- Returns:
(nullable) The item in this list at the specified `index`.
-
includes
final boolean includes(@Nullable() @Nullable() Object item)
Return
trueif this list containsitem.- Parameters:
item- (nullable) Item for comparison.- Returns:
trueif this list containsitem.
-
indexOf
final int indexOf(@Nullable() @Nullable() Object item)
See indexOf(Object, int).
- Parameters:
item- Item parameter.- Returns:
(see linked method).
-
indexOf
final int indexOf(@Nullable() @Nullable() Object item, int start)
Return first index in this list of
item, or-1if not found.- Parameters:
item- (nullable) Item for comparison.start- Zero-based starting index (search moves forwards from this index).- Returns:
First index in this list of
item, or-1if not found.
-
insertAll
final void insertAll(int index, @NonNull() @NotNull() AnyList list)
Insert all items of
listinto this list, before the item (if any) atindex.- Throws:
com.sap.cloud.mobile.odata.core.ListIndexException if
indexis out of range (0 to AnyList.length).
- Parameters:
index- Zero-based index.list- List of items to be inserted.
-
insertAt
final void insertAt(int index, @Nullable() @Nullable() Object item)
Insert
iteminto this list, before the item (if any) atindex.- Throws:
com.sap.cloud.mobile.odata.core.ListIndexException if
indexis out of range (0 to AnyList.length).
- Parameters:
index- Zero-based index.item- (nullable) Item to be added.
-
last
@Nullable()@Nullable() final Object last()
Return (nullable) The last item in this list.
- Throws:
com.sap.cloud.mobile.odata.core.EmptyListException if the list is empty.
- Returns:
(nullable) The last item in this list.
-
lastIndexOf
final int lastIndexOf(@Nullable() @Nullable() Object item)
- Parameters:
item- Item parameter.- Returns:
(see linked method).
-
lastIndexOf
final int lastIndexOf(@Nullable() @Nullable() Object item, int start)
Return last index in this list of
item, or-1if not found.- Parameters:
item- (nullable) Item for comparison.start- Zero-based starting index (search moves backwards from this index).- Returns:
Last index in this list of
item, or-1if not found.
-
of
@NonNull()@NotNull() static AnyList of(@Nullable() @Nullable() Array<Object> items)
Return a new list of item type
object?, containing the specifieditems.- Parameters:
items- Items for the resulting list.- Returns:
A new list of item type
object?, containing the specifieditems.
-
reversed
@NonNull()@NotNull() AnyList reversed()
Return a reversed copy of this list.
- See Also:
- Returns:
a reversed copy of this list.
-
set
final void set(int index, @Nullable() @Nullable() Object item)
Set the item in this list at the specified
index.- Parameters:
index- Zero-based index.item- (nullable) Item value.
-
share
@NonNull()@NotNull() static AnyList share(@NonNull() @NotNull() ListBase list)
Return a new com.sap.cloud.mobile.odata.AnyList that shares the ListBase.untypedList as the
listparameter. To ensure type safety, items inlistthat do not have the item typeobject?will be removed.- Parameters:
list- List whose items will be shared by the resulting list.- Returns:
A new list of item type
object?, sharing the same items aslist.
-
single
@Nullable()@Nullable() final Object single()
Return (nullable) A single item from this list.
- Throws:
com.sap.cloud.mobile.odata.core.EmptyListException if the list has no items, com.sap.cloud.mobile.odata.core.NotUniqueException if the list has multiple items.
- Returns:
(nullable) A single item from this list.
-
slice
@NonNull()@NotNull() final AnyList slice(int start)
See slice(int, int).
- Parameters:
start- Start parameter.- Returns:
(see linked method).
-
slice
@NonNull()@NotNull() final AnyList slice(int start, int end)
Return a slice of this list from index
start(inclusive) to indexend(exclusive).- Parameters:
start- Zero-based starting index (inclusive), or negative for starting index relative to the end of this list.end- Zero-based ending index (exclusive), or negative for ending index relative to the end of this list.- Returns:
A slice of this list from index
start(inclusive) to indexend(exclusive).
-
sortBy
final void sortBy(@NonNull() @NotNull() Function2<Object, Object, Boolean> increasing)
Sort this list in place (stable sort, O(n log n) complexity).
- See Also:
- Parameters:
increasing- Predicate that returns `true` if its first argument should preceed its second argument in the desired ordering.
-
sorted
@NonNull()@NotNull() final AnyList sorted()
Return a sorted copy of this list using this list's default AnyList.comparer for ordering (stable sort, O(n log n) complexity).
- See Also:
- Returns:
a sorted copy of this list using this list's default AnyList.comparer for ordering (stable sort, O(n log n) complexity).
-
sortedBy
@NonNull()@NotNull() final AnyList sortedBy(@NonNull() @NotNull() Function2<Object, Object, Boolean> increasing)
Return a sorted copy of this list (stable sort, O(n log n) complexity).
- See Also:
- Parameters:
increasing- Predicate that returns `true` if its first argument should preceed its second argument in the desired ordering.- Returns:
a sorted copy of this list (stable sort, O(n log n) complexity).
-
-
-
-