Structural model

class besser.BUML.metamodel.structural.structural.Association(name: str, ends: set[Property], timestamp: datetime = None, metadata: Metadata = None, is_derived: bool = False, uncertainty: float = 0.0)[source]

Bases: NamedElement

Represents an association between classes.

An Association defines a relationship between classes and is composed of two or more ends, each associated with a class. An association must have more than one end.

Parameters:
  • name (str) – The name of the association.

  • ends (set[Property]) – The set of ends related to the association.

  • timestamp (datetime) – Object creation datetime (default is current time).

  • metadata (Metadata) – Metadata information for the association (None as default).

  • is_derived (bool) – Inherited from NamedElement, indicates whether the element is derived (False as default).

name

Inherited from NamedElement, represents the name of the association.

Type:

str

ends

The set of ends related to the association.

Type:

set[Property]

timestamp

Inherited from NamedElement; object creation datetime (default is current time).

Type:

datetime

metadata

Metadata information for the association (None as default).

Type:

Metadata

is_derived

Inherited from NamedElement, indicates whether the element is derived (False as default).

Type:

bool

__ends: set[Property]
_abc_impl = <_abc._abc_data object>
property ends: set[Property]

Get the ends of the association.

Type:

set[Property]

class besser.BUML.metamodel.structural.structural.AssociationClass(name: str, attributes: set[Property], association: Association, timestamp: datetime = None, metadata: Metadata = None, is_derived: bool = False, uncertainty: float = 0.0)[source]

Bases: Class

An AssociationClass is a class that that has an association nature. It inherits from Class and is associated with an underlying Association.

Parameters:
  • name (str) – The name of the association class.

  • attributes (set[Property]) – The set of attributes associated with the association class.

  • association (Association) – The underlying association linked to the association class.

  • timestamp (datetime) – Object creation datetime (default is current time).

  • metadata (Metadata) – Metadata information for the association class (None as default).

  • is_derived (bool) – Inherited from NamedElement, indicates whether the element is derived (False as default).

name

Inherited from Class, represents the name of the association class.

Type:

str

attributes

Inherited from Class, represents the set of attributes associated with the association class.

Type:

set[Property]

association

The underlying association linked to the association class.

Type:

Association

timestamp

Inherited from NamedElement; object creation datetime (default is current time).

Type:

datetime

metadata

Metadata information for the association class (None as default).

Type:

Metadata

is_derived

Inherited from NamedElement, indicates whether the element is derived (False as default).

Type:

bool

_abc_impl = <_abc._abc_data object>
property association: Association

Get the underlying association of the association class.

Type:

Association

class besser.BUML.metamodel.structural.structural.BehaviorDeclaration(name: str, implementations: set[BehaviorImplementation], uncertainty: float = 0.0)[source]

Bases: NamedElement

A BehaviorDeclaration represents the signature of a behavior associated with a class.

Parameters:
  • name (str) – The name of the behavior.

  • implementations (set[BehaviorImplementation]) – The implementations associated with the behavior.

name

The name of the behavior.

Type:

str

implementations

The implementations associated with the behavior.

Type:

set[BehaviorImplementation]

_abc_impl = <_abc._abc_data object>
property implementations: set[BehaviorImplementation]

Get the implementations of the behavior.

Type:

set[BehaviorImplementation]

class besser.BUML.metamodel.structural.structural.BehaviorImplementation(name: str, uncertainty: float = 0.0)[source]

Bases: NamedElement

A behaviorImplementation represents the body of a behavior associated with a class.

Parameters:

name (str) – The name of the behavior implementation.

name

The name of the behavior implementation.

Type:

str

_abc_impl = <_abc._abc_data object>
class besser.BUML.metamodel.structural.structural.BinaryAssociation(name: str, ends: set[Property], timestamp: datetime = None, metadata: Metadata = None, is_derived: bool = False, uncertainty: float = 0.0)[source]

Bases: Association

Represents a binary association between two classes.

A BinaryAssociation is a specialized form of Association that specifically involves two ends, each associated with a class. It enforces constraints on the association, such as having exactly two ends. Exactly two ends are required

Parameters:
  • name (str) – The name of the binary association.

  • ends (set[Property]) – The set of ends related to the binary association.

  • timestamp (datetime) – Object creation datetime (default is current time).

  • metadata (Metadata) – Metadata information for the binary association (None as default).

  • is_derived (bool) – Inherited from NamedElement, indicates whether the element is derived (False as default).

name

Inherited from Association, represents the name of the binary association.

Type:

str

ends

Inherited from NamedElement, represents the set of ends related to the binary association.

Type:

set[Property]

timestamp

Inherited from NamedElement; object creation datetime (default is current time).

Type:

datetime

metadata

Metadata information for the binary association (None as default).

Type:

Metadata

is_derived

Inherited from NamedElement, indicates whether the element is derived (False as default).

Type:

bool

_abc_impl = <_abc._abc_data object>
property ends: set[Property]

Get the ends of the association.

Type:

set[Property]

class besser.BUML.metamodel.structural.structural.Class(name: str, attributes: set[Property] = None, methods: set[Method] = None, is_abstract: bool = False, is_read_only: bool = False, behaviors: set[BehaviorDeclaration] = None, timestamp: datetime = None, metadata: Metadata = None, is_derived: bool = False, uncertainty: float = 0.0)[source]

Bases: Type

Represents a class in a modeling context.

