Skip to main content

owl_structural_model/
axiom_annotations.rs

1//! Uniform annotations and kind dispatch for every OWL axiom.
2use crate::{Axiom, AxiomAnnotations, AxiomKind};
3impl<L, B> Axiom<L, B> {
4    /// Return the standard axiom family.
5    #[must_use]
6    pub fn kind(&self) -> AxiomKind {
7        match self {
8            Self::Declaration { .. } => AxiomKind::Declaration,
9            Self::SubClassOf { .. } => AxiomKind::SubClassOf,
10            Self::EquivalentClasses { .. } => AxiomKind::EquivalentClasses,
11            Self::DisjointClasses { .. } => AxiomKind::DisjointClasses,
12            Self::DisjointUnion { .. } => AxiomKind::DisjointUnion,
13            Self::SubObjectPropertyOf { .. } => AxiomKind::SubObjectPropertyOf,
14            Self::FunctionalObjectProperty { .. } => AxiomKind::FunctionalObjectProperty,
15            Self::InverseFunctionalObjectProperty { .. } => {
16                AxiomKind::InverseFunctionalObjectProperty
17            }
18            Self::ReflexiveObjectProperty { .. } => AxiomKind::ReflexiveObjectProperty,
19            Self::IrreflexiveObjectProperty { .. } => AxiomKind::IrreflexiveObjectProperty,
20            Self::SymmetricObjectProperty { .. } => AxiomKind::SymmetricObjectProperty,
21            Self::AsymmetricObjectProperty { .. } => AxiomKind::AsymmetricObjectProperty,
22            Self::TransitiveObjectProperty { .. } => AxiomKind::TransitiveObjectProperty,
23            Self::EquivalentObjectProperties { .. } => AxiomKind::EquivalentObjectProperties,
24            Self::DisjointObjectProperties { .. } => AxiomKind::DisjointObjectProperties,
25            Self::InverseObjectProperties { .. } => AxiomKind::InverseObjectProperties,
26            Self::ObjectPropertyDomain { .. } => AxiomKind::ObjectPropertyDomain,
27            Self::ObjectPropertyRange { .. } => AxiomKind::ObjectPropertyRange,
28            Self::SubDataPropertyOf { .. } => AxiomKind::SubDataPropertyOf,
29            Self::EquivalentDataProperties { .. } => AxiomKind::EquivalentDataProperties,
30            Self::DisjointDataProperties { .. } => AxiomKind::DisjointDataProperties,
31            Self::DataPropertyDomain { .. } => AxiomKind::DataPropertyDomain,
32            Self::DataPropertyRange { .. } => AxiomKind::DataPropertyRange,
33            Self::FunctionalDataProperty { .. } => AxiomKind::FunctionalDataProperty,
34            Self::DatatypeDefinition { .. } => AxiomKind::DatatypeDefinition,
35            Self::HasKey { .. } => AxiomKind::HasKey,
36            Self::SameIndividual { .. } => AxiomKind::SameIndividual,
37            Self::DifferentIndividuals { .. } => AxiomKind::DifferentIndividuals,
38            Self::ClassAssertion { .. } => AxiomKind::ClassAssertion,
39            Self::ObjectPropertyAssertion { .. } => AxiomKind::ObjectPropertyAssertion,
40            Self::NegativeObjectPropertyAssertion { .. } => {
41                AxiomKind::NegativeObjectPropertyAssertion
42            }
43            Self::DataPropertyAssertion { .. } => AxiomKind::DataPropertyAssertion,
44            Self::NegativeDataPropertyAssertion { .. } => AxiomKind::NegativeDataPropertyAssertion,
45            Self::AnnotationAssertion { .. } => AxiomKind::AnnotationAssertion,
46            Self::SubAnnotationPropertyOf { .. } => AxiomKind::SubAnnotationPropertyOf,
47            Self::AnnotationPropertyDomain { .. } => AxiomKind::AnnotationPropertyDomain,
48            Self::AnnotationPropertyRange { .. } => AxiomKind::AnnotationPropertyRange,
49        }
50    }
51    /// Return axiom annotations.
52    #[must_use]
53    pub fn annotations(&self) -> &AxiomAnnotations<L, B> {
54        match self {
55            Self::Declaration { annotations, .. }
56            | Self::SubClassOf { annotations, .. }
57            | Self::EquivalentClasses { annotations, .. }
58            | Self::DisjointClasses { annotations, .. }
59            | Self::DisjointUnion { annotations, .. }
60            | Self::SubObjectPropertyOf { annotations, .. }
61            | Self::FunctionalObjectProperty { annotations, .. }
62            | Self::InverseFunctionalObjectProperty { annotations, .. }
63            | Self::ReflexiveObjectProperty { annotations, .. }
64            | Self::IrreflexiveObjectProperty { annotations, .. }
65            | Self::SymmetricObjectProperty { annotations, .. }
66            | Self::AsymmetricObjectProperty { annotations, .. }
67            | Self::TransitiveObjectProperty { annotations, .. }
68            | Self::EquivalentObjectProperties { annotations, .. }
69            | Self::DisjointObjectProperties { annotations, .. }
70            | Self::InverseObjectProperties { annotations, .. }
71            | Self::ObjectPropertyDomain { annotations, .. }
72            | Self::ObjectPropertyRange { annotations, .. }
73            | Self::SubDataPropertyOf { annotations, .. }
74            | Self::EquivalentDataProperties { annotations, .. }
75            | Self::DisjointDataProperties { annotations, .. }
76            | Self::DataPropertyDomain { annotations, .. }
77            | Self::DataPropertyRange { annotations, .. }
78            | Self::FunctionalDataProperty { annotations, .. }
79            | Self::DatatypeDefinition { annotations, .. }
80            | Self::HasKey { annotations, .. }
81            | Self::SameIndividual { annotations, .. }
82            | Self::DifferentIndividuals { annotations, .. }
83            | Self::ClassAssertion { annotations, .. }
84            | Self::ObjectPropertyAssertion { annotations, .. }
85            | Self::NegativeObjectPropertyAssertion { annotations, .. }
86            | Self::DataPropertyAssertion { annotations, .. }
87            | Self::NegativeDataPropertyAssertion { annotations, .. }
88            | Self::AnnotationAssertion { annotations, .. }
89            | Self::SubAnnotationPropertyOf { annotations, .. }
90            | Self::AnnotationPropertyDomain { annotations, .. }
91            | Self::AnnotationPropertyRange { annotations, .. } => annotations,
92        }
93    }
94    /// Replace axiom annotations while preserving all logical operands.
95    #[must_use]
96    pub fn with_annotations(mut self, new_annotations: AxiomAnnotations<L, B>) -> Self {
97        match &mut self {
98            Self::Declaration { annotations, .. }
99            | Self::SubClassOf { annotations, .. }
100            | Self::EquivalentClasses { annotations, .. }
101            | Self::DisjointClasses { annotations, .. }
102            | Self::DisjointUnion { annotations, .. }
103            | Self::SubObjectPropertyOf { annotations, .. }
104            | Self::FunctionalObjectProperty { annotations, .. }
105            | Self::InverseFunctionalObjectProperty { annotations, .. }
106            | Self::ReflexiveObjectProperty { annotations, .. }
107            | Self::IrreflexiveObjectProperty { annotations, .. }
108            | Self::SymmetricObjectProperty { annotations, .. }
109            | Self::AsymmetricObjectProperty { annotations, .. }
110            | Self::TransitiveObjectProperty { annotations, .. }
111            | Self::EquivalentObjectProperties { annotations, .. }
112            | Self::DisjointObjectProperties { annotations, .. }
113            | Self::InverseObjectProperties { annotations, .. }
114            | Self::ObjectPropertyDomain { annotations, .. }
115            | Self::ObjectPropertyRange { annotations, .. }
116            | Self::SubDataPropertyOf { annotations, .. }
117            | Self::EquivalentDataProperties { annotations, .. }
118            | Self::DisjointDataProperties { annotations, .. }
119            | Self::DataPropertyDomain { annotations, .. }
120            | Self::DataPropertyRange { annotations, .. }
121            | Self::FunctionalDataProperty { annotations, .. }
122            | Self::DatatypeDefinition { annotations, .. }
123            | Self::HasKey { annotations, .. }
124            | Self::SameIndividual { annotations, .. }
125            | Self::DifferentIndividuals { annotations, .. }
126            | Self::ClassAssertion { annotations, .. }
127            | Self::ObjectPropertyAssertion { annotations, .. }
128            | Self::NegativeObjectPropertyAssertion { annotations, .. }
129            | Self::DataPropertyAssertion { annotations, .. }
130            | Self::NegativeDataPropertyAssertion { annotations, .. }
131            | Self::AnnotationAssertion { annotations, .. }
132            | Self::SubAnnotationPropertyOf { annotations, .. }
133            | Self::AnnotationPropertyDomain { annotations, .. }
134            | Self::AnnotationPropertyRange { annotations, .. } => *annotations = new_annotations,
135        }
136        self
137    }
138}