openehr-am 0.0.128

openEHR AM Archetype Model, generated from BMM: generations v1_4 (AM 1.4.0, ADL 1.4) and v2_4 (AM 2.4.0, ADL 2; current)
Documentation
// @generated by openehr-codegen from BMM (`BMM_ENUMERATION`) — DO NOT EDIT.
// SPDX-FileCopyrightText: Cadasto B.V.
// SPDX-FileCopyrightText: openEHR Foundation
// SPDX-License-Identifier: Apache-2.0

//! The openEHR `BMM_ENUMERATION` spec class, generated from the vendored BMM
//! meta-model.

#![expect(
    clippy::disallowed_types,
    reason = "adjudicated free-form JSON slots: serde_json::Value is workspace-banned (#1694); a generated carrier exists only where the spec leaves the slot open, and each adjudicated field's NOTE names its citation"
)]
use crate::v2_4::bmm::core::bmm_class::BmmClass;
use crate::v2_4::bmm::core::bmm_enumeration_integer::BmmEnumerationInteger;
use crate::v2_4::bmm::core::bmm_enumeration_string::BmmEnumerationString;
use crate::v2_4::bmm::core::bmm_package::BmmPackage;
use crate::v2_4::bmm::core::bmm_property::BmmProperty;
use crate::v2_4::bmm3::core::entity::bmm_model_type::BmmModelType;
use crate::v2_4::bmm3::core::feature::bmm_feature::BmmFeature;
use crate::v2_4::bmm3::core::feature::bmm_feature_group::BmmFeatureGroup;
use crate::v2_4::bmm3::core::feature::bmm_function::BmmFunction;
use crate::v2_4::bmm3::core::feature::bmm_procedure::BmmProcedure;
use crate::v2_4::bmm3::core::feature::bmm_static::BmmStatic;
use crate::v2_4::bmm3::core::literal_value::bmm_primitive_value::BmmPrimitiveValue;
use crate::v2_4::bmm3::statement::bmm_assertion::BmmAssertion;

/// Definition of an enumeration class, understood as a class whose value range is constrained extensionally, i.e. by an explicit enumeration of named singleton instances.
///
/// Only one inheritance ancestor is allowed in order to provide the base type to which the range constraint is applied.
///
/// The common notion of a set of literals with no explicit defined values is represented as the degenerate subtype `BMM_ENUMERATION_INTEGER`, whose values are 0, 1, ...
#[doc(alias = "BMM_ENUMERATION")]
#[derive(Debug, Clone, PartialEq)]
pub struct BmmEnumerationData {
    // inherited: BMM_MODEL_ELEMENT
    /// Name of this model element.
    pub name: String,
    /// Optional documentation of this element, as a keyed list.
    ///
    /// It is strongly recommended to use the following key /type combinations for the relevant purposes:
    ///
    /// * `"purpose": String`
    /// * `"keywords": List<String>`
    /// * `"use": String`
    /// * `"misuse": String`
    /// * `"references": String`
    ///
    /// Other keys and value types may be freely added.
    pub documentation: Option<std::collections::BTreeMap<String, serde_json::Value>>,
    // NOTE: `scope` (BMM-mandatory back-reference) omitted — LANG BMM3 bmm_module (scope: BMM_MODEL — redefinition of BMM_MODEL_ELEMENT.scope). A back-reference is not forward-owned data and never appears on the canonical wire; emitting it as an owning field would make this type non-constructible.
    /// Optional meta-data of this element, as a keyed list. May be used to extend the meta-model.
    pub extensions: Option<std::collections::BTreeMap<String, serde_json::Value>>,

    // inherited: BMM_MODULE
    /// List of feature groups in this class.
    pub feature_groups: Option<Vec<BmmFeatureGroup>>,

    // inherited: BMM_CLASS
    /// Features of this module.
    pub features: Option<Vec<BmmFeature>>,
    /// List of immediate inheritance parents.
    pub ancestors: Option<std::collections::BTreeMap<String, BmmModelType>>,
    /// Package this class belongs to.
    pub package: BmmPackage,
    /// Properties defined in this class (subset of `_features_`).
    pub properties: Option<std::collections::BTreeMap<String, BmmProperty>>,
    /// Reference to original source schema defining this class. Useful for UI tools to determine which original schema file to open for a given class for manual editing.
    pub source_schema_id: String,
    /// List of computed references to base classes of immediate inheritance descendants, derived when members of `_ancestors_` are attached at creation time.
    pub immediate_descendants: Option<Vec<BmmClass>>,
    /// True if this definition overrides a class of the same name in an included schema.
    pub is_override: bool,
    /// Static properties defined in this class (subset of `_features_`).
    pub static_properties: Option<std::collections::BTreeMap<String, BmmStatic>>,
    /// Functions defined in this class (subset of `_features_`).
    pub functions: Option<std::collections::BTreeMap<String, BmmFunction>>,
    /// Procedures defined in this class (subset of `_features_`).
    pub procedures: Option<std::collections::BTreeMap<String, BmmProcedure>>,
    /// True if this class represents a type considered to be primitive in the type system, i.e. any typically built-in or standard library type such as `String`, `Date`, `Hash<K,V>` etc.
    pub is_primitive: Option<bool>,
    /// True if this class is marked as abstract, i.e. direct instances cannot be created from its direct type.
    pub is_abstract: Option<bool>,
    /// The `invariants` attribute of openEHR `BMM_CLASS` (the vendored BMM carries no documentation for it).
    pub invariants: Option<Vec<BmmAssertion>>,
    /// Subset of `_procedures_` that may be used to initialise a new instance of an object, and whose execution will guarantee that class invariants are satisfied.
    pub creators: Option<std::collections::BTreeMap<String, BmmProcedure>>,
    /// Subset of `_creators_` that create a new instance from a single argument of another type.
    pub converters: Option<std::collections::BTreeMap<String, BmmProcedure>>,
    /// The list of names of the enumeration. If no values are supplied, the integer values 0, 1, 2, ... are assumed.
    pub item_names: Option<Vec<String>>,
    /// Optional list of specific values. Must be 1:1 with `_item_names_` list.
    pub item_values: Option<Vec<BmmPrimitiveValue>>,
}

/// Polymorphic slot of `BMM_ENUMERATION`, dispatched on each payload's `_type`.
///
/// Definition of an enumeration class, understood as a class whose value range is constrained extensionally, i.e. by an explicit enumeration of named singleton instances.
///
/// Only one inheritance ancestor is allowed in order to provide the base type to which the range constraint is applied.
///
/// The common notion of a set of literals with no explicit defined values is represented as the degenerate subtype `BMM_ENUMERATION_INTEGER`, whose values are 0, 1, ...
#[doc(alias = "BMM_ENUMERATION")]
#[derive(Debug, Clone, PartialEq)]
pub enum BmmEnumeration {
    /// The `BMM_ENUMERATION_INTEGER` subtype of `BMM_ENUMERATION`.
    BmmEnumerationInteger(BmmEnumerationInteger),
    /// The `BMM_ENUMERATION_STRING` subtype of `BMM_ENUMERATION`.
    BmmEnumerationString(BmmEnumerationString),
    /// An instance of `BMM_ENUMERATION` itself (its own, least-rich form).
    BmmEnumeration(BmmEnumerationData),
}