A Class is a type that defines a blueprint for objects. It can have attributes, associations, and generalizations with other classes.

Parameters:
  • name (str) – The name of the class.

  • attributes (set[Property]) – The set of attributes associated with the class (None as default).

  • methods (set[Method]) – The set of methods of the class (None as default).

  • is_abstract (bool) – Indicates whether the class is abstract (False as default).

  • is_read_only (bool) – Indicates whether the class is read only (False as default).

  • behaviors (set[BehaviorDeclaration]) – The set of behaviors associated with the class (None as default).

  • timestamp (datetime) – Object creation datetime (default is current time).

  • metadata (Metadata) – Metadata information for the class (None as default).

  • is_derived (bool) – Indicates whether the element is derived (False as default).

name

Inherited from Type, represents the name of the class.

Type:

str

attributes

The set of attributes associated with the class (set() as default).

Type:

set[Property]

methods

The set of methods of the class (set() as default).

Type:

set[Method]

is_abstract

Indicates whether the class is abstract (False as default).

Type:

bool

is_read_only

Indicates whether the class is read only (False as default).

Type:

bool

behaviors

The set of behaviors associated with the class (None as default).

Type:

set[BehaviorDeclaration]

timestamp

Object creation datetime (default is current time).

Type:

datetime

metadata

Metadata information for the class (None as default).

Type:

Metadata

is_derived

Inherited from NamedElement, indicates whether the element is derived (False as default).

Type:

bool

__associations: set[Association]
__generalizations: set[Generalization]
_abc_impl = <_abc._abc_data object>
_add_association(association)[source]

Association: Add an association to the set of class associations.

_add_generalization(generalization)[source]

Generalization: Add a generalization to the set of class generalizations.

_delete_association(association)[source]

Association: Remove an association to the set of class associations.

_delete_generalization(generalization)[source]

Generalization: Remove a generalization to the set of class generalizations.

_validate_unique_end_names(ends)[source]

Ensure that no association end has a duplicate name in this class or its specializations.

add_attribute(attribute: Property)[source]

Property: Add an attribute to the set of class attributes.

Raises:

ValueError – if the attribute name already exist.

add_method(method: Method)[source]

Method: Add a method to the set of class methods.

Raises:

ValueError – if the method name already exist.

all_association_ends() set[Property][source]

set[Property]: Get the set of direct and indirect association ends of the class.

all_attributes() set[Property][source]

set[Property]: Get all attributes, including inherited ones.

all_parents() set[source]

set[Class]: Get the set of direct and indirect parents of the class.

all_specializations() set[source]

set[Class]: Get the set of direct and indirect specializations (children) of the class.

association_ends() set[source]

set[Property]: Get the set of association ends of the class.

property associations: set

Get the set of associations involving the class.

Type:

set[Association]

property attributes: set[Property]

Get the attributes of the class.

Type:

set[Property]

property behaviors: set[BehaviorDeclaration]

Get the behaviors associated with the class.

Type:

set[BehaviorDeclaration]

property generalizations: set

Get the set of generalizations involving the class.

Type:

set[Generalization]

id_attribute() Property[source]

Property: Get the id attribute of the class.

inherited_attributes() set[Property][source]

set[Property]: Get the set of inherited attributes.

property is_abstract: bool

Get whether the class is abstract.

Type:

bool

property is_read_only: bool

Get whether the class is read only.

Type:

bool

property methods: set[Method]

Get the methods of the class.

Type:

set[Method]

parents() set[source]

set[Class]: Get the set of direct parents of the class.

specializations() set[source]

set[Class]: Get the set of direct specializations (children) of the class.

class besser.BUML.metamodel.structural.structural.Constraint(name: str, context: Class, expression: str, language: str, description: str = None, timestamp: datetime = None, metadata: Metadata = None, is_derived: bool = False, uncertainty: float = 0.0)[source]

Bases: NamedElement

A Constraint is a statement that restricts or defines conditions on the behavior, structure, or other aspects of the modeled system.

Parameters:
  • name (str) – The name of the constraint.

  • context (Class) – The class to which the constraint is associated.

  • expression (str) – The expression or condition defined by the constraint.

  • language (str) – The language in which the constraint expression is written.

  • description (str) – Optional natural-language explanation shown to end-users when the constraint is violated. Intended for non-technical audiences (e.g. graphical editor users) who may not understand the raw constraint expression.

  • timestamp (datetime) – Object creation datetime (default is current time).

  • metadata (Metadata) – Metadata information for the constraint (None as default).

  • is_derived (bool) – Inherited from NamedElement, indicates whether the element is derived (False as default).

name

Inherited from NamedElement, represents the name of the constraint.

Type:

str

context

The class to which the constraint is associated.

Type:

Class

expression

The expression or condition defined by the constraint.

Type:

str

language

The language in which the constraint expression is written.

Type:

str

description

Optional natural-language explanation surfaced on validation failure.

Type:

str

timestamp

Inherited from NamedElement; object creation datetime (default is current time).

Type:

datetime

metadata

Metadata information for the constraint (None as default).

Type:

Metadata

is_derived

Inherited from NamedElement, indicates whether the element is derived (False as default).

Type:

bool

_abc_impl = <_abc._abc_data object>
property context: Class

Get the class to which the constraint is associated.

Type:

Class

property description: str

Get the natural-language explanation shown when the constraint is violated.

Type:

str

property expression: str

