owl_structural_model/
class_boolean.rs1use crate::{
3 ClassExpression, Individual, OWL_NOTHING, OWL_THING, ObjectPropertyExpression, OperandSet,
4 StructuralModelError,
5};
6use iri_rfc3987::Iri;
7
8impl<L, B> ClassExpression<L, B> {
9 #[must_use]
11 pub fn named(iri: Iri<String>) -> Self {
12 Self::Named(iri)
13 }
14 #[must_use]
16 pub fn thing() -> Self {
17 Self::named(Self::builtin(OWL_THING))
18 }
19 #[must_use]
21 pub fn nothing() -> Self {
22 Self::named(Self::builtin(OWL_NOTHING))
23 }
24 #[must_use]
26 pub fn is_thing(&self) -> bool {
27 matches!(self, Self::Named(iri) if iri.as_str() == OWL_THING)
28 }
29 #[must_use]
31 pub fn is_nothing(&self) -> bool {
32 matches!(self, Self::Named(iri) if iri.as_str() == OWL_NOTHING)
33 }
34 pub(crate) fn builtin(value: &'static str) -> Iri<String> {
35 Iri::parse(value)
36 .expect("built-in OWL/RDF IRI is valid")
37 .into()
38 }
39 pub fn object_intersection_of(operands: Vec<Self>) -> Result<Self, StructuralModelError> {
43 Ok(Self::ObjectIntersectionOf(OperandSet::try_new(operands)?))
44 }
45 pub fn object_union_of(operands: Vec<Self>) -> Result<Self, StructuralModelError> {
49 Ok(Self::ObjectUnionOf(OperandSet::try_new(operands)?))
50 }
51 #[must_use]
53 pub fn object_complement_of(operand: Self) -> Self {
54 Self::ObjectComplementOf(Box::new(operand))
55 }
56 pub fn object_one_of(individuals: Vec<Individual<B>>) -> Result<Self, StructuralModelError> {
60 Ok(Self::ObjectOneOf(OperandSet::try_new(individuals)?))
61 }
62 #[must_use]
64 pub fn object_some_values_from(property: ObjectPropertyExpression, filler: Self) -> Self {
65 Self::ObjectSomeValuesFrom {
66 property,
67 filler: Box::new(filler),
68 }
69 }
70 #[must_use]
72 pub fn object_all_values_from(property: ObjectPropertyExpression, filler: Self) -> Self {
73 Self::ObjectAllValuesFrom {
74 property,
75 filler: Box::new(filler),
76 }
77 }
78 #[must_use]
80 pub fn object_has_value(property: ObjectPropertyExpression, individual: Individual<B>) -> Self {
81 Self::ObjectHasValue {
82 property,
83 individual,
84 }
85 }
86 #[must_use]
88 pub fn object_has_self(property: ObjectPropertyExpression) -> Self {
89 Self::ObjectHasSelf { property }
90 }
91}