Class: Type

$k. Type

new $k.Type()

Represents a type

Extends

Methods

addSupertype(type)

Add a supertype

Name Type Description
type

Type or internal name

Throws:
Type Description
$k.exception.TypeError

If the argument is not a valid supertype

$k.exception.SchemaError

If the argument cannot be added as supertype

$k.exception.AccessDenied

If adding the type is not allowed

$k.exception.TransactionError

If no write transaction is active

allInstances() : Array.<$k.Instance>

Returns all instances of this type and all subtypes.
Avoid using this function if possible, use queries instead

Returns:
Type Description
Array.<$k.Instance>

allSubtypes() : Array.<$k.Type>

Returns all subtypes

Returns:
Type Description
Array.<$k.Type>

allSupertypes() : Array.<$k.Type>

Returns all supertypes

Returns:
Type Description
Array.<$k.Type>

canCreateExtensions() : boolean

Returns true if instances of this type can be created as extensions of instances.
Only either canCreateExtensions() or canCreateInstances() can be true.
isAbstract() is true if neither canCreateExtensions() nor canCreateInstances() is true.

See:
Returns:
Type Description
boolean

canCreateInstances() : boolean

Returns true if instances / properties of this type can be created.
Only either canCreateExtensions() or canCreateInstances() can be true.
isAbstract() is true if neither canCreateExtensions() nor canCreateInstances() is true.

See:
Returns:
Type Description
boolean

domain() : $k.Domain

Returns the domain of the instances of this type

Returns:
Type Description
$k.Domain

estimatedNumberOfInstances() : number

Returns the estimated number of instances of this type

Returns:
Type Description
number

getCounter() : number

Returns the value of the counter associated with this type.

Returns:
Type Description
number

increaseCounter() : number

Increases and returns the value of the counter associated with this type. The counter can be increased concurrently.

Returns:
Type Description
number

instances() : Array.<$k.Instance>

Returns all direct instances of this type.
Avoid using this function if possible, use queries instead

Returns:
Type Description
Array.<$k.Instance>

internalName() : string

Returns the internal name

Returns:
Type Description
string

isAbstract() : boolean

Returns true if this is an abstract type (cannot create properties/instances/extensions).
isAbstract() is true if neither canCreateExtensions() nor canCreateInstances() is true.

Returns:
Type Description
boolean

isKindOf(type) : boolean

Returns true if this is equal to or a direct or indirect type of the other type

Name Type Description
type

Type or internal name

Throws:
Type Description
$k.exception.TypeError

If the argument is not a type

$k.exception.SchemaError

If the argument is an unknown internal name

Returns:
Type Description
boolean

numberOfInstances() : number

Returns the exact number of instances of this type

Returns:
Type Description
number

removeSupertype()

Remove a supertype

Throws:
Type Description
$k.exception.TypeError

If the argument is not a valid supertype

$k.exception.AccessDenied

If removing the type is not allowed

$k.exception.TransactionError

If no write transaction is active

schemaReportOn()

setCanCreateExtensions(canCreate)

Set to true if it should be possible to extend other instances with instances of this tyoe.
The flag cannot be set to false if extensions exist.
Only either canCreateExtensions() or canCreateInstances() can be true.

Name Type Description
canCreate boolean
See:
Throws:
Type Description
$k.exception.SchemaError

If it is not possible to change the schema, e.g. when the type already allows to create instances

setCanCreateInstances(canCreate)

Set to true if it should be possible to create instances / properties this type.
The flag cannot be set to false if instances exist.
Only either canCreateExtensions() or canCreateInstances() can be true.

Name Type Description
canCreate boolean
See:
Throws:
Type Description
$k.exception.SchemaError

If it is not possible to change the schema, e.g. when the type already allows to create extensions

setCounter(counterValue) : number

Set the initial value of the counter associated with this type. Note: this cannot be done concurrently. Use increaseCounter() instead.

Name Type Description
counterValue number

Must be an integer

See:
Returns:
Type Description
number The counter value

setInternalName(name)

Sets the internal name, or removes the internal name if null is passed

Name Type Description
name

New internal name or null

Throws:
Type Description
$k.exception.TypeError

If the argument is not a valid internal name

$k.exception.AccessDenied

If modifying the type is not allowed

$k.exception.NotUnique

If the internal name is not unique

$k.exception.TransactionError

If no write transaction is active

subtypes() : Array.<$k.Type>

Returns the direct subtypes

Returns:
Type Description
Array.<$k.Type>

supertypes() : Array.<$k.Type>

Returns the direct supertypes

Returns:
Type Description
Array.<$k.Type>

typeDomain() : $k.Domain

Returns the domain that represents this type and its subtype

Returns:
Type Description
$k.Domain

Intherited methods