Skip to main content
Version: 1.0.0

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.

Theory: why stereotypes exist

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 Project
An 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.
@example```typescript const project = new Project(); const person = project.classBuilder().kind().name('Person').build(); const student = project.classBuilder().role().name('Student').build(); project .generalizationBuilder() .general(person) .specific(student) .build(); ```
Project
} from 'ontouml-js';
const const project: Projectproject = new new Project(): Project
An 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.
@example```typescript const project = new Project(); const person = project.classBuilder().kind().name('Person').build(); const student = project.classBuilder().role().name('Student').build(); project .generalizationBuilder() .general(person) .specific(student) .build(); ```
Project
();
const const model: Packagemodel = const project: Projectproject.Project.packageBuilder(): PackageBuilder
Creates a builder for a new Package in this project.
packageBuilder
().PackageBuilder.root(): PackageBuilder
Sets the package as the root package of its project, i.e., the package that contains the entire model.
@returnsthis builder, for method chaining.
root
().NamedElementBuilder<PackageBuilder>.name(value: string, language?: string): PackageBuilder
Adds a name to the element in the given language.
@paramvalue - the name text.@paramlanguage - language tag of `value`; defaults to LanguageString.defaultLanguage.@returnsthis builder, for method chaining.
name
('People').PackageBuilder.build(): Package
Builds 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: []`
@throwsan error if the builder has already been used.
build
();
const const person: Classperson = const model: Packagemodel.Package.classBuilder(): ClassBuilder
Creates a builder for a Class contained in this package.
classBuilder
().ClassBuilder.kind(): ClassBuilder
Sets 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`
@returnsthis builder, for method chaining.
kind
().NamedElementBuilder<ClassBuilder>.name(value: string, language?: string): ClassBuilder
Adds a name to the element in the given language.
@paramvalue - the name text.@paramlanguage - language tag of `value`; defaults to LanguageString.defaultLanguage.@returnsthis builder, for method chaining.
name
('Person').ClassBuilder.build(): Class
Builds 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,`
@throwsan error if the builder has already been used.
build
();
var console: Consoleconsole.Console.log(...data: any[]): void
The **`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?: ClassStereotype
The stereotype applied to this element, if any.
stereotype
); // "kind"
var console: Consoleconsole.Console.log(...data: any[]): void
The **`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[]): void
The **`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(): boolean
Checks whether this class is a sortal, i.e., whether all of its instances follow the same identity principle.
@seeSORTAL_STEREOTYPES
isSortal
()); // true
var console: Consoleconsole.Console.log(...data: any[]): void
The **`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(): boolean
Checks whether this class is rigid, i.e., whether it necessarily applies to its instances in every world in which they exist.
@seeRIGID_STEREOTYPES
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 Project
An 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.
@example```typescript const project = new Project(); const person = project.classBuilder().kind().name('Person').build(); const student = project.classBuilder().role().name('Student').build(); project .generalizationBuilder() .general(person) .specific(student) .build(); ```
Project
} from 'ontouml-js';
const const project: Projectproject = new new Project(): Project
An 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.
@example```typescript const project = new Project(); const person = project.classBuilder().kind().name('Person').build(); const student = project.classBuilder().role().name('Student').build(); project .generalizationBuilder() .general(person) .specific(student) .build(); ```
Project
();
const const model: Packagemodel = const project: Projectproject.Project.packageBuilder(): PackageBuilder
Creates a builder for a new Package in this project.
packageBuilder
().PackageBuilder.root(): PackageBuilder
Sets the package as the root package of its project, i.e., the package that contains the entire model.
@returnsthis builder, for method chaining.
root
().NamedElementBuilder<PackageBuilder>.name(value: string, language?: string): PackageBuilder
Adds a name to the element in the given language.
@paramvalue - the name text.@paramlanguage - language tag of `value`; defaults to LanguageString.defaultLanguage.@returnsthis builder, for method chaining.
name
('Nature').PackageBuilder.build(): Package
Builds 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: []`
@throwsan error if the builder has already been used.
build
();
const const person: Classperson = const model: Packagemodel.Package.classBuilder(): ClassBuilder
Creates a builder for a Class contained in this package.
classBuilder
().ClassBuilder.kind(): ClassBuilder
Sets 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`
@returnsthis builder, for method chaining.
kind
().NamedElementBuilder<ClassBuilder>.name(value: string, language?: string): ClassBuilder
Adds a name to the element in the given language.
@paramvalue - the name text.@paramlanguage - language tag of `value`; defaults to LanguageString.defaultLanguage.@returnsthis builder, for method chaining.
name
('Person').ClassBuilder.build(): Class
Builds 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,`
@throwsan error if the builder has already been used.
build
();
const const forest: Classforest = const model: Packagemodel.Package.classBuilder(): ClassBuilder
Creates a builder for a Class contained in this package.
classBuilder
().ClassBuilder.collective(): ClassBuilder
Sets 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`
@returnsthis builder, for method chaining.
collective
().NamedElementBuilder<ClassBuilder>.name(value: string, language?: string): ClassBuilder
Adds a name to the element in the given language.
@paramvalue - the name text.@paramlanguage - language tag of `value`; defaults to LanguageString.defaultLanguage.@returnsthis builder, for method chaining.
name
('Forest').ClassBuilder.build(): Class
Builds 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,`
@throwsan error if the builder has already been used.
build
();
const const water: Classwater = const model: Packagemodel.Package.classBuilder(): ClassBuilder
Creates a builder for a Class contained in this package.
classBuilder
().ClassBuilder.quantity(): ClassBuilder
Sets 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`
@returnsthis builder, for method chaining.
quantity
().NamedElementBuilder<ClassBuilder>.name(value: string, language?: string): ClassBuilder
Adds a name to the element in the given language.
@paramvalue - the name text.@paramlanguage - language tag of `value`; defaults to LanguageString.defaultLanguage.@returnsthis builder, for method chaining.
name
('Water').ClassBuilder.build(): Class
Builds 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,`
@throwsan error if the builder has already been used.
build
();
// A subkind inherits identity from a kind above it. const const man: Classman = const model: Packagemodel.Package.classBuilder(): ClassBuilder
Creates a builder for a Class contained in this package.
classBuilder
().ClassBuilder.subkind(): ClassBuilder
Sets 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`).
@returnsthis builder, for method chaining.
subkind
().NamedElementBuilder<ClassBuilder>.name(value: string, language?: string): ClassBuilder
Adds a name to the element in the given language.
@paramvalue - the name text.@paramlanguage - language tag of `value`; defaults to LanguageString.defaultLanguage.@returnsthis builder, for method chaining.
name
('Man').ClassBuilder.build(): Class
Builds 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,`
@throwsan error if the builder has already been used.
build
();
const person: Classperson.Classifier<Class, ClassStereotype>.addChild(child: Class): Generalization
Creates a Generalization in which this classifier is the general and the given classifier is the specific.
@paramchild - the classifier to be set as the specific.@returnsthe newly created generalization.
addChild
(const man: Classman);
var console: Consoleconsole.Console.log(...data: any[]): void
The **`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(): boolean
Checks whether this class is an ultimate sortal, i.e., whether it provides the identity principle followed by its instances.
@seeULTIMATE_SORTAL_STEREOTYPES
isIdentityProvider
()); // true — a kind provides identity
var console: Consoleconsole.Console.log(...data: any[]): void
The **`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(): boolean
Checks whether this class is an ultimate sortal, i.e., whether it provides the identity principle followed by its instances.
@seeULTIMATE_SORTAL_STEREOTYPES
isIdentityProvider
()); // false — a subkind only inherits it
One identity provider per branch

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 Student only while enrolled, a Employee only while employed. A role always depends on a relation.
  • phase — an intrinsic condition: something is a Child or an Adult purely by its own properties (age), a Puppy by its stage of life.
