Skip to main content

owl_structural_model/
assertion.rs

1//! Checked construction for assertion families.
2use crate::{
3    Axiom, AxiomAnnotations, ClassExpression, Individual, ObjectPropertyExpression, OperandSet,
4    StructuralModelError,
5};
6use iri_rfc3987::Iri;
7impl<L, B> Axiom<L, B> {
8    /// Construct `SameIndividual` without axiom annotations.
9    /// # Errors
10    /// Rejects fewer than the structural minimum number of source occurrences.
11    pub fn same_individual(individuals: Vec<Individual<B>>) -> Result<Self, StructuralModelError> {
12        Ok(Self::SameIndividual {
13            individuals: OperandSet::try_new(individuals)?,
14            annotations: AxiomAnnotations::empty(),
15        })
16    }
17    /// Construct `DifferentIndividuals` without axiom annotations.
18    /// # Errors
19    /// Rejects fewer than the structural minimum number of source occurrences.
20    pub fn different_individuals(
21        individuals: Vec<Individual<B>>,
22    ) -> Result<Self, StructuralModelError> {
23        Ok(Self::DifferentIndividuals {
24            individuals: OperandSet::try_new(individuals)?,
25            annotations: AxiomAnnotations::empty(),
26        })
27    }
28    /// Construct `ClassAssertion` without axiom annotations.
29    #[must_use]
30    pub fn class_assertion(class: ClassExpression<L, B>, individual: Individual<B>) -> Self {
31        Self::ClassAssertion {
32            class,
33            individual,
34            annotations: AxiomAnnotations::empty(),
35        }
36    }
37    /// Construct `ObjectPropertyAssertion` without axiom annotations.
38    #[must_use]
39    pub fn object_property_assertion(
40        property: ObjectPropertyExpression,
41        source: Individual<B>,
42        target: Individual<B>,
43    ) -> Self {
44        Self::ObjectPropertyAssertion {
45            property,
46            source,
47            target,
48            annotations: AxiomAnnotations::empty(),
49        }
50    }
51    /// Construct `NegativeObjectPropertyAssertion` without axiom annotations.
52    #[must_use]
53    pub fn negative_object_property_assertion(
54        property: ObjectPropertyExpression,
55        source: Individual<B>,
56        target: Individual<B>,
57    ) -> Self {
58        Self::NegativeObjectPropertyAssertion {
59            property,
60            source,
61            target,
62            annotations: AxiomAnnotations::empty(),
63        }
64    }
65    /// Construct `DataPropertyAssertion` without axiom annotations.
66    #[must_use]
67    pub fn data_property_assertion(property: Iri<String>, source: Individual<B>, value: L) -> Self {
68        Self::DataPropertyAssertion {
69            property,
70            source,
71            value,
72            annotations: AxiomAnnotations::empty(),
73        }
74    }
75    /// Construct `NegativeDataPropertyAssertion` without axiom annotations.
76    #[must_use]
77    pub fn negative_data_property_assertion(
78        property: Iri<String>,
79        source: Individual<B>,
80        value: L,
81    ) -> Self {
82        Self::NegativeDataPropertyAssertion {
83            property,
84            source,
85            value,
86            annotations: AxiomAnnotations::empty(),
87        }
88    }
89}