Get the source text of the constraint expression.

Type:

str

property language: str

Get the language in which the constraint expression is written.

Type:

str

class besser.BUML.metamodel.structural.structural.DataType(name: str, timestamp: datetime = None, metadata: Metadata = None, is_derived: bool = False, uncertainty: float = 0.0)[source]

Bases: Type

Represents a data type.

This class inherits from NamedElement and is used to model data types.

Parameters:
  • name (str) – The name of the data type.

  • timestamp (datetime) – Object creation datetime (default is current time).

  • metadata (Metadata) – Metadata information for the data type (None as default).

name

Inherited from NamedElement, represents the name of the data type.

Type:

str

timestamp

Inherited from NamedElement; object creation datetime (default is current time).

Type:

datetime

metadata

Metadata information for the data type (None as default).

Type:

Metadata

_abc_impl = <_abc._abc_data object>
class besser.BUML.metamodel.structural.structural.DomainModel(name: str, types: set[Type] = None, associations: set[Association] = None, generalizations: set[Generalization] = None, packages: set[Package] = None, constraints: set[Constraint] = None, timestamp: datetime = None, metadata: Metadata = None, is_derived: bool = False, elements: set[Element] = None, uncertainty: float = 0.0)[source]

Bases: Model

A domain model comprises a number of types, associations, generalizations, packages, constraints, and others.

Parameters:
  • name (str) – The name of the domain model.

  • types (set[Type]) – The set of types (classes and datatypes) in the domain model (set() as default).

  • associations (set[Association]) – The set of associations in the domain model (set() as default).

  • generalizations (set[Generalization]) – The set of generalizations in the domain model (set() as default).

  • packages (set[Package]) – The set of packages in the domain model (set() as default).

  • constraints (set[Constraint]) – The set of constraints in the domain model (set() as default).

  • timestamp (datetime) – Object creation datetime (default is current time).

  • metadata (Metadata) – Metadata information for the domain model (None as default).

  • is_derived (bool) – Inherited from NamedElement, indicates whether the element is derived (False as default).

  • elements (set[Element]) – Set of model Elements in the Model. This property is derived (auto-calculated).

name

Inherited from NamedElement, represents the name of the domain model.

Type:

str

types

The set of types (classes and datatypes) in the domain model (set() as default).

Type:

set[Type]

associations

The set of associations in the domain model (set() as default).

Type:

set[Association]

generalizations

The set of generalizations in the domain model (set() as default).

Type:

set[Generalization]

packages

The set of packages in the domain model (set() as default).

Type:

set[Package]

constraints

The set of constraints in the domain model (set() as default).

Type:

set[Constraint]

timestamp

Inherited from NamedElement; object creation datetime (default is current time).

Type:

datetime

metadata

Metadata information for the domain model (None as default).

Type:

Metadata

is_derived

Inherited from NamedElement, indicates whether the element is derived (False as default).

Type:

bool

elements

Set of model Elements in the Model. This property is derived (auto-calculated).

Type:

set[Element]

_abc_impl = <_abc._abc_data object>
_update_elements()[source]

Recalculates the elements property by combining all relevant sets.

_validate_associations(errors: list[str])[source]

Validate that association ends reference types in the model.

_validate_attribute_shadowing(errors: list[str])[source]

Validate that subclass attributes do not shadow inherited attributes.

_validate_circular_inheritance(errors: list[str])[source]

Detect circular inheritance in the class hierarchy.

_validate_constraints(errors: list[str])[source]

Validate that constraint contexts reference classes in the model.

Walks both class-level invariants (self.__constraints) and every class’s methods’ pre/post lists so a precondition with a stale or external context class is flagged the same way an invariant would be.

_validate_generalizations(errors: list[str])[source]

Validate that generalizations reference types in the model.

_validate_multiplicities(errors: list[str])[source]

Validate that multiplicities on association ends and attributes are well-formed.

add_association(association: Association)[source]

Association: Add an association to the set of associations of the model.

add_constraint(constraint: Constraint)[source]

Constraint: Add a constraint to the set of constraints of the model.

add_generalization(generalization: Generalization)[source]

Generalization: Add a generalization to the set of generalizations of the model.

add_type(type_: Type)[source]

Type: Add a type (Class or DataType) to the set of types of the model.

property associations: set[Association]

Get the set of associations in the domain model.

Type:

set[Association]

classes_sorted_by_inheritance() list[Class][source]

list[Class]: Get the list of classes ordered by inheritance.

property constraints: set[Constraint]

Get the set of constraints in the domain model.

Type:

set[Constraint]

property generalizations: set[Generalization]

Get the set of generalizations in the domain model.

Type:

set[Generalization]

get_class_by_name(class_name: str) Class[source]

Class: Gets a class by name.

get_classes() set[Class][source]

set[Class]: Get all classes within the domain model.

get_enumerations() set[Enumeration][source]

set[Enumeration]: Get the set of enumerations in the domain model.

get_type_by_name(type_name: str) Type[source]

Type: Gets an Type by name.

property packages: set[Package]

Get the set of packages in the domain model.

Type:

set[Package]

remove_association(association: Association)[source]

Remove an association from the model and clean up references in involved classes.

Parameters:

association (Association) – The association to remove.

Raises:

ValueError – if the association is not in the model.

remove_constraint(constraint: Constraint)[source]

Remove a constraint from the model.

Parameters:

constraint (Constraint) – The constraint to remove.