import { class Project
An 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.
@example```typescript const project = new Project(); const person = project.classBuilder().kind().name('Person').build(); const student = project.classBuilder().role().name('Student').build(); project .generalizationBuilder() .general(person) .specific(student) .build(); ```
Project
} from 'ontouml-js';
const const project: Projectproject = new new Project(): Project
An 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.
@example```typescript const project = new Project(); const person = project.classBuilder().kind().name('Person').build(); const student = project.classBuilder().role().name('Student').build(); project .generalizationBuilder() .general(person) .specific(student) .build(); ```
Project
();
const const model: Packagemodel = const project: Projectproject.Project.packageBuilder(): PackageBuilder
Creates a builder for a new Package in this project.
packageBuilder
().PackageBuilder.root(): PackageBuilder
Sets the package as the root package of its project, i.e., the package that contains the entire model.
@returnsthis builder, for method chaining.
root
().NamedElementBuilder<PackageBuilder>.name(value: string, language?: string): PackageBuilder
Adds a name to the element in the given language.
@paramvalue - the name text.@paramlanguage - language tag of `value`; defaults to LanguageString.defaultLanguage.@returnsthis builder, for method chaining.
name
('University').PackageBuilder.build(): Package
Builds 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: []`
@throwsan error if the builder has already been used.
build
();
const const person: Classperson = const model: Packagemodel.Package.classBuilder(): ClassBuilder
Creates a builder for a Class contained in this package.
classBuilder
().ClassBuilder.kind(): ClassBuilder
Sets 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`
@returnsthis builder, for method chaining.
kind
().NamedElementBuilder<ClassBuilder>.name(value: string, language?: string): ClassBuilder
Adds a name to the element in the given language.
@paramvalue - the name text.@paramlanguage - language tag of `value`; defaults to LanguageString.defaultLanguage.@returnsthis builder, for method chaining.
name
('Person').ClassBuilder.build(): Class
Builds 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,`
@throwsan error if the builder has already been used.
build
();
const const student: Classstudent = const model: Packagemodel.Package.classBuilder(): ClassBuilder
Creates a builder for a Class contained in this package.
classBuilder
().ClassBuilder.role(): ClassBuilder
Sets 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`).
@returnsthis builder, for method chaining.
role
().NamedElementBuilder<ClassBuilder>.name(value: string, language?: string): ClassBuilder
Adds a name to the element in the given language.
@paramvalue - the name text.@paramlanguage - language tag of `value`; defaults to LanguageString.defaultLanguage.@returnsthis builder, for method chaining.
name
('Student').ClassBuilder.build(): Class
Builds 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,`
@throwsan error if the builder has already been used.
build
();
const const child: Classchild = const model: Packagemodel.Package.classBuilder(): ClassBuilder
Creates a builder for a Class contained in this package.
classBuilder
().ClassBuilder.phase(): ClassBuilder
Sets 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`).
@returnsthis builder, for method chaining.
phase
().NamedElementBuilder<ClassBuilder>.name(value: string, language?: string): ClassBuilder
Adds a name to the element in the given language.
@paramvalue - the name text.@paramlanguage - language tag of `value`; defaults to LanguageString.defaultLanguage.@returnsthis builder, for method chaining.
name
('Child').ClassBuilder.build(): Class
Builds 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,`
@throwsan error if the builder has already been used.
build
();
const person: Classperson.Classifier<Class, ClassStereotype>.addChild(child: Class): Generalization
Creates a Generalization in which this classifier is the general and the given classifier is the specific.
@paramchild - the classifier to be set as the specific.@returnsthe newly created generalization.
addChild
(const student: Classstudent);
const person: Classperson.Classifier<Class, ClassStereotype>.addChild(child: Class): Generalization
Creates a Generalization in which this classifier is the general and the given classifier is the specific.
@paramchild - the classifier to be set as the specific.@returnsthe newly created generalization.
addChild
(const child: Classchild);
var console: Consoleconsole.Console.log(...data: any[]): void
The **`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(): boolean
Checks whether this class is anti-rigid, i.e., whether every instance can cease to be classified by it without ceasing to exist.
@seeANTI_RIGID_STEREOTYPES
isAntiRigid
()); // true — being a student is temporary
var console: Consoleconsole.Console.log(...data: any[]): void
The **`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(): boolean
Checks whether this class is stereotyped as «role».
isRole
()); // true
var console: Consoleconsole.Console.log(...data: any[]): void
The **`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(): boolean
Checks 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:

