Structure
EClass
A class in the Ecore metamodel.
struct EClass
Overview
Represents a class definition in the metamodel, similar to a class declaration in object-oriented programming languages. It defines the structure and behaviour of model objects through structural features, operations, and inheritance relationships.
Overview
EClass serves as the primary metaclass type in Ecore, defining:
-
Structural Features: Attributes and references that define the class’s properties
-
Operations: Methods that can be invoked on instances
-
Inheritance: Supertypes that this class extends (supporting multiple inheritance)
-
Metadata: Whether the class is abstract or represents an interface
Creating Classes
Create an EClass using the designated initialiser:
let person = EClass(
name: "Person",
isAbstract: false,
structuralFeatures: [
// Features would be added here
]
)
Inheritance Hierarchy
Classes can extend multiple supertypes through the eSuperTypes property. The allSuperTypes computed property provides the complete inheritance hierarchy including transitive supertypes.
Feature Access
Structural features can be accessed by name using getStructuralFeature(name:) or filtered by type using allAttributes and allReferences.
Topics
Operators
Compare two classes for equality.
Initializers
Initialise a new class with the specified attributes.
Initialise an EClass from a DynamicEObject.
Instance Properties
Retrieve all attributes including inherited ones.
Retrieve all containment references including inherited ones.
Retrieve all references including inherited ones.
Retrieve all structural features including inherited ones.
Retrieve all supertypes including transitive ones.
Annotations attached to this class.
The metaclass describing this class.
The operations (methods) defined on this class.
The structural features (attributes and references) defined on this class.
The direct supertypes of this class.
Unique identifier for this class.
Whether this class is abstract.
Whether this class represents an interface.
The name of this class.
Instance Methods
Reflectively retrieve the value of a feature.
Check whether a feature has been explicitly set.
Reflectively set the value of a feature.
Unset a feature, returning it to its default value.
Retrieve an attribute by name.
Retrieve a reference by name.
Retrieve a structural feature by name.
Hash the essential components of this class.
Check if this class is a supertype of another class.
Type Aliases
The type of classifier for this class.
Default Implementations
Relationships
Conforms To
See Also
Core Types
Base protocol for all Ecore model elements.
A dynamic implementation of EObject that stores feature values generically.
A package in the Ecore metamodel.