public abstract class ListBase extends DataValue
Base class for strongly-typed lists.
Constructor and Description |
---|
ListBase(int capacity)
Construct a new list with a
ListBase.length of zero and specified initial capacity . |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Remove all items from this list.
|
com.sap.cloud.server.odata.core.Comparer |
getComparer()
Return an ordering function for the item type of this list.
|
DataType |
getDataType()
Return the data type for this list.
|
com.sap.cloud.server.odata.core.Equality |
getEquality()
Return an equality function for the item type of this list.
|
com.sap.cloud.server.odata.core.UntypedList |
getUntypedList()
Return the underlying untyped list.
|
boolean |
isEmpty()
Return
true if this list contains no items. |
int |
length()
Return the number of items in this list.
|
void |
removeAt(int index)
Remove an item from the specified index in this list.
|
void |
removeFirst()
Remove the first item (if any) from this list.
|
void |
removeLast()
Remove the last item (if any) from this list.
|
void |
removeRange(int start,
int end)
Remove a range of items from this list.
|
void |
reverse()
Reverse the order of the items in this list.
|
void |
shareWith(ListBase other,
boolean replace)
For internal use only.
|
void |
sort()
Sort the items in this list, using the
ListBase.comparer property for ordering. |
void |
sortWith(com.sap.cloud.server.odata.core.Comparer comparer)
Sort the items in this list.
|
ListBase |
toDynamic()
Return (nullable) a dynamic representation of this list (
DataValueList , ComplexValueList , or EntityValueList ), or null if there is no dynamic representation available. |
java.lang.String |
toString()
Return a string representation of this list.
|
java.lang.Object |
validate(java.lang.Object value)
Base function for validating the item's value before adding it to the list.
|
cloneMutable, equals, getTypeCode, hashCode
public ListBase(int capacity)
Construct a new list with a ListBase.length
of zero and specified 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
- Initial capacity.public void clear()
Remove all items from this list.
public com.sap.cloud.server.odata.core.Comparer getComparer()
Return an ordering function for the item type of this list.
public DataType getDataType()
Return the data type for this list.
getDataType
in class DataValue
public com.sap.cloud.server.odata.core.Equality getEquality()
Return an equality function for the item type of this list.
public com.sap.cloud.server.odata.core.UntypedList getUntypedList()
Return the underlying untyped list. Use with care, avoiding the addition of objects with an incorrect item type.
public boolean isEmpty()
Return true
if this list contains no items.
true
if this list contains no items.public int length()
Return the number of items in this list.
public void removeAt(int index)
Remove an item from the specified index in this list.
index
- Index of the item to be removed.public void removeFirst()
Remove the first item (if any) from this list.
public void removeLast()
Remove the last item (if any) from this list.
public void removeRange(int start, int end)
Remove a range of items from this list.
start
- Starting index (inclusive) for items to be removed.end
- Ending index (exclusive) for items to be removed.public void reverse()
Reverse the order of the items in this list.
public void shareWith(ListBase other, boolean replace)
For internal use only.
other
- (internal use only)replace
- (internal use only)public void sort()
Sort the items in this list, using the ListBase.comparer
property for ordering.
public void sortWith(com.sap.cloud.server.odata.core.Comparer comparer)
Sort the items in this list.
comparer
- Comparer for ordering.public ListBase toDynamic()
Return (nullable) a dynamic representation of this list (DataValueList
, ComplexValueList
, or EntityValueList
), or null
if there is no dynamic representation available.
DataValueList
, ComplexValueList
, or EntityValueList
), or null
if there is no dynamic representation available.public java.lang.String toString()
Return a string representation of this list.
public java.lang.Object validate(java.lang.Object value)
Base function for validating the item's value before adding it to the list. Validate is needed in some ListBase types, for exampe in the case of ByteList, where a value out of the ByteValue type's valid range can be added, because ByteList accepts Int instead of Byte. With a proper overwrite of this function in the given BaseList class ensures, that only a valid value Int (-128 - +127 in this case) can be added to the list.
value
- (nullable) The value to be validated.value
without modification.