ComplexValueList

open class ComplexValueList : ListBase, Codable, ComplexValueOrList, Sequence

A list of item type ComplexValue.

  • Decode and initialize a new object instance

    Declaration

    Swift

    public required init(from decoder: Decoder) throws

    Parameters

    from

    decoder object which contains the original object’s serialized data in a container instance

  • Encode the object instance

    Declaration

    Swift

    public func encode(to encoder: Encoder) throws

    Parameters

    to

    encoder object which can be used to serialize the object’s data one by one into a container instance

  • Undocumented

    Declaration

    Swift

    public subscript(index: Int) -> ComplexValue { get set }
  • An immutable empty ComplexValueList.

    Declaration

    Swift

    public static let empty: ComplexValueList
  • true if this list is a referece. If true, the readLink will be non-null, and this list will be empty.

    Declaration

    Swift

    final public var isReference: Bool
  • 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.

    Declaration

    Swift

    final public var nextLink: String?
  • An optional link that can be followed (by the caller) to re-read this list.

    Declaration

    Swift

    final public var readLink: String?
  • Total number of items available in the server-side list, which may be greater than length if the client requested an inline DataQuery.count.

    Declaration

    Swift

    final public var totalCount: Int64?
  • Construct a new list with 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.

    Declaration

    Swift

    override public init(capacity: Int = (4 as Int))

    Parameters

    capacity

    Optional initial capacity.

  • Add item to the end of this list.

    Declaration

    Swift

    open func append(_ item: ComplexValue)

    Parameters

    item

    Item to be added.

  • Add all the items of list to the end of this list.

    Declaration

    Swift

    open func append(contentsOf list: ComplexValueList)

    Parameters

    list

    Items to be added.

  • Append item to the end of this list. It is unusual for a ComplexValueList to contain nil items, so add is usually used.

    Declaration

    Swift

    open func appendOptional(_ item: ComplexValue?) -> ComplexValueList

    Parameters

    item

    Item to be added, which might be nil.

    Return Value

    This list.

  • Declaration

    Swift

    open func applyPageSize(query: DataQuery) -> ComplexValueList

    Parameters

    query

    Data query whose DataQuery.pageSize is used for filtering.

    Return Value

    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.

  • Declaration

    Swift

    open func copy() -> ComplexValueList

    Return Value

    A shallow copy of this list.

  • The data type for this list.

    Declaration

    Swift

    override open var dataType: DataType { get }
  • See also

    ComplexValue.equal.

    Declaration

    Swift

    open class func equal(a: ComplexValueList?, b: ComplexValueList?) -> Bool

    Parameters

    a

    First complex list.

    b

    Second complex list.

    Return Value

    true if two complex lists have equal items.

  • Declaration

    Swift

    open func filter(_ predicate: @escaping (ComplexValue) -> Bool) -> ComplexValueList

    Parameters

    predicate

    Function to be applied to each item of this list. Items matching this predicate will be returned in the new list.

    Return Value

    A new list which contains the items of this list that match a specified predicate function. Ordering is preserved.

  • Declaration

    Swift

    open func filterAndSort(query: DataQuery) throws -> ComplexValueList

    Parameters

    query

    Data query whose DataQuery.queryFilter is used for filtering and whose DataQuery.sortItems are used for sorting.

    Return Value

    A new list with the items of this list, filtered by query.queryFilter and sorted by query.sortItems.

  • Declaration

    Swift

    open func filterWithQuery(_ query: DataQuery) throws -> ComplexValueList

    Parameters

    query

    Data query used for filtering.

    Return Value

    A new list with the items of this list, filtered by query.queryFilter, query.derivedType (whichever of those is specified, if any).

  • Throws

    EmptyListException if the list is empty.

    Declaration

    Swift

    open func first() -> ComplexValue

    Return Value

    The first item in this list.

  • Convert array to list.

    Declaration

    Swift

    open class func fromArray(_ array: Array<ComplexValue>) -> ComplexValueList

    Parameters

    array

    Array with source items.

    Return Value

    New list with items copied from array parameter.

  • Convert array to list.

    Declaration

    Swift

    open class func fromNullable(_ array: Array<ComplexValue?>) -> ComplexValueList

    Parameters

    array

    Array with source items.

    Return Value

    New list with items copied from array parameter.

  • Declaration

    Swift

    open func includes(item: ComplexValue) -> Bool

    Parameters

    item

    Item for comparison. Comparison uses the equality property, which would usually be expected to match the == operator for item type ComplexValue.

    Return Value

    true if this list contains item.

  • Declaration

    Swift

    open func indexOf(item: ComplexValue, start: Int = (0 as Int)) -> Int

    Parameters

    item

    Item for comparison. Comparison uses the 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).

    Return Value

    First index in this list of item, or -1 if not found.

  • Insert item into this list, before the item (if any) at index.

    Throws

    ListIndexException if index is out of range (0 to length).

    Declaration

    Swift

    open func insert(at index: Int, item: ComplexValue)

    Parameters

    index

    Zero-based index.

    item

    Item to be added.

  • Insert all items of list into this list, before the item (if any) at index.

    Throws

    ListIndexException if index is out of range (0 to length).

    Declaration

    Swift

    open func insert(at index: Int, contentsOf list: ComplexValueList)

    Parameters

    index

    Zero-based index.

    list

    List of items to be inserted.

  • Throws

    ListIndexException if index is out of range (0 to length - 1).

    Declaration

    Swift

    open func item(at index: Int) -> ComplexValue

    Parameters

    index

    Zero-based index.

    Return Value

    The item in this list at the specified index.

  • Throws

    EmptyListException if the list is empty.

    Declaration

    Swift

    open func last() -> ComplexValue

    Return Value

    The last item in this list.

  • Declaration

    Swift

    open func lastIndexOf(item: ComplexValue, start: Int = (2147483647 as Int)) -> Int

    Parameters

    item

    Item for comparison. Comparison uses the 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).

    Return Value

    Last index in this list of item, or -1 if not found.

  • Declaration

    Swift

    open func makeIterator() -> IndexingIterator<Array<ComplexValue>>

    Return Value

    This list converted to a Swift iterator.

  • Throws

    ListIndexException if index is out of range (0 to length - 1).

    Declaration

    Swift

    open func optionalItem(at index: Int) -> ComplexValue?

    Parameters

    index

    Zero-based index.

    Return Value

    The item in this list at the specified index, which may be nil. It is unusual for a ComplexValueList to contain nil items, so get is usually used.

  • 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.

    Declaration

    Swift

    open class func share(_ list: ListBase) -> ComplexValueList

    Parameters

    list

    List whose items will be shared by the resulting list.

    Return Value

    A new list of item type ComplexValue, sharing the same items as 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.

    Declaration

    Swift

    open class func shareOptional(_ list: ListBase) -> ComplexValueList

    Parameters

    list

    List whose items will be shared by the resulting list.

    Return Value

    A new list of item type ComplexValue, sharing the same items as list.

  • Throws

    EmptyListException if the list has no items, NotUniqueException if the list has multiple items.

    Declaration

    Swift

    open func single() -> ComplexValue

    Return Value

    A single item from this list.

  • Declaration

    Swift

    open func skipAndTop(query: DataQuery) -> ComplexValueList

    Parameters

    query

    Data query whose DataQuery.skipCount and DataQuery.topCount are used for filtering.

    Return Value

    A new list with at most query.topCount items of this list, starting at index query.skipCount.

  • Declaration

    Swift

    open func slice(start: Int, end: Int = (2147483647 as Int)) -> ComplexValueList

    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.

    Return Value

    A slice of this list from index start (inclusive) to index end (exclusive).

  • Sort this list in-place, using query.sortItems.

    Declaration

    Swift

    open func sortWithQuery(_ query: DataQuery) throws

    Parameters

    query

    Data query whose whose DataQuery.sortItems are used for filtering.

  • Convert list to array.

    Declaration

    Swift

    open func toArray() -> Array<ComplexValue>

    Return Value

    New array with items copied from this list.

  • Set the item in this list at the specified index.

    Declaration

    Swift

    open func update(at index: Int, item: ComplexValue)

    Parameters

    index

    Zero-based index.

    item

    Item value.

  • Set the item in this list at the specified index. It is unusual for a ComplexValueList to contain nil items, so set is usually used.

    Declaration

    Swift

    open func updateOptional(at index: Int, item: ComplexValue?)

    Parameters

    index

    Zero-based index.

    item

    Item value, which might be nil.

  • Override the type of this list, and return this list.

    Declaration

    Swift

    open func withItemType(_ type: DataType) -> ComplexValueList

    Parameters

    type

    Data type for the items in this list.

    Return Value

    This list.

  • Declaration

    Swift

    open func withNulls() -> ComplexValueListWithNulls

    Return Value

    An iterator of this list which uses a nullable item type.

  • Override the type of this list, and return this list.

    Declaration

    Swift

    open func withType(_ type: DataType) -> ComplexValueList

    Parameters

    type

    Data type for a list of complex values. Use DataType.listOf to obtain a suitable list type.

    Return Value

    This list.