1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
use super::Context;
use crate::{
syntax::{Container, Term, Type},
Direction, Id, Nullable,
};
use iref::{Iri, IriBuf};
use langtag::LanguageTagBuf;
#[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<LanguageTagBuf>>,
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> {}