use super::Context;
use crate::{
lang::LenientLanguageTagBuf,
syntax::{Container, Term, Type},
Direction, Id, Nullable,
};
use iref::{Iri, IriBuf};
#[derive(Clone)]
pub struct TermDefinition<T: Id, C: Context<T>> {
pub value: Option<Term<T>>,
pub prefix: bool,
pub protected: bool,
pub reverse_property: bool,
pub base_url: Option<IriBuf>,
pub context: Option<C::LocalContext>,
pub container: Container,
pub direction: Option<Nullable<Direction>>,
pub index: Option<String>,
pub language: Option<Nullable<LenientLanguageTagBuf>>,
pub nest: Option<String>,
pub typ: Option<Type<T>>,
}
impl<T: Id, C: Context<T>> TermDefinition<T, C> {
pub fn base_url(&self) -> Option<Iri> {
self.base_url.as_ref().map(|iri| iri.as_iri())
}
}
impl<T: Id, C: Context<T>> Default for TermDefinition<T, C> {
fn default() -> TermDefinition<T, C> {
TermDefinition {
value: None,
prefix: false,
protected: false,
reverse_property: false,
base_url: None,
typ: None,
language: None,
direction: None,
context: None,
nest: None,
index: None,
container: Container::new(),
}
}
}
impl<T: Id, C: Context<T>> PartialEq for TermDefinition<T, C> {
fn eq(&self, other: &TermDefinition<T, C>) -> bool {
self.prefix == other.prefix
&& self.reverse_property == other.reverse_property
&& self.language == other.language
&& self.direction == other.direction
&& self.nest == other.nest
&& self.index == other.index
&& self.container == other.container
&& self.base_url == other.base_url
&& self.value == other.value
&& self.typ == other.typ
&& self.context == other.context
}
}
impl<T: Id, C: Context<T>> Eq for TermDefinition<T, C> {}