Raises:

ValueError – if the constraint is not in the model.

remove_generalization(generalization: Generalization)[source]

Remove a generalization from the model and clean up references in involved classes.

Parameters:

generalization (Generalization) – The generalization to remove.

Raises:

ValueError – if the generalization is not in the model.

remove_type(type_: Type)[source]

Remove a type from the model.

Parameters:

type (Type) – The type to remove.

Raises:

ValueError – if the type is not in the model.

property types: set[Type]

Get the set of types in the domain model.

Type:

set[Type]

validate(raise_exception: bool = True) dict[source]

Validate the domain model according to structural model constraints.

Parameters:

raise_exception (bool) – If True, raise ValueError when validation fails.

Returns:

Validation result with success flag, errors, and warnings.

Return type:

dict

class besser.BUML.metamodel.structural.structural.Element(timestamp: datetime = None, is_derived: bool = False, uncertainty: float = 0.0)[source]

Bases: ABC

Element is the Superclass of all structural model elements.

Parameters:
  • timestamp (datetime) – Object creation datetime (default is current time).

  • is_derived (bool) – Indicates whether the element is derived (False as default).

  • uncertainty (float) – Indicates the uncertainty level of the element as a probability between 0 and 1 (0.0 as default).

timestamp

Object creation datetime (default is current time).

Type:

datetime

is_derived

Indicates whether the element is derived (False as default).

Type:

bool

uncertainty

Indicates the uncertainty level of the element as a probability between 0 and 1 (0.0 as default).

Type:

float

_abc_impl = <_abc._abc_data object>
property is_derived: bool

Get whether the element is derived.

Type:

bool

property timestamp: datetime

Get the timestamp of the element.

Type:

datetime

property uncertainty: float

Get the uncertainty level of the element as a probability between 0 and 1.

Type:

float

class besser.BUML.metamodel.structural.structural.Enumeration(name: str, literals: set[EnumerationLiteral] = None, timestamp: datetime = None, metadata: Metadata = None, uncertainty: float = 0.0)[source]

Bases: DataType

Class representing an enumeration.

This class is a subclass of DataType and is used to represent enumerations with a specified name and a set of enumeration literals.

Parameters:
  • name (str) – The name of the enumeration data type.

  • literals (set[EnumerationLiteral]) – Set of enumeration literals associated with the enumeration (None as default).

  • timestamp (datetime) – Object creation datetime (default is current time).

  • metadata (Metadata) – Metadata information for the enumeration (None as default).

name

Inherited from DataType, represents the name of the enumeration.

Type:

str

literals

Represents a set of enumeration literals associated with the enumeration (None as default).

Type:

set[EnumerationLiteral]

timestamp

Inherited from NamedElement; object creation datetime (default is current time).

Type:

datetime

metadata

Metadata information for the enumeration (None as default).

Type:

Metadata

_abc_impl = <_abc._abc_data object>
add_literal(literal: EnumerationLiteral)[source]

Add an enumeration literal to the set.

Raises:

ValueError – if the enumeration literal name already exist.

property literals: set[EnumerationLiteral]

Get the set of literals.

Type:

set[EnumerationLiteral]

class besser.BUML.metamodel.structural.structural.EnumerationLiteral(name: str, owner: DataType = None, timestamp: datetime = None, metadata: Metadata = None, uncertainty: float = 0.0)[source]

Bases: NamedElement

Class representing an enumeration literal.

This class is a subclass of NamedElement and is used to represent individual literals within an enumeration.

Parameters:
  • name (str) – The name of the enumeration literal.

  • owner (DataType) – The owner data type of the enumeration literal (None as default).

  • timestamp (datetime) – Object creation datetime (default is current time).

  • metadata (Metadata) – Metadata information for the literal (None as default).

name

Inherited from NamedElement, represents the name of the enumeration literal.

Type:

str

owner

Represents the owner data type of the enumeration literal (None as default).

Type:

DataType

timestamp

Inherited from NamedElement; object creation datetime (default is current time).

Type:

datetime

metadata

Metadata information for the literal (None as default).

Type:

Metadata

_abc_impl = <_abc._abc_data object>
property owner: DataType

Get the owner.

Type:

Datatype

class besser.BUML.metamodel.structural.structural.Generalization(general: Class, specific: Class, timestamp: datetime = None, is_derived: bool = False, uncertainty: float = 0.0)[source]

Bases: Element

Represents a generalization relationship between two classes.

A Generalization is a relationship between two classes, where one class (specific) inherits attributes and behaviors from another class (general).

Parameters:
  • general (Class) – The general (parent) class in the generalization relationship.

  • specific (Class) – The specific (child) class in the generalization relationship.

  • timestamp (datetime) – Object creation datetime (default is current time).

  • is_derived (bool) – Inherited from NamedElement, indicates whether the element is derived (False as default).

general

The general (parent) class in the generalization relationship.

Type:

Class

specific

The specific (child) class in the generalization relationship.

Type:

Class

timestamp

Inherited from NamedElement; object creation datetime (default is current time).

Type:

datetime

is_derived

Inherited from NamedElement, indicates whether the element is derived (False as default).

Type:

bool

_abc_impl = <_abc._abc_data object>
property general: Class

Get the general (parent) class.

Type:

Class

property specific: Class

Get the specific (child) class.

Type:

Class

