Modifier

Partager via


Collection

A collection holds a set of Common Data Model objects and provides easy handling of them.

public class CdmCollection<CdmObject> extends List<CdmObject>

Constructors

Name Description
CdmCollection(CdmCorpusContext, CdmObject, CdmObjectType)
ctx: The corpus context.
owner: The object that contains this collection.
defaultType: The default object type of this collection.
Initializes a new instance of the CdmCollection class.

Properties

Name Type Description
DefaultType CdmObjectType The default object type of this collection.
Count

Length in TypeScript.
int The number of items in the collection.

Methods

There are additional methods and properties in this class that just extend standard list methods (IndexOf(...), Insert(...), Clear(), Contains(...), CopyTo(...), GetEnumerator(...), etc.).

Name Description Return Type
Add(string, bool)
name: The name of the object to add to the collection.
simpleRef [optional]: A boolean that denotes whether we want a reference to be a simple reference, if we're adding one. The default value is false.

append(...) in Python, push(...) in TypeScript.
Creates an object of a default type with the specified name and adds it to the collection. The default type can be set in the property. Returns the object that was added to the collection. T
Add(T)
currObject: The object to add to the collection.

append(...). in Python, push(...) in TypeScript.
Adds the specified object to the collection. Returns the object that was added to the collection. T
AddRange(IEnumerable<T>)
list: The list of objects to add.

addAll(...) in Java, extend(...) in Python, concat(...) in TypeScript.
Adds the elements of the specified list of objects to the collection. void
Remove(T)
currObject: The object to remove from the collection.
Removes the specified object from the collection. Returns true if the operation is successful, false otherwise. bool
RemoveAt(int)
index: The index of the object to remove.

pop(...) in Python.
Removes the object at the specified index from the collection. void
Item(string)
name: The name of the object to fetch.
Returns the object with the specified name. T
Copy(ResolveOptions, CdmObject)
resOpt: The resolve options.

Only in C# and Java.
Creates a copy of the current collection. CdmCollection<T>