Object model

Bases: object

An attribute link is a named slot in an instance, which holds the value of an attribute

  • name (str) – the name of the attribute link

  • value (DataValue) – the value of the attribute.

  • attribute (Property) – the attribute or property from the structural metamodel.

  • name (str) – inherited from NamedElement, represents the name of the attribute link.

  • value (DataValue) – the value of the attribute.

  • attribute (Property) – the attribute or property from the structural metamodel.

property value : DataValue

Get value of the attribute.

Type:

DataValue

property attribute : Property

Get the attribute.

Type:

Property

class besser.BUML.metamodel.object.object.Instance(name: str, classifier: Type)[source]

Bases: NamedElement

The instance defines an entity to which a set of operations can be applied and which has a state that stores the effects of the operations.

Parameters:
  • name (str) – the name of the instance

  • classifier (Type) – the classifier of the instance. It could be for example a Class or a PrimitiveDataType of the structural metamodel.

Attributes:
  • name (str) – inherited from NamedElement, represents the name of the instance.

  • classifier (Type) – the classifier of the instance. It could be for example a Class or a PrimitiveDataType of the structural metamodel.

property classifier : Type

Get the classifier.

Type:

Type

_abc_impl = <_abc._abc_data object>
class besser.BUML.metamodel.object.object.Object(name: str, classifier: Type, slots: list[AttributeLink] = None)[source]

Bases: Instance

An object is an instance that originates from a class.

Parameters:
  • name (str) – the name of the object instance

  • classifier (Type) – the classifier of the object instance. It could be for example a Class or a PrimitiveDataType of the structural metamodel.

  • slots (list[AttributeLink]) – list of properties of the instance

Attributes:
  • name (str) – inherited from NamedElement, represents the name of the object instance.

  • classifier (Type) – Inherited from Instance, represents the classifier of the object.

  • slots (list[AttributeLink]) – list of properties of the instance

property name

Get the name of the object instance.

Type:

str

property name_

Get the name of the object instance.

Type:

str

property slots : list[AttributeLink]

Get the list of slots (attributes) of the object instance.

Type:

list[AttributeLink]

add_slot(slot: AttributeLink)[source]

Add a slot (attribute) to the object instance.

Get the set of links associated with the object instance.

set[Link]

Add a link to the object instance.

Delete a link from the object instance.

Get the set of link ends associated with the object instance.

_is_internal_attr(key: str) → bool[source]

Check if the key is an internal attribute of the Object class.

_is_fully_initialized() → bool[source]

Check if the Object instance is fully initialized.

_set_slot_value(key: str, value) → bool[source]

Set the value of an attribute link if it exists in the slots.

_set_classifier_attribute(key: str, value) → bool[source]

Set the value of an attribute if it exists in the classifier’s attributes.

_handle_association_end(key: str, value) → bool[source]

Handle the case where the key matches an association end.

Create a link between the source end and the target object.

_abc_impl = <_abc._abc_data object>
class besser.BUML.metamodel.object.object.DataValue(classifier: Type, value, name='')[source]

Bases: Instance

An DataValue represent the value of a property or attribute of an Object.

Parameters:
  • classifier (Type) – the classifier of the DataValue. It could be for example a Class or a PrimitiveDataType of the structural metamodel.

  • value – value of the property Instance.

Attributes:
  • classifier (Type) – Inherited from Instance, represents the classifier of the DataValue instance.

  • value – value of the property Instance.

property value

Method to retrieve Value

_primitive_type_to_python_type(typename: str)[source]

Maps a BESSER primitive type name to the corresponding Python type.

_abc_impl = <_abc._abc_data object>
class besser.BUML.metamodel.object.object.LinkEnd(name: str, association_end: Property, object: Object, owner: Link = None)[source]

Bases: NamedElement

A link end is an end point of a link.

Parameters:
  • name (str) – the name of the LinkEnd

  • association_end (Property) – the end represeted by the LinkEnd

  • object (Object) – the object pointed to by the LinkEnd

  • owner (Link) – the Link that owns this LinkEnd

Attributes:
  • name (str) – inherited from NamedElement, represents the name of the LinkEnd

  • association_end (Property) – the end of the link

  • object (Object) – the object pointed to by the LinkEnd

  • owner (Link) – the Link that owns this LinkEnd

property association_end

Method to retrieve the association end

Type:

Property

property object

Method to retrieve the object

Type:

Object

property owner

Method to retrieve the owner link

Type:

Link

_abc_impl = <_abc._abc_data object>

Bases: NamedElement

A link represent a relationship between objects.

  • name (str) – the name of the Link

  • association (Association) – the Association that represents the Link

  • connections – list of link ends.

  • name (str) – inherited from NamedElement, represents the name of the Link

  • association (Association) – the Association that represents the Link

  • connections – list of link ends.

_abc_impl = <_abc._abc_data object>
property association

Method to retrieve the association

Type:

Association

property connections

Method to retrieve the connections

Type:

list[LinkEnd]

add_to_connection(linkEnd)[source]

Method to add linkend

class besser.BUML.metamodel.object.object.ObjectModel(name: str, objects: set[Object] = None)[source]

Bases: NamedElement

An object model is the root element that comprises a number of objects.

Parameters:
  • name (str) – the name of the object model

  • objects (set[Object]) – set of objects in the model

Attributes:
  • name (str) – inherited from NamedElement, represents the name of the model

  • objects (set[Object]) – set of objects in the model

_abc_impl = <_abc._abc_data object>
property instances : set[Object | DataValue]

Method to retrieve the intances (Objects + DataValues).

Type:

set[Union[Object, DataValue]

Method to retrieve the links.

set[Link]

property objects : set[Object]

Method to retrieve the objects.

Type:

set[Object]

add_object(obj: Object)[source]

Object: Method to add an object to the set of objects.

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

Validate the object model according to the UML object diagram constraints.

Parameters:

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

Returns:

Validation result with success flag, errors, and warnings.

Return type:

dict

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

Ensure each object has a unique name inside the model.

Validate that each link is well-formed and typed correctly.

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

Verify that each object satisfies multiplicity constraints for every navigable association end.

_validate_object_completeness(warnings: list[str])[source]

Warn about objects with no attribute values defined.

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

Validate that enumeration attribute values are valid literals of their enumeration.

static _conforms_to_type(classifier: Type, expected_type: Type) → bool[source]

Return True if classifier matches or specializes expected_type.

static _format_multiplicity(assoc_end: Property) → str[source]

Render multiplicity bounds readable for error messages.