class besser.BUML.metamodel.structural.structural.GeneralizationSet(name: str, generalizations: set[Generalization], is_disjoint: bool, is_complete: bool, timestamp: datetime = None, metadata: Metadata = None, is_derived: bool = False, uncertainty: float = 0.0)[source]

Bases: NamedElement

Represents a set of generalization relationships.

Parameters:
  • name (str) – The name of the generalization set.

  • generalizations (set[Generalization]) – The set of generalization relationships in the set.

  • is_disjoint (bool) – Indicates whether the set is disjoint (instances cannot belong to more than one class in the set).

  • is_complete (bool) – Indicates whether the set is complete (every instance of the superclass must belong to a subclass).

  • timestamp (datetime) – Object creation datetime (default is current time).

  • metadata (Metadata) – Metadata information for the generalization set (None as default).

  • is_derived (bool) – Inherited from NamedElement, indicates whether the element is derived (False as default).

name

Inherited from NamedElement, represents the name of the generalization set.

Type:

str

generalizations

The set of generalization relationships in the set.

Type:

set[Generalization]

is_disjoint

Indicates whether the set is disjoint (instances cannot belong to more than one class in the set).

Type:

bool

is_complete

Indicates whether the set is complete (every instance of the superclass must belong to a subclass).

Type:

bool

timestamp

Inherited from NamedElement; object creation datetime (default is current time).

Type:

datetime

metadata

Metadata information for the generalization set (None as default).

Type:

Metadata

is_derived

Inherited from NamedElement, indicates whether the element is derived (False as default).

Type:

bool

_abc_impl = <_abc._abc_data object>
property generalizations: set[Generalization]

Get the generalization relationships.

Type:

set[Generalization]

property is_complete: bool

Get whether the set is complete.

Type:

bool

property is_disjoint: bool

Get whether the set is disjoint.

Type:

bool

class besser.BUML.metamodel.structural.structural.Metadata(description: str = None, uri: str = None, synonyms: List[str] = None, icon: str = None, timestamp: datetime = None)[source]

Bases: Element

The Metadata class stores additional information about named elements.

Parameters:
  • description (str) – Description of the element (None as default).

  • uri (str) – Uniform resource identifier for the element (None as default).

  • synonyms (List[str]) – List of synonyms of the element (None as default).

  • icon (str) – Icon representing the element (None as default).

  • timestamp (datetime) – Object creation datetime (default is current time).

description

Description of the element (None as default).

Type:

str

uri

Uniform resource identifier for the element (None as default).

Type:

str

synonyms

List of synonyms of the element (None as default).

Type:

List[str]

icon

Icon representing the element (None as default).

Type:

str

timestamp

Object creation datetime (default is current time).

Type:

datetime

_abc_impl = <_abc._abc_data object>
property description: str

Get the description of the metadata.

Type:

str

property icon: str

Get the icon representing the metadata.

Type:

str

property synonyms: List[str]

Get the list of synonyms of the metadata.

Type:

List[str]

property uri: str

Get the URI of the metadata.

Type:

str

class besser.BUML.metamodel.structural.structural.Method(name: str, visibility: str = 'public', is_abstract: bool = False, parameters: list[Parameter] = None, type: Type = None, owner: Type = None, code: str = '', implementation_type: MethodImplementationType = None, state_machine: StateMachine = None, quantum_circuit: QuantumCircuit = None, timestamp: datetime = None, metadata: Metadata = None, is_derived: bool = False, uncertainty: float = 0.0, pre: list[Constraint] = None, post: list[Constraint] = None)[source]

Bases: TypedElement

Method is used to represent a method of a class.

A method can have different types of implementations: - NONE: Abstract method or signature only (UML description) - CODE: Python code implementation - BAL: BESSER Action Language implementation - STATE_MACHINE: Behavior defined by a state machine - QUANTUM_CIRCUIT: Behavior defined by a quantum circuit

Parameters:
  • name (str) – The name of the method.

  • visibility (str) – Determines the kind of visibility of the method (public as default).

  • is_abstract (bool) – Indicates if the method is abstract (False as default).

  • parameters (list[Parameter]) – The list of parameters for the method (list() as default).

  • type (Type) – The type of the method (None as default).

  • owner (Type) – The type that owns the method (None as default).

  • code (str) – code of the method (”” as default).

  • implementation_type (MethodImplementationType) – The type of implementation (auto-detected as default).

  • state_machine (StateMachine) – Reference to a state machine that defines the method behavior (None as default).

  • quantum_circuit (QuantumCircuit) – Reference to a quantum circuit that defines the method behavior (None as default).

  • timestamp (datetime) – Object creation datetime (default is current time).

  • metadata (Metadata) – Metadata information for the method (None as default).

  • is_derived (bool) – Inherited from NamedElement, indicates whether the element is derived (False as default).

  • pre (list[Constraint]) – Preconditions of the method (list() as default).

  • post (list[Constraint]) – Postconditions of the method (list() as default).

name

Inherited from TypedElement, represents the name of the method.

Type:

str

visibility

Inherited from TypedElement, represents the visibility of the method (public as default).

Type:

str

is_abstract

Indicates if the method is abstract. (False as default)

Type:

bool

parameters

The list of parameters for the method (list() as default).

Type:

list[Parameter]

type

Inherited from TypedElement, represents the type of the method (None as default).

Type:

Type

owner

The type that owns the property (None as default).

Type:

Type

code

code of the method (”” as default).

Type:

str

implementation_type

