Classes & stereotypes
This is the heart of OntoUML. A class is built from a package and carries an
ontological stereotype that fixes what kind of thing it represents — not
just "a Person", but "a kind of substantial whose instances carry their own
principle of identity". You already saw .kind() and .relator() in
Hello, model; this chapter covers the full
vocabulary.
Plain UML lets you draw a class called Student and a class called Person
with no way to say that being a student is a temporary phase while being a
person is permanent, or that a Marriage only exists because two people are
married. OntoUML makes those distinctions first-class by tagging every class
with a stereotype drawn from the Unified Foundational Ontology (UFO). Three
questions organize the whole vocabulary:
- Does it supply identity? Sortals provide or inherit a principle of identity (you can count and re-identify their instances); non-sortals merely aggregate properties across kinds.
- Is membership permanent? Rigid types apply to their instances necessarily, for as long as they exist; anti-rigid types apply only contingently; semi-rigid types are rigid for some instances and anti-rigid for others.
- What is the instance — a substance, an aspect, or an occurrence? Substantials exist on their own; moments (relators, modes, qualities) inhere in something else; events and situations happen.
Every builder shortcut below encodes the answers and, crucially, applies the
default restrictedTo nature and order that OntoUML prescribes — so .kind()
is not just a label, it is a bundle of correct defaults.
Building a class
Classes are built from a container — a Project or a Package — with
classBuilder(). Pick a stereotype shortcut, give it a name, and build().
The shortcut does double duty: it sets the stereotype and the defaults for
that stereotype.
import { class ProjectAn OntoUML project: the top-level container of an ontology and the entry
point of this library. A project holds every element of a model — classes,
relations, generalizations, packages, properties, notes — as well as the
diagrams and views that depict them, and provides typed access to these
elements by id or by kind.
New elements are created through the fluent builders exposed by the
project (e.g.,
classBuilder
,
binaryRelationBuilder
), which
register the created elements in the project.
A project is also described by the metadata fields of the OntoUML/UFO
Catalog Metadata Vocabulary, such as publisher, license, keywords, themes,
and designed-for tasks.Project } from 'ontouml-js';
const const project: Projectproject = new new Project(): ProjectAn OntoUML project: the top-level container of an ontology and the entry
point of this library. A project holds every element of a model — classes,
relations, generalizations, packages, properties, notes — as well as the
diagrams and views that depict them, and provides typed access to these
elements by id or by kind.
New elements are created through the fluent builders exposed by the
project (e.g.,
classBuilder
,
binaryRelationBuilder
), which
register the created elements in the project.
A project is also described by the metadata fields of the OntoUML/UFO
Catalog Metadata Vocabulary, such as publisher, license, keywords, themes,
and designed-for tasks.Project();
const const model: Packagemodel = const project: Projectproject.Project.packageBuilder(): PackageBuilderCreates a builder for a new
Package
in this project.packageBuilder().PackageBuilder.root(): PackageBuilderSets the package as the root package of its project, i.e., the package
that contains the entire model.root().NamedElementBuilder<PackageBuilder>.name(value: string, language?: string): PackageBuilderAdds a name to the element in the given language.name('People').PackageBuilder.build(): PackageBuilds an instance of
Package
with the parameters passed to the
builder. When no methods are evoked, the created package has the
following defaults:
- `id: "randomly-generated-id",`
- `created: new Date(),`
- `contents: []`build();
const const person: Classperson = const model: Packagemodel.Package.classBuilder(): ClassBuilderCreates a builder for a
Class
contained in this package.classBuilder().ClassBuilder.kind(): ClassBuilderSets the stereotype of the class to «kind», which decorates rigid
classes that provide an identity principle to their instances, which are
functional complexes (e.g., `Person`, `Car`). Also applies the following
defaults:
- `restrictedTo = [ "functional-complex" ]`
- `order = 1`kind().NamedElementBuilder<ClassBuilder>.name(value: string, language?: string): ClassBuilderAdds a name to the element in the given language.name('Person').ClassBuilder.build(): ClassBuilds an instance of
Class
with the parameters passed to the
builder. **WARNING:** the ordering in which methods are evoked may
affect the resulting object. When no methods are evoked, the created
class has the following defaults:
- `id: "randomly-generated-id",`
- `created: new Date(),`
- `isAbstract: false,`
- `isDerived: false,`
- `order: 1,`
- `isPowertype: false,`build();
var console: Consoleconsole.Console.log(...data: any[]): voidThe **`console.log()`** static method outputs a message to the console.
[MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)log(const person: Classperson.Decoratable<ClassStereotype>.stereotype?: ClassStereotypeThe stereotype applied to this element, if any.stereotype); // "kind"
var console: Consoleconsole.Console.log(...data: any[]): voidThe **`console.log()`** static method outputs a message to the console.
[MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)log(const person: Classperson.Class.restrictedTo: Nature[]The ontological natures that instances of this class may have. For
example, a class `Person` decorated with «kind» is restricted to the
functional complex nature, while a class `Insurable` may admit
instances of multiple natures.
Sets the ontological natures that instances of this class may have,
discarding duplicates.restrictedTo); // [ "functional-complex" ]
var console: Consoleconsole.Console.log(...data: any[]): voidThe **`console.log()`** static method outputs a message to the console.
[MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)log(const person: Classperson.Class.isSortal(): booleanChecks whether this class is a sortal, i.e., whether all of its
instances follow the same identity principle.isSortal()); // true
var console: Consoleconsole.Console.log(...data: any[]): voidThe **`console.log()`** static method outputs a message to the console.
[MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)log(const person: Classperson.Class.isRigid(): booleanChecks whether this class is rigid, i.e., whether it necessarily
applies to its instances in every world in which they exist.isRigid()); // true
Sortals that supply identity
A kind is the backbone of a model: a rigid sortal whose instances are
functional complexes carrying their own identity principle (Person, Car,
Organization). Two variants supply identity for other kinds of substantial:
collective (a whole whose parts play the same role — Forest, Deck) and
quantity (an amount of matter — Water, Gold).
A subkind is a rigid specialization that inherits the identity of a kind
above it (Man and Woman as subkinds of Person).
import { class ProjectAn OntoUML project: the top-level container of an ontology and the entry
point of this library. A project holds every element of a model — classes,
relations, generalizations, packages, properties, notes — as well as the
diagrams and views that depict them, and provides typed access to these
elements by id or by kind.
New elements are created through the fluent builders exposed by the
project (e.g.,
classBuilder
,
binaryRelationBuilder
), which
register the created elements in the project.
A project is also described by the metadata fields of the OntoUML/UFO
Catalog Metadata Vocabulary, such as publisher, license, keywords, themes,
and designed-for tasks.Project } from 'ontouml-js';
const const project: Projectproject = new new Project(): ProjectAn OntoUML project: the top-level container of an ontology and the entry
point of this library. A project holds every element of a model — classes,
relations, generalizations, packages, properties, notes — as well as the
diagrams and views that depict them, and provides typed access to these
elements by id or by kind.
New elements are created through the fluent builders exposed by the
project (e.g.,
classBuilder
,
binaryRelationBuilder
), which
register the created elements in the project.
A project is also described by the metadata fields of the OntoUML/UFO
Catalog Metadata Vocabulary, such as publisher, license, keywords, themes,
and designed-for tasks.Project();
const const model: Packagemodel = const project: Projectproject.Project.packageBuilder(): PackageBuilderCreates a builder for a new
Package
in this project.packageBuilder().PackageBuilder.root(): PackageBuilderSets the package as the root package of its project, i.e., the package
that contains the entire model.root().NamedElementBuilder<PackageBuilder>.name(value: string, language?: string): PackageBuilderAdds a name to the element in the given language.name('Nature').PackageBuilder.build(): PackageBuilds an instance of
Package
with the parameters passed to the
builder. When no methods are evoked, the created package has the
following defaults:
- `id: "randomly-generated-id",`
- `created: new Date(),`
- `contents: []`build();
const const person: Classperson = const model: Packagemodel.Package.classBuilder(): ClassBuilderCreates a builder for a
Class
contained in this package.classBuilder().ClassBuilder.kind(): ClassBuilderSets the stereotype of the class to «kind», which decorates rigid
classes that provide an identity principle to their instances, which are
functional complexes (e.g., `Person`, `Car`). Also applies the following
defaults:
- `restrictedTo = [ "functional-complex" ]`
- `order = 1`kind().NamedElementBuilder<ClassBuilder>.name(value: string, language?: string): ClassBuilderAdds a name to the element in the given language.name('Person').ClassBuilder.build(): ClassBuilds an instance of
Class
with the parameters passed to the
builder. **WARNING:** the ordering in which methods are evoked may
affect the resulting object. When no methods are evoked, the created
class has the following defaults:
- `id: "randomly-generated-id",`
- `created: new Date(),`
- `isAbstract: false,`
- `isDerived: false,`
- `order: 1,`
- `isPowertype: false,`build();
const const forest: Classforest = const model: Packagemodel.Package.classBuilder(): ClassBuilderCreates a builder for a
Class
contained in this package.classBuilder().ClassBuilder.collective(): ClassBuilderSets the stereotype of the class to «collective», which decorates rigid
classes that provide an identity principle to their instances, which are
collectives, i.e., wholes whose parts play the same role (e.g., `Forest`,
`Crowd`). Also applies the following defaults:
- `restrictedTo = [ "collective" ]`
- `order = 1`collective().NamedElementBuilder<ClassBuilder>.name(value: string, language?: string): ClassBuilderAdds a name to the element in the given language.name('Forest').ClassBuilder.build(): ClassBuilds an instance of
Class
with the parameters passed to the
builder. **WARNING:** the ordering in which methods are evoked may
affect the resulting object. When no methods are evoked, the created
class has the following defaults:
- `id: "randomly-generated-id",`
- `created: new Date(),`
- `isAbstract: false,`
- `isDerived: false,`
- `order: 1,`
- `isPowertype: false,`build();
const const water: Classwater = const model: Packagemodel.Package.classBuilder(): ClassBuilderCreates a builder for a
Class
contained in this package.classBuilder().ClassBuilder.quantity(): ClassBuilderSets the stereotype of the class to «quantity», which decorates rigid
classes that provide an identity principle to their instances, which are
amounts of matter (e.g., `Water`, `Sand`). Also applies the following
defaults:
- `restrictedTo = [ "quantity" ]`
- `order = 1`quantity().NamedElementBuilder<ClassBuilder>.name(value: string, language?: string): ClassBuilderAdds a name to the element in the given language.name('Water').ClassBuilder.build(): ClassBuilds an instance of
Class
with the parameters passed to the
builder. **WARNING:** the ordering in which methods are evoked may
affect the resulting object. When no methods are evoked, the created
class has the following defaults:
- `id: "randomly-generated-id",`
- `created: new Date(),`
- `isAbstract: false,`
- `isDerived: false,`
- `order: 1,`
- `isPowertype: false,`build();
// A subkind inherits identity from a kind above it.
const const man: Classman = const model: Packagemodel.Package.classBuilder(): ClassBuilderCreates a builder for a
Class
contained in this package.classBuilder().ClassBuilder.subkind(): ClassBuilderSets the stereotype of the class to «subkind», which decorates rigid
classes that specialize a kind, inheriting its identity principle (e.g.,
`Man` as a subkind of `Person`).subkind().NamedElementBuilder<ClassBuilder>.name(value: string, language?: string): ClassBuilderAdds a name to the element in the given language.name('Man').ClassBuilder.build(): ClassBuilds an instance of
Class
with the parameters passed to the
builder. **WARNING:** the ordering in which methods are evoked may
affect the resulting object. When no methods are evoked, the created
class has the following defaults:
- `id: "randomly-generated-id",`
- `created: new Date(),`
- `isAbstract: false,`
- `isDerived: false,`
- `order: 1,`
- `isPowertype: false,`build();
const person: Classperson.Classifier<Class, ClassStereotype>.addChild(child: Class): GeneralizationCreates a
Generalization
in which this classifier is the
general and the given classifier is the specific.addChild(const man: Classman);
var console: Consoleconsole.Console.log(...data: any[]): voidThe **`console.log()`** static method outputs a message to the console.
[MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)log(const person: Classperson.Class.isIdentityProvider(): booleanChecks whether this class is an ultimate sortal, i.e., whether it
provides the identity principle followed by its instances.isIdentityProvider()); // true — a kind provides identity
var console: Consoleconsole.Console.log(...data: any[]): voidThe **`console.log()`** static method outputs a message to the console.
[MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)log(const man: Classman.Class.isIdentityProvider(): booleanChecks whether this class is an ultimate sortal, i.e., whether it
provides the identity principle followed by its instances.isIdentityProvider()); // false — a subkind only inherits it
Every sortal must ultimately specialize exactly one identity provider (a
kind, collective, or quantity). Subkinds, roles, and phases never stand
alone — they always sit beneath a kind. Building them without that hierarchy is
valid TypeScript but an incomplete model; add the
generalizations that root them.
Anti-rigid sortals: roles and phases
Some classifications come and go during an instance's life. OntoUML splits these anti-rigid sortals by what makes them apply:
- role — a relational condition: something is a
Studentonly while enrolled, aEmployeeonly while employed. A role always depends on a relation. - phase — an intrinsic condition: something is a
Childor anAdultpurely by its own properties (age), aPuppyby its stage of life.
import { class ProjectAn OntoUML project: the top-level container of an ontology and the entry
point of this library. A project holds every element of a model — classes,
relations, generalizations, packages, properties, notes — as well as the
diagrams and views that depict them, and provides typed access to these
elements by id or by kind.
New elements are created through the fluent builders exposed by the
project (e.g.,
classBuilder
,
binaryRelationBuilder
), which
register the created elements in the project.
A project is also described by the metadata fields of the OntoUML/UFO
Catalog Metadata Vocabulary, such as publisher, license, keywords, themes,
and designed-for tasks.Project } from 'ontouml-js';
const const project: Projectproject = new new Project(): ProjectAn OntoUML project: the top-level container of an ontology and the entry
point of this library. A project holds every element of a model — classes,
relations, generalizations, packages, properties, notes — as well as the
diagrams and views that depict them, and provides typed access to these
elements by id or by kind.
New elements are created through the fluent builders exposed by the
project (e.g.,
classBuilder
,
binaryRelationBuilder
), which
register the created elements in the project.
A project is also described by the metadata fields of the OntoUML/UFO
Catalog Metadata Vocabulary, such as publisher, license, keywords, themes,
and designed-for tasks.Project();
const const model: Packagemodel = const project: Projectproject.Project.packageBuilder(): PackageBuilderCreates a builder for a new
Package
in this project.packageBuilder().PackageBuilder.root(): PackageBuilderSets the package as the root package of its project, i.e., the package
that contains the entire model.root().NamedElementBuilder<PackageBuilder>.name(value: string, language?: string): PackageBuilderAdds a name to the element in the given language.name('University').PackageBuilder.build(): PackageBuilds an instance of
Package
with the parameters passed to the
builder. When no methods are evoked, the created package has the
following defaults:
- `id: "randomly-generated-id",`
- `created: new Date(),`
- `contents: []`build();
const const person: Classperson = const model: Packagemodel.Package.classBuilder(): ClassBuilderCreates a builder for a
Class
contained in this package.classBuilder().ClassBuilder.kind(): ClassBuilderSets the stereotype of the class to «kind», which decorates rigid
classes that provide an identity principle to their instances, which are
functional complexes (e.g., `Person`, `Car`). Also applies the following
defaults:
- `restrictedTo = [ "functional-complex" ]`
- `order = 1`kind().NamedElementBuilder<ClassBuilder>.name(value: string, language?: string): ClassBuilderAdds a name to the element in the given language.name('Person').ClassBuilder.build(): ClassBuilds an instance of
Class
with the parameters passed to the
builder. **WARNING:** the ordering in which methods are evoked may
affect the resulting object. When no methods are evoked, the created
class has the following defaults:
- `id: "randomly-generated-id",`
- `created: new Date(),`
- `isAbstract: false,`
- `isDerived: false,`
- `order: 1,`
- `isPowertype: false,`build();
const const student: Classstudent = const model: Packagemodel.Package.classBuilder(): ClassBuilderCreates a builder for a
Class
contained in this package.classBuilder().ClassBuilder.role(): ClassBuilderSets the stereotype of the class to «role», which decorates anti-rigid
classes whose instances are contingently classified by virtue of a
relational condition (e.g., `Student`, `Employee`).role().NamedElementBuilder<ClassBuilder>.name(value: string, language?: string): ClassBuilderAdds a name to the element in the given language.name('Student').ClassBuilder.build(): ClassBuilds an instance of
Class
with the parameters passed to the
builder. **WARNING:** the ordering in which methods are evoked may
affect the resulting object. When no methods are evoked, the created
class has the following defaults:
- `id: "randomly-generated-id",`
- `created: new Date(),`
- `isAbstract: false,`
- `isDerived: false,`
- `order: 1,`
- `isPowertype: false,`build();
const const child: Classchild = const model: Packagemodel.Package.classBuilder(): ClassBuilderCreates a builder for a
Class
contained in this package.classBuilder().ClassBuilder.phase(): ClassBuilderSets the stereotype of the class to «phase», which decorates anti-rigid
classes whose instances are contingently classified by virtue of an
intrinsic condition (e.g., `Child`, `LivingPerson`).phase().NamedElementBuilder<ClassBuilder>.name(value: string, language?: string): ClassBuilderAdds a name to the element in the given language.name('Child').ClassBuilder.build(): ClassBuilds an instance of
Class
with the parameters passed to the
builder. **WARNING:** the ordering in which methods are evoked may
affect the resulting object. When no methods are evoked, the created
class has the following defaults:
- `id: "randomly-generated-id",`
- `created: new Date(),`
- `isAbstract: false,`
- `isDerived: false,`
- `order: 1,`
- `isPowertype: false,`build();
const person: Classperson.Classifier<Class, ClassStereotype>.addChild(child: Class): GeneralizationCreates a
Generalization
in which this classifier is the
general and the given classifier is the specific.addChild(const student: Classstudent);
const person: Classperson.Classifier<Class, ClassStereotype>.addChild(child: Class): GeneralizationCreates a
Generalization
in which this classifier is the
general and the given classifier is the specific.addChild(const child: Classchild);
var console: Consoleconsole.Console.log(...data: any[]): voidThe **`console.log()`** static method outputs a message to the console.
[MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)log(const student: Classstudent.Class.isAntiRigid(): booleanChecks whether this class is anti-rigid, i.e., whether every instance
can cease to be classified by it without ceasing to exist.isAntiRigid()); // true — being a student is temporary
var console: Consoleconsole.Console.log(...data: any[]): voidThe **`console.log()`** static method outputs a message to the console.
[MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)log(const student: Classstudent.Class.isRole(): booleanChecks whether this class is stereotyped as «role».isRole()); // true
var console: Consoleconsole.Console.log(...data: any[]): voidThe **`console.log()`** static method outputs a message to the console.
[MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)log(const child: Classchild.Class.isPhase(): booleanChecks whether this class is stereotyped as «phase».isPhase()); // true
Their historical counterparts, historicalRole (.historicalRole()) and
historicalRoleMixin, classify instances by past participation — an
ExStudent is no longer enrolled but was.
Non-sortals: categories and mixins
Non-sortals don't provide identity of their own; they gather properties that instances of different kinds share. They differ by rigidity:
| Shortcut | Stereotype | Rigidity | Example |
|---|---|---|---|
.category() | «category» | rigid | PhysicalObject over Car, Rock |
.mixin() | «mixin» | semi-rigid | Insurable (essential to some) |
.roleMixin() | «roleMixin» | anti-rigid | Customer over Person, Company |
.phaseMixin() | «phaseMixin» | anti-rigid | Living over Person, Animal |
Each of these shortcuts also marks the class abstract — a non-sortal is never instantiated directly; only its sortal subtypes are.
import { class ProjectAn OntoUML project: the top-level container of an ontology and the entry
point of this library. A project holds every element of a model — classes,
relations, generalizations, packages, properties, notes — as well as the
diagrams and views that depict them, and provides typed access to these
elements by id or by kind.
New elements are created through the fluent builders exposed by the
project (e.g.,
classBuilder
,
binaryRelationBuilder
), which
register the created elements in the project.
A project is also described by the metadata fields of the OntoUML/UFO
Catalog Metadata Vocabulary, such as publisher, license, keywords, themes,
and designed-for tasks.Project } from 'ontouml-js';
const const project: Projectproject = new new Project(): ProjectAn OntoUML project: the top-level container of an ontology and the entry
point of this library. A project holds every element of a model — classes,
relations, generalizations, packages, properties, notes — as well as the
diagrams and views that depict them, and provides typed access to these
elements by id or by kind.
New elements are created through the fluent builders exposed by the
project (e.g.,
classBuilder
,
binaryRelationBuilder
), which
register the created elements in the project.
A project is also described by the metadata fields of the OntoUML/UFO
Catalog Metadata Vocabulary, such as publisher, license, keywords, themes,
and designed-for tasks.Project();
const const model: Packagemodel = const project: Projectproject.Project.packageBuilder(): PackageBuilderCreates a builder for a new
Package
in this project.packageBuilder().PackageBuilder.root(): PackageBuilderSets the package as the root package of its project, i.e., the package
that contains the entire model.root().NamedElementBuilder<PackageBuilder>.name(value: string, language?: string): PackageBuilderAdds a name to the element in the given language.name('Agents').PackageBuilder.build(): PackageBuilds an instance of
Package
with the parameters passed to the
builder. When no methods are evoked, the created package has the
following defaults:
- `id: "randomly-generated-id",`
- `created: new Date(),`
- `contents: []`build();
const const agent: Classagent = const model: Packagemodel.Package.classBuilder(): ClassBuilderCreates a builder for a
Class
contained in this package.classBuilder().ClassBuilder.category(): ClassBuilderSets the stereotype of the class to «category», which decorates rigid
non-sortal classes that aggregate essential properties common to
instances of different kinds (e.g., `PhysicalObject`). Also applies the
following defaults:
- `restrictedTo = [ "functional-complex" ]`
- `isAbstract = true`category().NamedElementBuilder<ClassBuilder>.name(value: string, language?: string): ClassBuilderAdds a name to the element in the given language.name('Agent').ClassBuilder.build(): ClassBuilds an instance of
Class
with the parameters passed to the
builder. **WARNING:** the ordering in which methods are evoked may
affect the resulting object. When no methods are evoked, the created
class has the following defaults:
- `id: "randomly-generated-id",`
- `created: new Date(),`
- `isAbstract: false,`
- `isDerived: false,`
- `order: 1,`
- `isPowertype: false,`build();
const const customer: Classcustomer = const model: Packagemodel.Package.classBuilder(): ClassBuilderCreates a builder for a
Class
contained in this package.classBuilder().ClassBuilder.roleMixin(): ClassBuilderSets the stereotype of the class to «roleMixin», which decorates
anti-rigid non-sortal classes that aggregate contingent relational
properties common to roles of different kinds (e.g., `Customer`). Also
applies the following defaults:
- `restrictedTo = [ "functional-complex" ]`
- `isAbstract = true`roleMixin().NamedElementBuilder<ClassBuilder>.name(value: string, language?: string): ClassBuilderAdds a name to the element in the given language.name('Customer').ClassBuilder.build(): ClassBuilds an instance of
Class
with the parameters passed to the
builder. **WARNING:** the ordering in which methods are evoked may
affect the resulting object. When no methods are evoked, the created
class has the following defaults:
- `id: "randomly-generated-id",`
- `created: new Date(),`
- `isAbstract: false,`
- `isDerived: false,`
- `order: 1,`
- `isPowertype: false,`build();
var console: Consoleconsole.Console.log(...data: any[]): voidThe **`console.log()`** static method outputs a message to the console.
[MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)log(const agent: Classagent.Class.isNonSortal(): booleanChecks whether this class is a non-sortal, i.e., whether it classifies
entities that follow different identity principles.isNonSortal()); // true
var console: Consoleconsole.Console.log(...data: any[]): voidThe **`console.log()`** static method outputs a message to the console.
[MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)log(const agent: Classagent.Classifier<Class, ClassStereotype>.isAbstract: booleanIndicates whether the classifier is abstract, i.e., whether it can have
direct instances.isAbstract); // true — set for you by .category()
var console: Consoleconsole.Console.log(...data: any[]): voidThe **`console.log()`** static method outputs a message to the console.
[MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)log(const customer: Classcustomer.Class.isAntiRigid(): booleanChecks whether this class is anti-rigid, i.e., whether every instance
can cease to be classified by it without ceasing to exist.isAntiRigid()); // true
Moments: relators, modes, and qualities
Not everything stands on its own. Moments are aspects that existentially depend on a bearer:
- relator — the truthmaker of a material relation; it binds two or more
entities (
Marriage,Enrollment,Employment). You met relators in Hello, model. - mode — an intrinsic aspect with no natural measurement scale (
Skill,Belief,Symptom). - quality — an intrinsic aspect that is measurable on a value structure
(
Weight,Color,Temperature).
import { class ProjectAn OntoUML project: the top-level container of an ontology and the entry
point of this library. A project holds every element of a model — classes,
relations, generalizations, packages, properties, notes — as well as the
diagrams and views that depict them, and provides typed access to these
elements by id or by kind.
New elements are created through the fluent builders exposed by the
project (e.g.,
classBuilder
,
binaryRelationBuilder
), which
register the created elements in the project.
A project is also described by the metadata fields of the OntoUML/UFO
Catalog Metadata Vocabulary, such as publisher, license, keywords, themes,
and designed-for tasks.Project } from 'ontouml-js';
const const project: Projectproject = new new Project(): ProjectAn OntoUML project: the top-level container of an ontology and the entry
point of this library. A project holds every element of a model — classes,
relations, generalizations, packages, properties, notes — as well as the
diagrams and views that depict them, and provides typed access to these
elements by id or by kind.
New elements are created through the fluent builders exposed by the
project (e.g.,
classBuilder
,
binaryRelationBuilder
), which
register the created elements in the project.
A project is also described by the metadata fields of the OntoUML/UFO
Catalog Metadata Vocabulary, such as publisher, license, keywords, themes,
and designed-for tasks.Project();
const const model: Packagemodel = const project: Projectproject.Project.packageBuilder(): PackageBuilderCreates a builder for a new
Package
in this project.packageBuilder().PackageBuilder.root(): PackageBuilderSets the package as the root package of its project, i.e., the package
that contains the entire model.root().NamedElementBuilder<PackageBuilder>.name(value: string, language?: string): PackageBuilderAdds a name to the element in the given language.name('Marriage').PackageBuilder.build(): PackageBuilds an instance of
Package
with the parameters passed to the
builder. When no methods are evoked, the created package has the
following defaults:
- `id: "randomly-generated-id",`
- `created: new Date(),`
- `contents: []`build();
const const marriage: Classmarriage = const model: Packagemodel.Package.classBuilder(): ClassBuilderCreates a builder for a
Class
contained in this package.classBuilder().ClassBuilder.relator(): ClassBuilderSets the stereotype of the class to «relator», which decorates rigid
classes whose instances are relators, i.e., entities that mediate other
entities and are the truthmakers of material relations (e.g.,
`Marriage`, `Enrollment`). Also applies the following defaults:
- `restrictedTo = [ "relator" ]`
- `order = 1`relator().NamedElementBuilder<ClassBuilder>.name(value: string, language?: string): ClassBuilderAdds a name to the element in the given language.name('Marriage').ClassBuilder.build(): ClassBuilds an instance of
Class
with the parameters passed to the
builder. **WARNING:** the ordering in which methods are evoked may
affect the resulting object. When no methods are evoked, the created
class has the following defaults:
- `id: "randomly-generated-id",`
- `created: new Date(),`
- `isAbstract: false,`
- `isDerived: false,`
- `order: 1,`
- `isPowertype: false,`build();
const const skill: Classskill = const model: Packagemodel.Package.classBuilder(): ClassBuilderCreates a builder for a
Class
contained in this package.classBuilder().ClassBuilder.mode(): ClassBuilderSets the stereotype of the class to «mode», which decorates rigid
classes whose instances are intrinsic modes, i.e., aspects of entities
that are not measurable on quality structures (e.g., `Skill`, `Belief`).
Also applies the following defaults:
- `restrictedTo = [ "intrinsic-mode" ]`
- `order = 1`mode().NamedElementBuilder<ClassBuilder>.name(value: string, language?: string): ClassBuilderAdds a name to the element in the given language.name('Skill').ClassBuilder.build(): ClassBuilds an instance of
Class
with the parameters passed to the
builder. **WARNING:** the ordering in which methods are evoked may
affect the resulting object. When no methods are evoked, the created
class has the following defaults:
- `id: "randomly-generated-id",`
- `created: new Date(),`
- `isAbstract: false,`
- `isDerived: false,`
- `order: 1,`
- `isPowertype: false,`build();
const const weight: Classweight = const model: Packagemodel.Package.classBuilder(): ClassBuilderCreates a builder for a
Class
contained in this package.classBuilder().ClassBuilder.quality(): ClassBuilderSets the stereotype of the class to «quality», which decorates rigid
classes whose instances are qualities, i.e., intrinsic aspects of
entities that are measurable on quality structures (e.g., `Weight`,
`Color`). Also applies the following defaults:
- `restrictedTo = [ "quality" ]`
- `order = 1`quality().NamedElementBuilder<ClassBuilder>.name(value: string, language?: string): ClassBuilderAdds a name to the element in the given language.name('Weight').ClassBuilder.build(): ClassBuilds an instance of
Class
with the parameters passed to the
builder. **WARNING:** the ordering in which methods are evoked may
affect the resulting object. When no methods are evoked, the created
class has the following defaults:
- `id: "randomly-generated-id",`
- `created: new Date(),`
- `isAbstract: false,`
- `isDerived: false,`
- `order: 1,`
- `isPowertype: false,`build();
var console: Consoleconsole.Console.log(...data: any[]): voidThe **`console.log()`** static method outputs a message to the console.
[MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)log(const marriage: Classmarriage.Class.isRelator(): booleanChecks whether this class is stereotyped as «relator».isRelator()); // true
var console: Consoleconsole.Console.log(...data: any[]): voidThe **`console.log()`** static method outputs a message to the console.
[MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)log(const skill: Classskill.Class.isIntrinsicMomentType(): booleanChecks whether the instances of this class are restricted to intrinsic
moment natures (see
IntrinsicMomentNatures
).isIntrinsicMomentType()); // true
var console: Consoleconsole.Console.log(...data: any[]): voidThe **`console.log()`** static method outputs a message to the console.
[MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)log(const weight: Classweight.Class.isQualityType(): booleanChecks whether the instances of this class are restricted to the
quality nature.isQualityType()); // true
The relations that tie a moment to its bearer — «mediation» for relators,
«characterization» for modes and qualities — are covered under
binary relations.
Events, situations, and higher-order types
Beyond endurants (things that persist), OntoUML also types events
(.event() — a Wedding, a Purchase), situations (.situation() — a
configuration that can trigger events), and high-order types (.type() —
classes whose instances are themselves types, like CarModel). Datatypes and
enumerations are classes too, and get their own treatment in
Attributes.
Ontological natures
The stereotype fixes a class's category; the restrictedTo natures fix
what its instances ultimately are. Each stereotype shortcut sets a sensible
default (a kind ⇒ functional-complex, a relator ⇒ relator), but non-sortals
often span several natures, and you set those explicitly with restrictedTo or
the additive helpers.
import { class ProjectAn OntoUML project: the top-level container of an ontology and the entry
point of this library. A project holds every element of a model — classes,
relations, generalizations, packages, properties, notes — as well as the
diagrams and views that depict them, and provides typed access to these
elements by id or by kind.
New elements are created through the fluent builders exposed by the
project (e.g.,
classBuilder
,
binaryRelationBuilder
), which
register the created elements in the project.
A project is also described by the metadata fields of the OntoUML/UFO
Catalog Metadata Vocabulary, such as publisher, license, keywords, themes,
and designed-for tasks.Project, enum NatureThe ontological natures that instances of a
Class
may have,
according to the UFO foundational ontology. The natures a class is
restricted to are recorded in
Class.restrictedTo
and constrain
which stereotypes and specializations are admissible for the class.Nature } from 'ontouml-js';
const const project: Projectproject = new new Project(): ProjectAn OntoUML project: the top-level container of an ontology and the entry
point of this library. A project holds every element of a model — classes,
relations, generalizations, packages, properties, notes — as well as the
diagrams and views that depict them, and provides typed access to these
elements by id or by kind.
New elements are created through the fluent builders exposed by the
project (e.g.,
classBuilder
,
binaryRelationBuilder
), which
register the created elements in the project.
A project is also described by the metadata fields of the OntoUML/UFO
Catalog Metadata Vocabulary, such as publisher, license, keywords, themes,
and designed-for tasks.Project();
const const model: Packagemodel = const project: Projectproject.Project.packageBuilder(): PackageBuilderCreates a builder for a new
Package
in this project.packageBuilder().PackageBuilder.root(): PackageBuilderSets the package as the root package of its project, i.e., the package
that contains the entire model.root().NamedElementBuilder<PackageBuilder>.name(value: string, language?: string): PackageBuilderAdds a name to the element in the given language.name('Physical').PackageBuilder.build(): PackageBuilds an instance of
Package
with the parameters passed to the
builder. When no methods are evoked, the created package has the
following defaults:
- `id: "randomly-generated-id",`
- `created: new Date(),`
- `contents: []`build();
// A category over any substantial (functional-complex, collective, quantity).
const const object: Classobject = const model: Packagemodel
.Package.classBuilder(): ClassBuilderCreates a builder for a
Class
contained in this package.classBuilder()
.ClassBuilder.category(): ClassBuilderSets the stereotype of the class to «category», which decorates rigid
non-sortal classes that aggregate essential properties common to
instances of different kinds (e.g., `PhysicalObject`). Also applies the
following defaults:
- `restrictedTo = [ "functional-complex" ]`
- `isAbstract = true`category()
.NamedElementBuilder<ClassBuilder>.name(value: string, language?: string): ClassBuilderAdds a name to the element in the given language.name('PhysicalObject')
.ClassBuilder.restrictedTo(natures?: Nature | Nature[]): ClassBuilderSets the ontological natures that the instances of the class may have,
replacing any previously set natures.restrictedTo([enum NatureThe ontological natures that instances of a
Class
may have,
according to the UFO foundational ontology. The natures a class is
restricted to are recorded in
Class.restrictedTo
and constrain
which stereotypes and specializations are admissible for the class.Nature.function (enum member) Nature.FUNCTIONAL_COMPLEX = "functional-complex"The nature of functional complexes: objects whose parts play different
functional roles with respect to the whole, such as a person or a car.FUNCTIONAL_COMPLEX, enum NatureThe ontological natures that instances of a
Class
may have,
according to the UFO foundational ontology. The natures a class is
restricted to are recorded in
Class.restrictedTo
and constrain
which stereotypes and specializations are admissible for the class.Nature.function (enum member) Nature.COLLECTIVE = "collective"The nature of collectives: objects whose parts (members) play the same
role with respect to the whole, such as a forest or a crowd.COLLECTIVE, enum NatureThe ontological natures that instances of a
Class
may have,
according to the UFO foundational ontology. The natures a class is
restricted to are recorded in
Class.restrictedTo
and constrain
which stereotypes and specializations are admissible for the class.Nature.function (enum member) Nature.QUANTITY = "quantity"The nature of quantities: maximally connected amounts of matter, such as
a portion of water or gold.QUANTITY])
.ClassBuilder.build(): ClassBuilds an instance of
Class
with the parameters passed to the
builder. **WARNING:** the ordering in which methods are evoked may
affect the resulting object. When no methods are evoked, the created
class has the following defaults:
- `id: "randomly-generated-id",`
- `created: new Date(),`
- `isAbstract: false,`
- `isDerived: false,`
- `order: 1,`
- `isPowertype: false,`build();
var console: Consoleconsole.Console.log(...data: any[]): voidThe **`console.log()`** static method outputs a message to the console.
[MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)log(const object: Classobject.Class.restrictedTo: Nature[]The ontological natures that instances of this class may have. For
example, a class `Person` decorated with «kind» is restricted to the
functional complex nature, while a class `Insurable` may admit
instances of multiple natures.
Sets the ontological natures that instances of this class may have,
discarding duplicates.restrictedTo.Array<Nature>.length: numberGets or sets the length of the array. This is a number one higher than the highest index in the array.length); // 3
var console: Consoleconsole.Console.log(...data: any[]): voidThe **`console.log()`** static method outputs a message to the console.
[MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)log(const object: Classobject.Class.isSubstantialType(): booleanChecks whether the instances of this class are restricted to
substantial natures (see
SubstantialNatures
).isSubstantialType()); // true
// The same thing, spelled with the additive shortcut:
const model: Packagemodel.Package.classBuilder(): ClassBuilderCreates a builder for a
Class
contained in this package.classBuilder().ClassBuilder.category(): ClassBuilderSets the stereotype of the class to «category», which decorates rigid
non-sortal classes that aggregate essential properties common to
instances of different kinds (e.g., `PhysicalObject`). Also applies the
following defaults:
- `restrictedTo = [ "functional-complex" ]`
- `isAbstract = true`category().NamedElementBuilder<ClassBuilder>.name(value: string, language?: string): ClassBuilderAdds a name to the element in the given language.name('Substance').ClassBuilder.substantialType(): ClassBuilderAdds the natures of substantials (`functional-complex`, `collective`,
and `quantity`) to the natures allowed for instances of the class.substantialType().ClassBuilder.build(): ClassBuilds an instance of
Class
with the parameters passed to the
builder. **WARNING:** the ordering in which methods are evoked may
affect the resulting object. When no methods are evoked, the created
class has the following defaults:
- `id: "randomly-generated-id",`
- `created: new Date(),`
- `isAbstract: false,`
- `isDerived: false,`
- `order: 1,`
- `isPowertype: false,`build();
allowsExactly, allowsSome, and allowsOnly let you query a class's natures
later — see Querying.
Now you try it
Model a small fragment: Person is a kind; Employee is a role under
it; Employment is the relator that makes someone an employee. Fill in the
three TODOs, then open the console.
Show the solution
Key takeaways
- A class carries an ontological stereotype; the builder shortcut sets the
stereotype and its prescribed defaults (
restrictedTo, order, abstractness). - Sortals provide (
kind,collective,quantity) or inherit (subkind,role,phase) a principle of identity; non-sortals (category,mixin,roleMixin,phaseMixin) aggregate properties across kinds. - Rigidity tells you whether membership is permanent (
kind,category), temporary (role,phase,roleMixin), or mixed (mixin). - Moments —
relator,mode,quality— depend on a bearer, unlike self-standing substantials. restrictedTonatures record what instances ultimately are; query them withisSortal(),isRigid(),allowsExactly(), and friends.
Next: attributes →, the intrinsic structure a class gives its instances.