public class ComplexValueList extends ListBase implements java.lang.Iterable<ComplexValue>
A list of item type ComplexValue
.
Uses the property and function naming conventions of the JavaScript Array object.
Modifier and Type | Field and Description |
---|---|
static ComplexValueList |
empty |
Constructor and Description |
---|
ComplexValueList()
|
ComplexValueList(int capacity)
Construct a new list with
ComplexValueList.length of zero and optional initial capacity . |
Modifier and Type | Method and Description |
---|---|
void |
add(ComplexValue item)
Add
item to the end of this list. |
void |
addAll(ComplexValueList list)
Add all the items of
list to the end of this list. |
ComplexValueList |
addNullable(ComplexValue item)
Append
item to the end of this list. |
ComplexValueList |
addThis(ComplexValue item)
Add
item to the end of this list. |
ComplexValueList |
applyPageSize(DataQuery query)
Return a new list with at most
query.pageSize initial items of this list. |
static ComplexValueList |
castRequired(DataValue value)
For internal use only.
|
ComplexValueList |
copy()
Return a shallow copy of this list.
|
static boolean |
equal(ComplexValueList a,
ComplexValueList b)
Return
true if two complex lists have equal items. |
ComplexValueList |
filterAndSort(DataQuery query)
Return a new list with the items of this list, filtered by
query.queryFilter and sorted by query.sortItems . |
ComplexValueList |
filterWithQuery(DataQuery query)
Return a new list with the items of this list, filtered by
query.queryFilter , query.derivedType (whichever of those is specified, if any). |
ComplexValue |
first()
Return the first item in this list.
|
static ComplexValueList |
from(java.util.List<ComplexValue> list) |
static ComplexValueList |
fromNullable(java.util.List<ComplexValue> list) |
ComplexValue |
get(int index)
Return the item in this list at the specified
index . |
DataType |
getDataType()
Return the data type for this list.
|
java.lang.String |
getNextLink()
Return (nullable) An optional link that can be followed (by the caller) to fetch additional list items.
|
ComplexValue |
getNullable(int index)
Return (nullable) The item in this list at the specified
index , which may be null . |
java.lang.String |
getReadLink()
Return (nullable) An optional link that can be followed (by the caller) to re-read this list.
|
java.lang.Long |
getTotalCount()
Return (nullable) Total number of items available in the server-side list, which may be greater than
ComplexValueList.length if the client requested an inline DataQuery.count . |
boolean |
includes(ComplexValue item)
Return
true if this list contains item . |
int |
indexOf(ComplexValue item)
|
int |
indexOf(ComplexValue item,
int start)
Return first index in this list of
item , or -1 if not found. |
void |
insertAll(int index,
ComplexValueList list)
Insert all items of
list into this list, before the item (if any) at index . |
void |
insertAt(int index,
ComplexValue item)
Insert
item into this list, before the item (if any) at index . |
boolean |
isReference()
Return
true if this list is a referece. |
java.util.Iterator<ComplexValue> |
iterator() |
ComplexValue |
last()
Return the last item in this list.
|
int |
lastIndexOf(ComplexValue item)
|
int |
lastIndexOf(ComplexValue item,
int start)
Return last index in this list of
item , or -1 if not found. |
void |
set(int index,
ComplexValue item)
Set the item in this list at the specified
index . |
void |
setNextLink(java.lang.String value)
Set an optional link that can be followed (by the caller) to fetch additional list items.
|
void |
setNullable(int index,
ComplexValue item)
Set the item in this list at the specified
index . |
void |
setReadLink(java.lang.String value)
Set an optional link that can be followed (by the caller) to re-read this list.
|
void |
setReference(boolean value)
Set
true if this list is a referece. |
void |
setTotalCount(java.lang.Long value)
Set total number of items available in the server-side list, which may be greater than
ComplexValueList.length if the client requested an inline DataQuery.count . |
static ComplexValueList |
share(ListBase list)
|
static ComplexValueList |
shareNullable(ListBase list)
Return a new ComplexValueList that shares the
ListBase.untypedList as the list parameter, including nulls. |
ComplexValue |
single()
Return a single item from this list.
|
ComplexValueList |
skipAndTop(DataQuery query)
Return a new list with at most
query.topCount items of this list, starting at index query.skipCount . |
ComplexValueList |
slice(int start)
See slice(int, int).
|
ComplexValueList |
slice(int start,
int end)
Return a slice of this list from index
start (inclusive) to index end (exclusive). |
void |
sortWithQuery(DataQuery query)
Sort this list in-place, using
query.sortItems . |
java.util.List<ComplexValue> |
toGeneric() |
ComplexValueList |
withItemType(DataType type)
Override the type of this list, and return this list.
|
ComplexValueListWithNulls |
withNulls()
Return an iterator of this list which uses a nullable item type.
|
ComplexValueList |
withType(DataType type)
Override the type of this list, and return this list.
|
clear, getComparer, getEquality, getUntypedList, isEmpty, length, removeAt, removeFirst, removeLast, removeRange, reverse, shareWith, sort, sortWith, toDynamic, toString, validate
cloneMutable, equals, getTypeCode, hashCode
public static final ComplexValueList empty
public ComplexValueList()
public ComplexValueList(int capacity)
Construct a new list with ComplexValueList.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 the list's maximum length.
capacity
- Optional initial capacity.public void add(ComplexValue item)
Add item
to the end of this list.
item
- Item to be added.public void addAll(ComplexValueList list)
Add all the items of list
to the end of this list.
list
- Items to be added.public ComplexValueList addNullable(ComplexValue item)
Append item
to the end of this list.
It is unusual for a ComplexValueList
to contain null
items, so ComplexValueList.add
is usually used.
item
- (nullable) Item to be added, which might be null
.public ComplexValueList addThis(ComplexValue item)
Add item
to the end of this list.
item
- Item to be added.public ComplexValueList applyPageSize(DataQuery query)
Return a new list with at most query.pageSize
initial items of this list. The result's ComplexValueList.needsNextLink
will be true
if the original list length exceeded the page size.
query
- Data query whose DataQuery.pageSize
is used for filtering.query.pageSize
initial items of this list. The result's ComplexValueList.needsNextLink
will be true
if the original list length exceeded the page size.public static ComplexValueList castRequired(DataValue value)
For internal use only.
value
- (internal use only)public ComplexValueList copy()
Return a shallow copy of this list.
public static boolean equal(ComplexValueList a, ComplexValueList b)
Return true
if two complex lists have equal items.
a
- (nullable) First complex list.b
- (nullable) Second complex list.public ComplexValueList filterAndSort(DataQuery query)
Return a new list with the items of this list, filtered by query.queryFilter
and sorted by query.sortItems
.
query
- Data query whose DataQuery.queryFilter
is used for filtering and whose DataQuery.sortItems
are used for sorting.query.queryFilter
and sorted by query.sortItems
.public ComplexValueList filterWithQuery(DataQuery query)
Return a new list with the items of this list, filtered by query.queryFilter
, query.derivedType
(whichever of those is specified, if any).
query
- Data query used for filtering.query.queryFilter
, query.derivedType
(whichever of those is specified, if any).public ComplexValue first()
Return the first item in this list.
EmptyListException
if the list is empty.
public static ComplexValueList from(java.util.List<ComplexValue> list)
public static ComplexValueList fromNullable(java.util.List<ComplexValue> list)
public ComplexValue get(int index)
Return the item in this list at the specified index
.
ListIndexException
if index
is out of range (0 to ComplexValueList.length
- 1).
index
- Zero-based index.public DataType getDataType()
Return the data type for this list.
getDataType
in class ListBase
public java.lang.String getNextLink()
Return (nullable) An optional link that can be followed (by the caller) to fetch additional list items. If this complex list was produced via server-driven paging, then the server may have provided a next-link which can be followed to obtain more items.
public ComplexValue getNullable(int index)
Return (nullable) The item in this list at the specified index
, which may be null
.
It is unusual for a ComplexValueList
to contain null
items, so ComplexValueList.get
is usually used.
ListIndexException
if index
is out of range (0 to ComplexValueList.length
- 1).
index
- Zero-based index.public java.lang.String getReadLink()
Return (nullable) An optional link that can be followed (by the caller) to re-read this list.
public java.lang.Long getTotalCount()
Return (nullable) Total number of items available in the server-side list, which may be greater than ComplexValueList.length
if the client requested an inline DataQuery.count
.
ComplexValueList.length
if the client requested an inline DataQuery.count
.public boolean includes(ComplexValue item)
Return true
if this list contains item
.
item
- Item for comparison. Comparison uses the ComplexValueList.equality
property, which would usually be expected to match the ==
operator for item type ComplexValue
.true
if this list contains item
.public int indexOf(ComplexValue item)
item
- Item parameter.public int indexOf(ComplexValue item, int start)
Return first index in this list of item
, or -1
if not found.
item
- Item for comparison. Comparison uses the ComplexValueList.equality
property, which would usually be expected to match the ==
operator for item type ComplexValue
.start
- Zero-based starting index (search moves forwards from this index).item
, or -1
if not found.public void insertAll(int index, ComplexValueList list)
Insert all items of list
into this list, before the item (if any) at index
.
ListIndexException
if index
is out of range (0 to ComplexValueList.length
).
index
- Zero-based index.list
- List of items to be inserted.public void insertAt(int index, ComplexValue item)
Insert item
into this list, before the item (if any) at index
.
ListIndexException
if index
is out of range (0 to ComplexValueList.length
).
index
- Zero-based index.item
- Item to be added.public boolean isReference()
Return true
if this list is a referece. If true
, the ComplexValueList.readLink
will be non-null, and this list will be empty.
true
if this list is a referece. If true
, the ComplexValueList.readLink
will be non-null, and this list will be empty.public java.util.Iterator<ComplexValue> iterator()
iterator
in interface java.lang.Iterable<ComplexValue>
public ComplexValue last()
Return the last item in this list.
EmptyListException
if the list is empty.
public int lastIndexOf(ComplexValue item)
item
- Item parameter.public int lastIndexOf(ComplexValue item, int start)
Return last index in this list of item
, or -1
if not found.
item
- Item for comparison. Comparison uses the ComplexValueList.equality
property, which would usually be expected to match the ==
operator for item type ComplexValue
.start
- Zero-based starting index (search moves backwards from this index).item
, or -1
if not found.public void set(int index, ComplexValue item)
Set the item in this list at the specified index
.
index
- Zero-based index.item
- Item value.public void setNextLink(java.lang.String value)
Set an optional link that can be followed (by the caller) to fetch additional list items. If this complex list was produced via server-driven paging, then the server may have provided a next-link which can be followed to obtain more items.
value
- An optional link that can be followed (by the caller) to fetch additional list items.public void setNullable(int index, ComplexValue item)
Set the item in this list at the specified index
.
It is unusual for a ComplexValueList
to contain null
items, so ComplexValueList.set
is usually used.
index
- Zero-based index.item
- (nullable) Item value, which might be null
.public void setReadLink(java.lang.String value)
Set an optional link that can be followed (by the caller) to re-read this list.
value
- An optional link that can be followed (by the caller) to re-read this list.public void setReference(boolean value)
Set true
if this list is a referece. If true
, the ComplexValueList.readLink
will be non-null, and this list will be empty.
value
- true
if this list is a referece. If true
, the ComplexValueList.readLink
will be non-null, and this list will be empty.public void setTotalCount(java.lang.Long value)
Set total number of items available in the server-side list, which may be greater than ComplexValueList.length
if the client requested an inline DataQuery.count
.
value
- Total number of items available in the server-side list, which may be greater than ComplexValueList.length
if the client requested an inline DataQuery.count
.public static ComplexValueList share(ListBase list)
Return a new ComplexValueList
that shares the ListBase.untypedList
as the list
parameter.
To ensure type safety, items in list
that do not have the item type ComplexValue
will be removed.
list
- List whose items will be shared by the resulting list.ComplexValue
, sharing the same items as list
.public static ComplexValueList shareNullable(ListBase list)
Return a new ComplexValueList that shares the ListBase.untypedList
as the list
parameter, including nulls.
To ensure type safety, items in list
that do not have the item type will be removed.
list
- List whose items will be shared by the resulting list.ComplexValue
, sharing the same items as list
.public ComplexValue single()
Return a single item from this list.
EmptyListException
if the list has no items, NotUniqueException
if the list has multiple items.
public ComplexValueList skipAndTop(DataQuery query)
Return a new list with at most query.topCount
items of this list, starting at index query.skipCount
.
query
- Data query whose DataQuery.skipCount
and DataQuery.topCount
are used for filtering.query.topCount
items of this list, starting at index query.skipCount
.public ComplexValueList slice(int start)
start
- Start parameter.public ComplexValueList slice(int start, int end)
Return a slice of this list from index start
(inclusive) to index end
(exclusive).
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.start
(inclusive) to index end
(exclusive).public void sortWithQuery(DataQuery query)
Sort this list in-place, using query.sortItems
.
query
- Data query whose whose DataQuery.sortItems
are used for filtering.public java.util.List<ComplexValue> toGeneric()
public ComplexValueList withItemType(DataType type)
Override the type of this list, and return this list.
type
- Data type for the items in this list.public ComplexValueListWithNulls withNulls()
Return an iterator of this list which uses a nullable item type.
public ComplexValueList withType(DataType type)
Override the type of this list, and return this list.
type
- Data type for a list of complex values. Use DataType.listOf
to obtain a suitable list type.