ShortcutStereotypeRigidityExample
.category()«category»rigidPhysicalObject over Car, Rock
.mixin()«mixin»semi-rigidInsurable (essential to some)
.roleMixin()«roleMixin»anti-rigidCustomer over Person, Company
.phaseMixin()«phaseMixin»anti-rigidLiving 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 Project
An 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.
@example```typescript const project = new Project(); const person = project.classBuilder().kind().name('Person').build(); const student = project.classBuilder().role().name('Student').build(); project .generalizationBuilder() .general(person) .specific(student) .build(); ```
Project
} from 'ontouml-js';
const const project: Projectproject = new new Project(): Project
An 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.
@example```typescript const project = new Project(); const person = project.classBuilder().kind().name('Person').build(); const student = project.classBuilder().role().name('Student').build(); project .generalizationBuilder() .general(person) .specific(student) .build(); ```
Project
();
const const model: Packagemodel = const project: Projectproject.Project.packageBuilder(): PackageBuilder
Creates a builder for a new Package in this project.
packageBuilder
().PackageBuilder.root(): PackageBuilder
Sets the package as the root package of its project, i.e., the package that contains the entire model.
@returnsthis builder, for method chaining.
root
().NamedElementBuilder<PackageBuilder>.name(value: string, language?: string): PackageBuilder
Adds a name to the element in the given language.
@paramvalue - the name text.@paramlanguage - language tag of `value`; defaults to LanguageString.defaultLanguage.@returnsthis builder, for method chaining.
name
('Agents').PackageBuilder.build(): Package
Builds 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: []`
@throwsan error if the builder has already been used.
build
();
const const agent: Classagent = const model: Packagemodel.Package.classBuilder(): ClassBuilder
Creates a builder for a Class contained in this package.
classBuilder
().ClassBuilder.category(): ClassBuilder
Sets 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`
@returnsthis builder, for method chaining.
category
().NamedElementBuilder<ClassBuilder>.name(value: string, language?: string): ClassBuilder
Adds a name to the element in the given language.
@paramvalue - the name text.@paramlanguage - language tag of `value`; defaults to LanguageString.defaultLanguage.@returnsthis builder, for method chaining.
name
('Agent').ClassBuilder.build(): Class
Builds 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,`
@throwsan error if the builder has already been used.
build
();
const const customer: Classcustomer = const model: Packagemodel.Package.classBuilder(): ClassBuilder
Creates a builder for a Class contained in this package.
classBuilder
().ClassBuilder.roleMixin(): ClassBuilder
Sets 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`
@returnsthis builder, for method chaining.
roleMixin
().NamedElementBuilder<ClassBuilder>.name(value: string, language?: string): ClassBuilder
Adds a name to the element in the given language.
@paramvalue - the name text.@paramlanguage - language tag of `value`; defaults to LanguageString.defaultLanguage.@returnsthis builder, for method chaining.
name
('Customer').ClassBuilder.build(): Class
Builds 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,`
@throwsan error if the builder has already been used.
build
();
var console: Consoleconsole.Console.log(...data: any[]): void
The **`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(): boolean
Checks whether this class is a non-sortal, i.e., whether it classifies entities that follow different identity principles.
@seeNON_SORTAL_STEREOTYPES
isNonSortal
()); // true
var console: Consoleconsole.Console.log(...data: any[]): void
The **`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: boolean
Indicates 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[]): void
The **`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(): boolean
Checks whether this class is anti-rigid, i.e., whether every instance can cease to be classified by it without ceasing to exist.
@seeANTI_RIGID_STEREOTYPES
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 Project
An 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.
@example```typescript const project = new Project(); const person = project.classBuilder().kind().name('Person').build(); const student = project.classBuilder().role().name('Student').build(); project .generalizationBuilder() .general(person) .specific(student) .build(); ```
Project
} from 'ontouml-js';
const const project: Projectproject = new new Project(): Project
An 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.
@example```typescript const project = new Project(); const person = project.classBuilder().kind().name('Person').build(); const student = project.classBuilder().role().name('Student').build(); project .generalizationBuilder() .general(person) .specific(student) .build(); ```
Project
();
const const model: Packagemodel = const project: Projectproject.Project.packageBuilder(): PackageBuilder
Creates a builder for a new Package in this project.
packageBuilder
().PackageBuilder.root(): PackageBuilder
Sets the package as the root package of its project, i.e., the package that contains the entire model.
@returnsthis builder, for method chaining.
root
().NamedElementBuilder<PackageBuilder>.name(value: string, language?: string): PackageBuilder
Adds a name to the element in the given language.
@paramvalue - the name text.@paramlanguage - language tag of `value`; defaults to LanguageString.defaultLanguage.@returnsthis builder, for method chaining.
name
('Marriage').PackageBuilder.build(): Package
Builds 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: []`
@throwsan error if the builder has already been used.
build
();
const const marriage: Classmarriage = const model: Packagemodel.Package.classBuilder(): ClassBuilder
Creates a builder for a Class contained in this package.
classBuilder
().ClassBuilder.relator(): ClassBuilder
Sets 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`
@returnsthis builder, for method chaining.
relator
().NamedElementBuilder<ClassBuilder>.name(value: string, language?: string): ClassBuilder
Adds a name to the element in the given language.
@paramvalue - the name text.@paramlanguage - language tag of `value`; defaults to LanguageString.defaultLanguage.@returnsthis builder, for method chaining.
name
('Marriage').ClassBuilder.build(): Class
Builds 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,`
@throwsan error if the builder has already been used.
build
();
const const skill: Classskill = const model: Packagemodel.Package.classBuilder(): ClassBuilder
Creates a builder for a Class contained in this package.
classBuilder
().ClassBuilder.mode(): ClassBuilder
Sets 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`
@returnsthis builder, for method chaining.
mode
().NamedElementBuilder<ClassBuilder>.name(value: string, language?: string): ClassBuilder
Adds a name to the element in the given language.
@paramvalue - the name text.@paramlanguage - language tag of `value`; defaults to LanguageString.defaultLanguage.@returnsthis builder, for method chaining.
name
('Skill').ClassBuilder.build(): Class
Builds 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,`
@throwsan error if the builder has already been used.
build
();
const const weight: Classweight = const model: Packagemodel.Package.classBuilder(): ClassBuilder
Creates a builder for a Class contained in this package.
classBuilder
().ClassBuilder.quality(): ClassBuilder
Sets 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`
@returnsthis builder, for method chaining.
quality
().NamedElementBuilder<ClassBuilder>.name(value: string, language?: string): ClassBuilder
Adds a name to the element in the given language.
@paramvalue - the name text.@paramlanguage - language tag of `value`; defaults to LanguageString.defaultLanguage.@returnsthis builder, for method chaining.
name
('Weight').ClassBuilder.build(): Class
Builds 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,`
@throwsan error if the builder has already been used.
build
();
var console: Consoleconsole.Console.log(...data: any[]): void
The **`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(): boolean
Checks whether this class is stereotyped as «relator».
isRelator
()); // true
var console: Consoleconsole.Console.log(...data: any[]): void
The **`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(): boolean
Checks whether the instances of this class are restricted to intrinsic moment natures (see IntrinsicMomentNatures ).
isIntrinsicMomentType
()); // true
var console: Consoleconsole.Console.log(...data: any[]): void
The **`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(): boolean
Checks 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 Project
An 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.
@example```typescript const project = new Project(); const person = project.classBuilder().kind().name('Person').build(); const student = project.classBuilder().role().name('Student').build(); project .generalizationBuilder() .general(person) .specific(student) .build(); ```
Project
, enum Nature
The 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(): Project
An 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.
@example```typescript const project = new Project(); const person = project.classBuilder().kind().name('Person').build(); const student = project.classBuilder().role().name('Student').build(); project .generalizationBuilder() .general(person) .specific(student) .build(); ```
Project
();
const const model: Packagemodel = const project: Projectproject.Project.packageBuilder(): PackageBuilder
Creates a builder for a new Package in this project.
packageBuilder
().PackageBuilder.root(): PackageBuilder
Sets the package as the root package of its project, i.e., the package that contains the entire model.
@returnsthis builder, for method chaining.
root
().NamedElementBuilder<PackageBuilder>.name(value: string, language?: string): PackageBuilder
Adds a name to the element in the given language.
@paramvalue - the name text.@paramlanguage - language tag of `value`; defaults to LanguageString.defaultLanguage.@returnsthis builder, for method chaining.
name
('Physical').PackageBuilder.build(): Package
Builds 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: []`
@throwsan error if the builder has already been used.
build
();
// A category over any substantial (functional-complex, collective, quantity). const const object: Classobject = const model: Packagemodel .Package.classBuilder(): ClassBuilder
Creates a builder for a Class contained in this package.
classBuilder
()
.ClassBuilder.category(): ClassBuilder
Sets 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`
@returnsthis builder, for method chaining.
category
()
.NamedElementBuilder<ClassBuilder>.name(value: string, language?: string): ClassBuilder
Adds a name to the element in the given language.
@paramvalue - the name text.@paramlanguage - language tag of `value`; defaults to LanguageString.defaultLanguage.@returnsthis builder, for method chaining.
name
('PhysicalObject')
.ClassBuilder.restrictedTo(natures?: Nature | Nature[]): ClassBuilder
Sets the ontological natures that the instances of the class may have, replacing any previously set natures.
@paramnatures - the nature or natures allowed for instances of the class.@returnsthis builder, for method chaining.
restrictedTo
([enum Nature
The 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 Nature
The 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 Nature
The 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(): Class
Builds 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,`
@throwsan error if the builder has already been used.
build
();
var console: Consoleconsole.Console.log(...data: any[]): void
The **`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: number
Gets 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[]): void
The **`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(): boolean
Checks 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(): ClassBuilder
Creates a builder for a Class contained in this package.
classBuilder
().ClassBuilder.category(): ClassBuilder
Sets 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`
@returnsthis builder, for method chaining.
category
().NamedElementBuilder<ClassBuilder>.name(value: string, language?: string): ClassBuilder
Adds a name to the element in the given language.
@paramvalue - the name text.@paramlanguage - language tag of `value`; defaults to LanguageString.defaultLanguage.@returnsthis builder, for method chaining.
name
('Substance').ClassBuilder.substantialType(): ClassBuilder
Adds the natures of substantials (`functional-complex`, `collective`, and `quantity`) to the natures allowed for instances of the class.
@returnsthis builder, for method chaining.
substantialType
().ClassBuilder.build(): Class
Builds 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,`
@throwsan error if the builder has already been used.
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.

Loading playground…
Show the solution
Loading playground…

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.
  • restrictedTo natures record what instances ultimately are; query them with isSortal(), isRigid(), allowsExactly(), and friends.

Next: attributes →, the intrinsic structure a class gives its instances.