:py:mod:`ontouml_py.model.ontoumlelement` ========================================= .. py:module:: ontouml_py.model.ontoumlelement .. autoapi-nested-parse:: This module defines the core elements of an OntoUML model, providing a robust framework for representing and managing OntoUML elements. OntoUML is a well-established modeling language used primarily in the field of ontology-driven conceptual modeling. The module includes an abstract base class, `OntoumlElement`, which serves as the foundation for all other elements in an OntoUML model. This class encapsulates common features such as unique identification, creation and modification timestamps, and validation logic to ensure the integrity of these attributes. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: ontouml_py.model.ontoumlelement.OntoumlElement .. py:class:: OntoumlElement(**data) Bases: :py:obj:`abc.ABC`, :py:obj:`pydantic.BaseModel` Abstract base class representing a generic element within an OntoUML model. This class provides foundational attributes and methods for all OntoUML elements, including unique identification and timestamps for creation and modification. It enforces constraints on certain attributes and includes validation logic to maintain their integrity. :ivar id: A unique identifier for the element, automatically generated upon instantiation. :vartype id: str :ivar created: Timestamp when the element was created, defaults to the current time. :vartype created: datetime :ivar modified: Timestamp when the element was last modified, can be None if not modified. :vartype modified: Optional[datetime] :cvar model_config: Configuration settings for the Pydantic model. :vartype model_config: Dict[str, Any] .. py:attribute:: id :type: str .. py:attribute:: created :type: datetime.datetime .. py:attribute:: modified :type: Optional[datetime.datetime] .. py:attribute:: model_config .. py:method:: __eq__(other) Determine if two OntoumlElement instances are equal based on their unique identifiers. This method overrides the default equality comparison behavior. It is essential for comparing instances of OntoumlElement, particularly in collections and when ensuring uniqueness. Equality is determined solely based on the 'id' attribute, which is assumed to be a unique identifier for each instance. :param other: The other object to compare with the current instance. :type other: object :return: True if both instances have the same 'id', False otherwise. Returns NotImplemented if 'other' is not an instance of OntoumlElement. :rtype: bool :raises TypeError: If 'other' is not an instance of OntoumlElement and cannot be compared. .. py:method:: __hash__() Compute the hash value of an OntoumlElement instance based on its unique identifier. This method enables OntoumlElement instances to be used in hash-based data structures like sets and dicts. The hash value is computed using the 'id' attribute, ensuring that each instance has a distinct hash value corresponding to its unique identifier. :return: The hash value of the instance, computed using its 'id'. :rtype: int