Generalization sets
A generalization set groups several generalizations that share the same
general classifier and says something about them together: whether the
subtypes overlap, and whether they cover the supertype completely. It is how you
state "a Person is either a Child or an Adult, and nothing else."
Two orthogonal constraints define a generalization set:
- Disjoint — no instance belongs to more than one of the subtypes (you can't be both a Child and an Adult).
- Complete — every instance of the general belongs to at least one subtype (every Person is a Child or an Adult; there is no third option).
A set that is both disjoint and complete is a partition — the most common and most informative case.
Building a generalization set
First build the generalizations you want to group (from
the previous page), then pass them to
generalizationSetBuilder(). The flags read declaratively: .partition(),
or any combination of .disjoint() / .overlapping() and .complete() /
.incomplete().
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();
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 const adult: Classadult = 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('Adult').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();
// The generalizations to group…
const const childGen: GeneralizationchildGen = 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);
const const adultGen: GeneralizationadultGen = 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 adult: Classadult);
// …grouped into a partition (disjoint AND complete).
const const byAge: GeneralizationSetbyAge = const model: Packagemodel
.Package.generalizationSetBuilder(): GeneralizationSetBuilderCreates a builder for a
GeneralizationSet
contained in this
package.generalizationSetBuilder()
.GeneralizationSetBuilder.partition(): GeneralizationSetBuilderSets the generalization set as a partition, i.e., as both disjoint and
complete.partition()
.NamedElementBuilder<GeneralizationSetBuilder>.name(value: string, language?: string): GeneralizationSetBuilderAdds a name to the element in the given language.name('by life phase')
.GeneralizationSetBuilder.generalizations(...generalizations: Generalization[]): GeneralizationSetBuilderSets the
Generalization
instances grouped by the generalization
set, replacing any previously set generalizations.generalizations(const childGen: GeneralizationchildGen, const adultGen: GeneralizationadultGen)
.GeneralizationSetBuilder.build(): GeneralizationSetBuilds an instance of
GeneralizationSet
with the parameters
passed to the builder. When no methods are evoked, the created
generalization set has the following defaults:
- `id: "randomly-generated-id",`
- `created: new Date(),`
- `isDisjoint: false,`
- `isComplete: 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 byAge: GeneralizationSetbyAge.GeneralizationSet.isDisjoint: booleanIndicates whether the specifics of this set have no common instances,
i.e., whether the specializations are mutually exclusive.isDisjoint); // 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 byAge: GeneralizationSetbyAge.GeneralizationSet.isComplete: booleanIndicates whether every instance of the general classifier is an
instance of at least one specific of this set.isComplete); // 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 byAge: GeneralizationSetbyAge.GeneralizationSet.isPartition(): booleanChecks whether this generalization set is a partition, i.e., whether it
is both disjoint and complete.isPartition()); // true
For an overlapping or incomplete set, swap the flag:
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();
const const employee: Classemployee = 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('Employee').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.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('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();
const const employeeGen: GeneralizationemployeeGen = 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 employee: Classemployee);
const const customerGen: GeneralizationcustomerGen = 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 customer: Classcustomer);
// A person may be both, and need be neither: overlapping and incomplete.
const const roles: GeneralizationSetroles = const model: Packagemodel
.Package.generalizationSetBuilder(): GeneralizationSetBuilderCreates a builder for a
GeneralizationSet
contained in this
package.generalizationSetBuilder()
.GeneralizationSetBuilder.overlapping(): GeneralizationSetBuilderSets the generalization set as overlapping, i.e., states that the
specific classifiers in the set may share instances, reverting a
previous call to `disjoint()`.overlapping()
.GeneralizationSetBuilder.incomplete(): GeneralizationSetBuilderSets the generalization set as incomplete, i.e., states that some
instances of the general classifier may not be instances of any specific
classifier in the set, reverting a previous call to `complete()`.incomplete()
.NamedElementBuilder<GeneralizationSetBuilder>.name(value: string, language?: string): GeneralizationSetBuilderAdds a name to the element in the given language.name('by role')
.GeneralizationSetBuilder.generalizations(...generalizations: Generalization[]): GeneralizationSetBuilderSets the
Generalization
instances grouped by the generalization
set, replacing any previously set generalizations.generalizations(const employeeGen: GeneralizationemployeeGen, const customerGen: GeneralizationcustomerGen)
.GeneralizationSetBuilder.build(): GeneralizationSetBuilds an instance of
GeneralizationSet
with the parameters
passed to the builder. When no methods are evoked, the created
generalization set has the following defaults:
- `id: "randomly-generated-id",`
- `created: new Date(),`
- `isDisjoint: false,`
- `isComplete: false,`build();
Reading a set back
The set can report its general and specifics without you tracking them separately — handy when validating a taxonomy:
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();
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 const adult: Classadult = 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('Adult').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 byAge: GeneralizationSetbyAge = const model: Packagemodel
.Package.generalizationSetBuilder(): GeneralizationSetBuilderCreates a builder for a
GeneralizationSet
contained in this
package.generalizationSetBuilder()
.GeneralizationSetBuilder.partition(): GeneralizationSetBuilderSets the generalization set as a partition, i.e., as both disjoint and
complete.partition()
.GeneralizationSetBuilder.generalizations(...generalizations: Generalization[]): GeneralizationSetBuilderSets the
Generalization
instances grouped by the generalization
set, replacing any previously set generalizations.generalizations(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), 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 adult: Classadult))
.GeneralizationSetBuilder.build(): GeneralizationSetBuilds an instance of
GeneralizationSet
with the parameters
passed to the builder. When no methods are evoked, the created
generalization set has the following defaults:
- `id: "randomly-generated-id",`
- `created: new Date(),`
- `isDisjoint: false,`
- `isComplete: 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 byAge: GeneralizationSetbyAge.GeneralizationSet.getGeneral(): Classifier<any, any>Retrieves the classifier that is the common general of all
generalizations in this set.getGeneral() === const person: Classperson); // 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 byAge: GeneralizationSetbyAge.GeneralizationSet.getSpecifics(): Classifier<any, any>[]Retrieves the specific classifiers of the generalizations in this set,
without duplicates.getSpecifics().Array<Classifier<any, any>>.length: numberGets or sets the length of the array. This is a number one higher than the highest index in the array.length); // 2 — Child, Adult
A high-order set can name the class whose instances are the subtypes with
.categorizer(type). That is an advanced, second-order modeling move — most
sets don't need it — but the builder supports it when you do.
Key takeaways
- A generalization set constrains a group of generalizations sharing one general classifier.
- Disjoint rules out shared instances; complete requires full coverage;
.partition()is both at once. - Build the generalizations first, then pass them to
generalizationSetBuilder().generalizations(...). - Read a set back with
getGeneral(),getSpecifics(), andisPartition().
Next: notes & anchors →, for annotating a model.