public class EntityValueList extends ListBase implements java.lang.Iterable<EntityValue>
A list of item type EntityValue
.
Uses the property and function naming conventions of the JavaScript Array object.
Modifier and Type | Field and Description |
---|---|
static EntityValueList |
empty |
Constructor and Description |
---|
EntityValueList()
See EntityValueList(int).
|
EntityValueList(int capacity)
Construct a new list with
EntityValueList.length of zero and optional initial capacity . |
Modifier and Type | Method and Description |
---|---|
void |
add(EntityValue item)
Add
item to the end of this list. |
void |
addAll(EntityValueList list)
Add all the items of
list to the end of this list. |
EntityValueList |
addNullable(EntityValue item)
Append
item to the end of this list. |
EntityValueList |
addThis(EntityValue item)
Add
item to the end of this list. |
EntityValueList |
applyPageSize(DataQuery query)
Return a new list with at most
query.pageSize initial items of this list. |
static EntityValueList |
castRequired(DataValue value)
For internal use only.
|
EntityValueList |
copy()
Return a shallow copy of this list.
|
EntityValueList |
copyForQuery(DataQuery query,
boolean copySelected,
boolean copyExpanded)
Return a new list with the items of this list, copied according to the selected properties in the
query . |
static boolean |
equal(EntityValueList a,
EntityValueList b)
Return
true if two entity lists have equal items. |
EntityValueList |
filterAndSort(DataQuery query)
Return a new list with the items of this list, filtered by
query.queryFilter and sorted by query.sortItems . |
EntityValueList |
filterWithQuery(DataQuery query)
Return a new list with the items of this list, filtered by
query.queryFilter , query.derivedType , query.entityKey , query.deltaTime (whichever of those is specified, if any). |
EntityValue |
first()
Return the first item in this list.
|
static EntityValueList |
from(java.util.List<EntityValue> list) |
static EntityValueList |
fromNullable(java.util.List<EntityValue> list) |
EntityValue |
get(int index)
Return the item in this list at the specified
index . |
ChangedLinkList |
getChangedLinks()
Return a list of changed links associated with this entity list.
|
DataType |
getDataType()
Return the data type for this list.
|
java.lang.String |
getDeltaLink()
Return (nullable) An optional link that can be followed (by the caller) to get changes to this list.
|
java.lang.String |
getNextLink()
Return (nullable) An optional link that can be followed (by the caller) to fetch additional list items.
|
EntityValue |
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
EntityValueList.length if the client requested an inline DataQuery.count . |
boolean |
includes(EntityValue item)
Return
true if this list contains item . |
int |
indexOf(EntityValue item)
|
int |
indexOf(EntityValue item,
int start)
Return first index in this list of
item , or -1 if not found. |
void |
insertAll(int index,
EntityValueList list)
Insert all items of
list into this list, before the item (if any) at index . |
void |
insertAt(int index,
EntityValue item)
Insert
item into this list, before the item (if any) at index . |
boolean |
isDelta()
Return
true if this list is a delta response. |
boolean |
isReference()
Return
true if this list is a referece. |
java.util.Iterator<EntityValue> |
iterator() |
EntityValue |
last()
Return the last item in this list.
|
int |
lastIndexOf(EntityValue item)
|
int |
lastIndexOf(EntityValue item,
int start)
Return last index in this list of
item , or -1 if not found. |
void |
set(int index,
EntityValue item)
Set the item in this list at the specified
index . |
void |
setChangedLinks(ChangedLinkList value)
Set a list of changed links associated with this entity list.
|
void |
setDelta(boolean value)
Set
true if this list is a delta response. |
void |
setDeltaLink(java.lang.String value)
Set an optional link that can be followed (by the caller) to get changes to this list.
|
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,
EntityValue 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
EntityValueList.length if the client requested an inline DataQuery.count . |
static EntityValueList |
share(ListBase list)
|
static EntityValueList |
shareNullable(ListBase list)
Return a new EntityValueList that shares the
ListBase.untypedList as the list parameter, including nulls. |
EntityValue |
single()
Return a single item from this list.
|
EntityValueList |
skipAndTop(DataQuery query)
Return a new list with at most
query.topCount items of this list, starting at index query.skipCount . |
EntityValueList |
slice(int start)
See slice(int, int).
|
EntityValueList |
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<EntityValue> |
toGeneric() |
EntityValueList |
withItemType(DataType type)
Override the type of this list, and return this list.
|
EntityValueListWithNulls |
withNulls()
Return an iterator of this list which uses a nullable item type.
|
EntityValueList |
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 EntityValueList empty
public EntityValueList()
public EntityValueList(int capacity)
Construct a new list with EntityValueList.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(EntityValue item)
Add item
to the end of this list.
item
- Item to be added.public void addAll(EntityValueList list)
Add all the items of list
to the end of this list.
list
- Items to be added.public EntityValueList addNullable(EntityValue item)
Append item
to the end of this list.
It is unusual for an EntityValueList
to contain null
items, so EntityValueList.add
is usually used.
item
- (nullable) Item to be added, which might be null
.public EntityValueList addThis(EntityValue item)
Add item
to the end of this list.
item
- Item to be added.public EntityValueList applyPageSize(DataQuery query)
Return a new list with at most query.pageSize
initial items of this list. The result's EntityValueList.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 EntityValueList.needsNextLink
will be true
if the original list length exceeded the page size.public static EntityValueList castRequired(DataValue value)
For internal use only.
value
- (internal use only)public EntityValueList copy()
Return a shallow copy of this list.
public EntityValueList copyForQuery(DataQuery query, boolean copySelected, boolean copyExpanded)
Return a new list with the items of this list, copied according to the selected properties in the query
.
A set of the entities to be returned by a DataServlet.executeQuery
call may contain values for more properties
than requested by the client's query, e.g. if the returned entities are derived from an in-memory structure.
In such cases, this function can be helpful to prune the returned properties (in the returned copied entities)
to just what the client requested.
query
- Data query whose DataQuery.selectItems
and DataQuery.expandItems
are used for selecting/expanding.copySelected
- Should "selected" (e.g. structural) properties be copied?copyExpanded
- Should "expanded" (e.g. navigation) properties be copied?query
.public static boolean equal(EntityValueList a, EntityValueList b)
Return true
if two entity lists have equal items.
a
- (nullable) First entity list.b
- (nullable) Second entity list.public EntityValueList 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 EntityValueList filterWithQuery(DataQuery query)
Return a new list with the items of this list, filtered by query.queryFilter
, query.derivedType
, query.entityKey
, query.deltaTime
(whichever of those is specified, if any).
query
- Data query used for filtering.query.queryFilter
, query.derivedType
, query.entityKey
, query.deltaTime
(whichever of those is specified, if any).public EntityValue first()
Return the first item in this list.
EmptyListException
if the list is empty.
public static EntityValueList from(java.util.List<EntityValue> list)
public static EntityValueList fromNullable(java.util.List<EntityValue> list)
public EntityValue get(int index)
Return the item in this list at the specified index
.
ListIndexException
if index
is out of range (0 to EntityValueList.length
- 1).
index
- Zero-based index.public ChangedLinkList getChangedLinks()
Return a list of changed links associated with this entity list.
public DataType getDataType()
Return the data type for this list.
getDataType
in class ListBase
public java.lang.String getDeltaLink()
Return (nullable) An optional link that can be followed (by the caller) to get changes to this list.
public java.lang.String getNextLink()
Return (nullable) An optional link that can be followed (by the caller) to fetch additional list items. If this entity 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 EntityValue getNullable(int index)
Return (nullable) The item in this list at the specified index
, which may be null
.
It is unusual for an EntityValueList
to contain null
items, so EntityValueList.get
is usually used.
ListIndexException
if index
is out of range (0 to EntityValueList.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 EntityValueList.length
if the client requested an inline DataQuery.count
.
EntityValueList.length
if the client requested an inline DataQuery.count
.public boolean includes(EntityValue item)
Return true
if this list contains item
.
item
- Item for comparison. Comparison uses the EntityValueList.equality
property, which would usually be expected to match the ==
operator for item type EntityValue
.true
if this list contains item
.public int indexOf(EntityValue item)
item
- Item parameter.public int indexOf(EntityValue item, int start)
Return first index in this list of item
, or -1
if not found.
item
- Item for comparison. Comparison uses the EntityValueList.equality
property, which would usually be expected to match the ==
operator for item type EntityValue
.start
- Zero-based starting index (search moves forwards from this index).item
, or -1
if not found.public void insertAll(int index, EntityValueList 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 EntityValueList.length
).
index
- Zero-based index.list
- List of items to be inserted.public void insertAt(int index, EntityValue item)
Insert item
into this list, before the item (if any) at index
.
ListIndexException
if index
is out of range (0 to EntityValueList.length
).
index
- Zero-based index.item
- Item to be added.public boolean isDelta()
Return true
if this list is a delta response.
true
if this list is a delta response.public boolean isReference()
Return true
if this list is a referece. If true
, the EntityValueList.readLink
will be non-null, and this list will be empty.
true
if this list is a referece. If true
, the EntityValueList.readLink
will be non-null, and this list will be empty.public java.util.Iterator<EntityValue> iterator()
iterator
in interface java.lang.Iterable<EntityValue>
public EntityValue last()
Return the last item in this list.
EmptyListException
if the list is empty.
public int lastIndexOf(EntityValue item)
item
- Item parameter.public int lastIndexOf(EntityValue item, int start)
Return last index in this list of item
, or -1
if not found.
item
- Item for comparison. Comparison uses the EntityValueList.equality
property, which would usually be expected to match the ==
operator for item type EntityValue
.start
- Zero-based starting index (search moves backwards from this index).item
, or -1
if not found.public void set(int index, EntityValue item)
Set the item in this list at the specified index
.
index
- Zero-based index.item
- Item value.public void setChangedLinks(ChangedLinkList value)
Set a list of changed links associated with this entity list.
value
- A list of changed links associated with this entity list.public void setDelta(boolean value)
Set true
if this list is a delta response.
value
- true
if this list is a delta response.public void setDeltaLink(java.lang.String value)
Set an optional link that can be followed (by the caller) to get changes to this list.
value
- An optional link that can be followed (by the caller) to get changes to this list.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 entity 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, EntityValue item)
Set the item in this list at the specified index
.
It is unusual for an EntityValueList
to contain null
items, so EntityValueList.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 EntityValueList.readLink
will be non-null, and this list will be empty.
value
- true
if this list is a referece. If true
, the EntityValueList.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 EntityValueList.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 EntityValueList.length
if the client requested an inline DataQuery.count
.public static EntityValueList share(ListBase list)
Return a new EntityValueList
that shares the ListBase.untypedList
as the list
parameter.
To ensure type safety, items in list
that do not have the item type EntityValue
will be removed.
list
- List whose items will be shared by the resulting list.EntityValue
, sharing the same items as list
.public static EntityValueList shareNullable(ListBase list)
Return a new EntityValueList 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.EntityValue
, sharing the same items as list
.public EntityValue single()
Return a single item from this list.
EmptyListException
if the list has no items, NotUniqueException
if the list has multiple items.
public EntityValueList 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 EntityValueList slice(int start)
start
- Start parameter.public EntityValueList 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<EntityValue> toGeneric()
public EntityValueList withItemType(DataType type)
Override the type of this list, and return this list.
type
- Data type for the items in this list.public EntityValueListWithNulls withNulls()
Return an iterator of this list which uses a nullable item type.
public EntityValueList withType(DataType type)
Override the type of this list, and return this list.
type
- Data type for a list of entity values. Use DataType.listOf
to obtain a suitable list type.