The type of implementation.

Type:

MethodImplementationType

state_machine

Reference to a state machine that defines the method behavior (None as default).

Type:

StateMachine

quantum_circuit

Reference to a quantum circuit that defines the method behavior (None as default).

Type:

QuantumCircuit

timestamp

Inherited from NamedElement; object creation datetime (default is current time).

Type:

datetime

metadata

Metadata information for the method (None as default).

Type:

Metadata

is_derived

Inherited from NamedElement, indicates whether the element is derived (False as default).

Type:

bool

pre

Preconditions of the method (list() as default).

Type:

list[Constraint]

post

Postconditions of the method (list() as default).

Type:

list[Constraint]

_abc_impl = <_abc._abc_data object>
add_parameter(parameter: Parameter)[source]

Parameter: Add a parameter to the set of class parameters.

Raises:

ValueError – if the parameter name already exist.

add_post(constraint: Constraint)[source]

Constraint: Add a postcondition to the method.

Raises:

ValueError – if the postcondition name already exists on this method.

add_pre(constraint: Constraint)[source]

Constraint: Add a precondition to the method.

Raises:

ValueError – if the precondition name already exists on this method.

property code: str

Get the code of the method.

Type:

str

property implementation_type: MethodImplementationType

Get the implementation type of the method.

Type:

MethodImplementationType

property is_abstract: bool

Get whether the method is abstract.

Type:

bool

property owner: Type

Get the owner type of the method.

Type:

Type

property parameters: list[Parameter]

Get the set of parameters of the method.

Type:

list[Parameter]

property post: list[Constraint]

Get the postconditions of the method.

Type:

list[Constraint]

property pre: list[Constraint]

Get the preconditions of the method.

Type:

list[Constraint]

property quantum_circuit: QuantumCircuit

Get the quantum circuit that defines the method behavior.

Type:

QuantumCircuit

property state_machine: StateMachine

Get the state machine that defines the method behavior.

Type:

StateMachine

class besser.BUML.metamodel.structural.structural.MethodImplementationType(*values)[source]

Bases: Enum

Enumeration representing the type of implementation for a method.

NONE

No implementation (abstract method or signature only).

CODE

Implementation provided as Python code string.

BAL

Implementation provided as BESSER Action Language code string.

STATE_MACHINE

Implementation defined by a state machine.

QUANTUM_CIRCUIT

Implementation defined by a quantum circuit.

BAL = 'besser_action_language'
CODE = 'code'
NONE = 'none'
QUANTUM_CIRCUIT = 'quantum_circuit'
STATE_MACHINE = 'state_machine'
class besser.BUML.metamodel.structural.structural.Model(name: str, timestamp: datetime = None, metadata: Metadata = None, is_derived: bool = False, elements: set[Element] = None, uncertainty: float = 0.0)[source]

Bases: NamedElement

A model is the root element. There are different types of models that inherit from this class. For example, DomainModel, ObjectModel, or GUIModel.

Parameters:
  • name (str) – The name of the model.

  • timestamp (datetime) – Object creation datetime (default is current time).

  • metadata (Metadata) – Metadata information for the model (None as default).

  • is_derived (bool) – Inherited from NamedElement, indicates whether the element is derived (False as default).

  • elements (set[Element]) – Set of model Elements in the Model.

name

Inherited from NamedElement, represents the name of the model.

Type:

str

timestamp

Inherited from NamedElement; object creation datetime (default is current time).

Type:

datetime

metadata

Metadata information for the model (None as default).

Type:

Metadata

is_derived

Inherited from NamedElement, indicates whether the element is derived (False as default).

Type:

bool

elements

Set of model Elements in the Model.

Type:

set[Element]

_abc_impl = <_abc._abc_data object>
property elements: set[Element]

Get the set of model elements in the model.

Type:

set[Element]

class besser.BUML.metamodel.structural.structural.Multiplicity(min_multiplicity: int, max_multiplicity: int, is_derived: bool = False, uncertainty: float = 0.0)[source]

Bases: Element

Represents the multiplicity of a Property.

It consists of a minimum and maximum value, indicating the allowed range.

Parameters:
  • min_multiplicity (int) – The minimum multiplicity.

  • max_multiplicity (int) – The maximum multiplicity. Use “*” for unlimited.

  • is_derived (bool) – Indicates whether the element is derived (False as default).

min

The minimum multiplicity.

Type:

int

max

The maximum multiplicity. Use “*” for unlimited.

Type:

int

is_derived

Indicates whether the element is derived (False as default).

Type:

bool

_abc_impl = <_abc._abc_data object>
property max: int

Get the maximum multiplicity.

Type:

int

property min: int

Get the minimum multiplicity.

Type:

int

class besser.BUML.metamodel.structural.structural.NamedElement(name: str, timestamp: datetime = None, metadata: Metadata = None, visibility: str = 'public', is_derived: bool = False, uncertainty: float = 0.0)[source]

Bases: Element

NamedElement represent a structural element with a name.

Parameters:
  • name (str) – The name of the named element

  • timestamp (datetime) – Object creation datetime (default is current time).

  • metadata (Metadata) – Metadata information for the named element (None as default).

  • visibility (str) – Determines the kind of visibility of the named element (public as default).

  • is_derived (bool) – Indicates whether the element is derived (False as default).

name

The name of the named element

Type:

str

timestamp

Object creation datetime (default is current time).

Type:

datetime

