use crate::{
ClassExpression, Individual, OWL_NOTHING, OWL_THING, ObjectPropertyExpression, OperandSet,
StructuralModelError,
};
use iri_rfc3987::Iri;
impl<L, B> ClassExpression<L, B> {
#[must_use]
pub fn named(iri: Iri<String>) -> Self {
Self::Named(iri)
}
#[must_use]
pub fn thing() -> Self {
Self::named(Self::builtin(OWL_THING))
}
#[must_use]
pub fn nothing() -> Self {
Self::named(Self::builtin(OWL_NOTHING))
}
#[must_use]
pub fn is_thing(&self) -> bool {
matches!(self, Self::Named(iri) if iri.as_str() == OWL_THING)
}
#[must_use]
pub fn is_nothing(&self) -> bool {
matches!(self, Self::Named(iri) if iri.as_str() == OWL_NOTHING)
}
pub(crate) fn builtin(value: &'static str) -> Iri<String> {
Iri::parse(value)
.expect("built-in OWL/RDF IRI is valid")
.into()
}
pub fn object_intersection_of(operands: Vec<Self>) -> Result<Self, StructuralModelError> {
Ok(Self::ObjectIntersectionOf(OperandSet::try_new(operands)?))
}
pub fn object_union_of(operands: Vec<Self>) -> Result<Self, StructuralModelError> {
Ok(Self::ObjectUnionOf(OperandSet::try_new(operands)?))
}
#[must_use]
pub fn object_complement_of(operand: Self) -> Self {
Self::ObjectComplementOf(Box::new(operand))
}
pub fn object_one_of(individuals: Vec<Individual<B>>) -> Result<Self, StructuralModelError> {
Ok(Self::ObjectOneOf(OperandSet::try_new(individuals)?))
}
#[must_use]
pub fn object_some_values_from(property: ObjectPropertyExpression, filler: Self) -> Self {
Self::ObjectSomeValuesFrom {
property,
filler: Box::new(filler),
}
}
#[must_use]
pub fn object_all_values_from(property: ObjectPropertyExpression, filler: Self) -> Self {
Self::ObjectAllValuesFrom {
property,
filler: Box::new(filler),
}
}
#[must_use]
pub fn object_has_value(property: ObjectPropertyExpression, individual: Individual<B>) -> Self {
Self::ObjectHasValue {
property,
individual,
}
}
#[must_use]
pub fn object_has_self(property: ObjectPropertyExpression) -> Self {
Self::ObjectHasSelf { property }
}
}