Skip to main content

owl_structural_model/
data_axiom.rs

1//! Checked construction for data axiom families.
2use crate::{
3    Axiom, AxiomAnnotations, ClassExpression, DataRange, KeyProperties, OperandSet,
4    StructuralModelError,
5};
6use iri_rfc3987::Iri;
7impl<L, B> Axiom<L, B> {
8    /// Construct `SubDataPropertyOf` without axiom annotations.
9    #[must_use]
10    pub fn sub_data_property_of(sub_property: Iri<String>, super_property: Iri<String>) -> Self {
11        Self::SubDataPropertyOf {
12            sub_property,
13            super_property,
14            annotations: AxiomAnnotations::empty(),
15        }
16    }
17    /// Construct `EquivalentDataProperties` without axiom annotations.
18    /// # Errors
19    /// Rejects fewer than the structural minimum number of source occurrences.
20    pub fn equivalent_data_properties(
21        properties: Vec<Iri<String>>,
22    ) -> Result<Self, StructuralModelError> {
23        Ok(Self::EquivalentDataProperties {
24            properties: OperandSet::try_new(properties)?,
25            annotations: AxiomAnnotations::empty(),
26        })
27    }
28    /// Construct `DisjointDataProperties` without axiom annotations.
29    /// # Errors
30    /// Rejects fewer than the structural minimum number of source occurrences.
31    pub fn disjoint_data_properties(
32        properties: Vec<Iri<String>>,
33    ) -> Result<Self, StructuralModelError> {
34        Ok(Self::DisjointDataProperties {
35            properties: OperandSet::try_new(properties)?,
36            annotations: AxiomAnnotations::empty(),
37        })
38    }
39    /// Construct `DataPropertyDomain` without axiom annotations.
40    #[must_use]
41    pub fn data_property_domain(property: Iri<String>, domain: ClassExpression<L, B>) -> Self {
42        Self::DataPropertyDomain {
43            property,
44            domain,
45            annotations: AxiomAnnotations::empty(),
46        }
47    }
48    /// Construct `DataPropertyRange` without axiom annotations.
49    #[must_use]
50    pub fn data_property_range(property: Iri<String>, range: DataRange<L>) -> Self {
51        Self::DataPropertyRange {
52            property,
53            range,
54            annotations: AxiomAnnotations::empty(),
55        }
56    }
57    /// Construct `FunctionalDataProperty` without axiom annotations.
58    #[must_use]
59    pub fn functional_data_property(property: Iri<String>) -> Self {
60        Self::FunctionalDataProperty {
61            property,
62            annotations: AxiomAnnotations::empty(),
63        }
64    }
65    /// Construct `DatatypeDefinition` without axiom annotations.
66    #[must_use]
67    pub fn datatype_definition(datatype: Iri<String>, range: DataRange<L>) -> Self {
68        Self::DatatypeDefinition {
69            datatype,
70            range,
71            annotations: AxiomAnnotations::empty(),
72        }
73    }
74    /// Construct `HasKey` without axiom annotations.
75    #[must_use]
76    pub fn has_key(class: ClassExpression<L, B>, properties: KeyProperties) -> Self {
77        Self::HasKey {
78            class,
79            properties,
80            annotations: AxiomAnnotations::empty(),
81        }
82    }
83}