metadata

Metadata information for the named element (None as default).

Type:

Metadata

visibility

Determines the kind of visibility of the named element (public as default).

Type:

str

is_derived

Indicates whether the element is derived (False as default).

Type:

bool

_abc_impl = <_abc._abc_data object>
property metadata: Metadata

Get the metadata of the named element.

Type:

Metadata

property name: str

Get the name of the named element.

Type:

str

property visibility: str

Get the visibility of the named element.

Type:

str

class besser.BUML.metamodel.structural.structural.Package(name: str, elements: set[NamedElement], timestamp: datetime = None, metadata: Metadata = None, is_derived: bool = False, uncertainty: float = 0.0)[source]

Bases: NamedElement

A Package is a grouping mechanism that allows organizing and managing a set of NamedElements.

Parameters:
  • name (str) – The name of the package.

  • elements (set[NamedElement]) – The set of elements contained in the package.

  • timestamp (datetime) – Object creation datetime (default is current time).

  • metadata (Metadata) – Metadata information for the package (None as default).

  • is_derived (bool) – Inherited from NamedElement, indicates whether the element is derived (False as default).

name

Inherited from NamedElement, represents the name of the package.

Type:

str

elements

The set of elements contained in the package.

Type:

set[NamedElement]

timestamp

Inherited from NamedElement; object creation datetime (default is current time).

Type:

datetime

metadata

Metadata information for the package (None as default).

Type:

Metadata

is_derived

Inherited from NamedElement, indicates whether the element is derived (False as default).

Type:

bool

_abc_impl = <_abc._abc_data object>
property elements: set[NamedElement]

Get the named elements contained in the package.

Type:

set[NamedElement]

get_associations() set[Association][source]

set[Association]: Get all associations within the package.

get_classes() set[Class][source]

set[Class]: Get all classes within the package.

get_enumerations() set[Enumeration][source]

set[Enumeration]: Get all enumerations within the package.

get_generalizations() set[Generalization][source]

set[Generalization]: Get all generalizations within the package.

class besser.BUML.metamodel.structural.structural.Parameter(name: str, type: Type, default_value: Any = None, timestamp: datetime = None, metadata: Metadata = None, is_derived: bool = False, uncertainty: float = 0.0)[source]

Bases: TypedElement

Parameter is used to represent a parameter of a method with a specific type.

Parameters:
  • name (str) – The name of the parameter.

  • type (Type) – The data type of the parameter.

  • default_value (Any) – The default value of the parameter (None as default).

  • timestamp (datetime) – Object creation datetime (default is current time).

  • metadata (Metadata) – Metadata information for the parameter (None as default).

  • is_derived (bool) – Inherited from NamedElement, indicates whether the element is derived (False as default).

name

Inherited from NamedElement, represents the name of the parameter.

Type:

str

type

Inherited from TypedElement, represents the type of the parameter.

Type:

Type

default_value

The default value of the parameter (None as default).

Type:

Any

timestamp

Inherited from NamedElement; object creation datetime (default is current time).

Type:

datetime

metadata

Metadata information for the parameter (None as default).

Type:

Metadata

_abc_impl = <_abc._abc_data object>
property default_value: Any

Get the default value of the parameter.

Type:

Type

class besser.BUML.metamodel.structural.structural.PrimitiveDataType(name: str, timestamp: datetime = None, metadata: Metadata = None, is_derived: bool = False, uncertainty: float = 0.0)[source]

Bases: DataType

Class representing a primitive data type.

This class is a subclass of DataType and is used to represent primitive data types with a specified name.

Parameters:
  • name (str) – The name of the primitive data type.

  • timestamp (datetime) – Object creation datetime (default is current time).

  • metadata (Metadata) – Metadata information for the primitive data type (None as default).

name

Inherited from NamedElement, represents the name of the primitive data type.

Type:

str

timestamp

Inherited from NamedElement; object creation datetime (default is current time).

Type:

datetime

metadata

Metadata information for the primitive data type (None as default).

Type:

Metadata

_abc_impl = <_abc._abc_data object>
property name: str

Get the name of the named element.

Type:

str

class besser.BUML.metamodel.structural.structural.Property(name: str, type: Type, owner: Type = None, multiplicity: Multiplicity = Multiplicity(1, 1, is_derived=False), visibility: str = 'public', is_composite: bool = False, is_navigable: bool = True, is_id: bool = False, is_read_only: bool = False, is_optional: bool = False, is_external_id: bool = False, default_value: Any = None, timestamp: datetime = None, metadata: Metadata = None, is_derived: bool = False, uncertainty: float = 0.0)[source]

Bases: TypedElement

A property can represents an attribute of a class or an end of an association.

Properties are owned by a class or an association.

Parameters:
  • name (str) – The name of the property.

  • type (Type) – The type of the property.

  • owner (Type) – The type that owns the property (None as default).

  • multiplicity (Multiplicity) – The multiplicity of the property (1..1 as default).

  • visibility (str) – The visibility of the property (public as default).

  • is_composite (bool) – Indicates whether the property is a composite (False as default).

  • is_navigable (bool) – Indicates whether the property is navigable in a relationship (True as default).

  • is_id (bool) – Indicates whether the property is an id (False as default).

  • is_read_only (bool) – Indicates whether the property is read only (False as default).

  • is_optional (bool) – Indicates whether the property is optional/nullable (False as default).

  • default_value (Any) – The default value of the property (None as default).

  • timestamp (datetime) – Object creation datetime (default is current time).

  • metadata (Metadata) – Metadata information for the property (None as default). is_derived (bool): Inherited from NamedElement, indicates whether the element is derived (False as default).

name

Inherited from TypedElement, represents the name of the property.

Type:

str

type

Inherited from TypedElement, represents the type of the property.

Type:

Type

owner

The type that owns the property (public as default).

Type:

Type

multiplicity

The multiplicity of the property (1..1 as default).

Type:

Multiplicity

visibility

Inherited from TypedElement, represents the visibility of the property (public as default).

Type:

str

is_composite

Indicates whether the property is a composite (False as default).

Type:

bool

is_navigable

Indicates whether the property is navigable in a relationship (True as default).

Type:

bool

is_id

Indicates whether the property is an id (False as default).

Type:

bool

is_read_only

Indicates whether the property is read only (False as default).

Type:

bool

is_optional

Indicates whether the property is optional/nullable (False as default).

Type:

bool

default_value

The default value of the property (None as default).

Type:

Any

timestamp

Inherited from NamedElement; object creation datetime (default is current time).

Type:

datetime

metadata

Metadata information for the property (None as default).

Type:

Metadata

is_derived

Inherited from NamedElement, indicates whether the element is derived (False as default).

Type:

bool

_abc_impl = <_abc._abc_data object>
property default_value: Any

Get the default value of the property.

Type:

Any

property is_composite: bool

Get whether the property is composite.

Type:

bool

property is_external_id: bool

Get whether the property is an external identifier.

External identifiers are user-facing keys (e.g. name, email, sku) that people outside the system use to locate an object, distinct from the internal/surrogate primary key (is_id). A class may have multiple external-id properties forming a composite key, and a property can be both is_id and is_external_id when a natural key also serves as the PK.

Type:

bool

property is_id: bool

Get whether the property is an id.

Type:

bool

property is_navigable: bool

Get whether the property is navigable.

Type:

bool

property is_optional: bool

Get whether the property is optional.

Type:

bool

property is_read_only: bool

Get whether the property is read only.

Type:

bool

property multiplicity: Multiplicity

Get the multiplicity of the property.

Type:

Multiplicity

opposite_end() Property[source]

Property: Get the opposite end of the property if it is an association end.

property owner: Type

Get the owner type of the property.

Type:

Type

class besser.BUML.metamodel.structural.structural.Type(name: str, timestamp: datetime = None, metadata: Metadata = None, is_derived: bool = False, uncertainty: float = 0.0)[source]

Bases: NamedElement

Type is the Superclass of classes and data types in the model.

Parameters:
  • name (str) – The name of the Type.

  • timestamp (datetime) – Object creation datetime (default is current time).

  • metadata (Metadata) – Metadata information for the type (None as default).

  • is_derived (bool) – Indicates whether the element is derived (False as default).

name

Inherited from NamedElement, represents the name of the Type.

Type:

str

timestamp

Inherited from NamedElement; object creation datetime (default is current time).

Type:

datetime

metadata

Metadata information for the type (None as default).

Type:

Metadata

is_derived

Indicates whether the element is derived (False as default).

Type:

bool

_abc_impl = <_abc._abc_data object>
class besser.BUML.metamodel.structural.structural.TypedElement(name: str, type: Type | str, timestamp: datetime = None, metadata: Metadata = None, visibility: str = 'public', is_derived: bool = False, uncertainty: float = 0.0)[source]

Bases: NamedElement

TypedElement is a subclass of NamedElement and is used to represent elements that have a specific type.

Parameters:
  • name (str) – The name of the typed element.

  • type (Type, str) – The data type of the typed element.

  • timestamp (datetime) – Object creation datetime (default is current time).

  • metadata (Metadata) – Metadata information for the typed element (None as default).

  • visibility (str) – Determines the kind of visibility of the typed element (public as default).

  • is_derived (bool) – Indicates whether the element is derived (False as default).

name

Inherited from NamedElement, represents the name of the typed element.

Type:

str

type

The data type of the typed element.

Type:

Type

timestamp

Inherited from NamedElement; object creation datetime (default is current time).

Type:

datetime

metadata

Metadata information for the typed element (None as default).

Type:

Metadata

visibility

Inherited from NamedElement, represents the visibility of the typed element (public as default).

Type:

str

is_derived

Inherited from NamedElement, indicates whether the element is derived (False as default).

Type:

bool

_abc_impl = <_abc._abc_data object>
property type: Type

Get the type of the typed element.

Type:

Type

type_mapping = {'bool': PrimitiveDataType(bool, 2026-06-08 08:37:44.826565, None), 'date': PrimitiveDataType(date, 2026-06-08 08:37:44.826583, None), 'datetime': PrimitiveDataType(datetime, 2026-06-08 08:37:44.826593, None), 'float': PrimitiveDataType(float, 2026-06-08 08:37:44.826554, None), 'int': PrimitiveDataType(int, 2026-06-08 08:37:44.826536, None), 'str': PrimitiveDataType(str, 2026-06-08 08:37:44.826480, None), 'string': PrimitiveDataType(str, 2026-06-08 08:37:44.826480, None), 'time': PrimitiveDataType(time, 2026-06-08 08:37:44.826573, None), 'timedelta': PrimitiveDataType(timedelta, 2026-06-08 08:37:44.826601, None)}