14
14
15
15
package com .github .owlcs .ontapi .internal ;
16
16
17
- import org .apache .jena .util .iterator .ExtendedIterator ;
18
- import org .semanticweb .owlapi .model .*;
19
17
import com .github .owlcs .ontapi .OntApiException ;
20
18
import com .github .owlcs .ontapi .jena .model .OntGraphModel ;
21
19
import com .github .owlcs .ontapi .jena .utils .Iter ;
20
+ import org .apache .jena .util .iterator .ExtendedIterator ;
21
+ import org .semanticweb .owlapi .model .*;
22
22
23
23
import java .util .*;
24
24
import java .util .function .Supplier ;
@@ -62,48 +62,48 @@ void write(OntGraphModel m, OWLObject v) {
62
62
},
63
63
// axioms:
64
64
DECLARATION (AxiomType .DECLARATION , true , ENTITY ),
65
- EQUIVALENT_CLASSES (AxiomType .EQUIVALENT_CLASSES , false , CLASS_EXPRESSION ),
66
- SUBCLASS_OF (AxiomType .SUBCLASS_OF , false , CLASS_EXPRESSION ),
67
- DISJOINT_CLASSES (AxiomType .DISJOINT_CLASSES , false , CLASS_EXPRESSION ),
68
- DISJOINT_UNION (AxiomType .DISJOINT_UNION , false , CLASS , CLASS_EXPRESSION ),
69
- CLASS_ASSERTION (AxiomType .CLASS_ASSERTION , true , INDIVIDUAL , CLASS_EXPRESSION ),
70
- SAME_INDIVIDUAL (AxiomType .SAME_INDIVIDUAL , false , INDIVIDUAL ),
71
- DIFFERENT_INDIVIDUALS (AxiomType .DIFFERENT_INDIVIDUALS , false , INDIVIDUAL ),
65
+ EQUIVALENT_CLASSES (AxiomType .EQUIVALENT_CLASSES , CLASS_EXPRESSION ),
66
+ SUBCLASS_OF (AxiomType .SUBCLASS_OF , CLASS_EXPRESSION ),
67
+ DISJOINT_CLASSES (AxiomType .DISJOINT_CLASSES , CLASS_EXPRESSION ),
68
+ DISJOINT_UNION (AxiomType .DISJOINT_UNION , CLASS , CLASS_EXPRESSION ),
69
+ CLASS_ASSERTION (AxiomType .CLASS_ASSERTION , INDIVIDUAL , CLASS_EXPRESSION ),
70
+ SAME_INDIVIDUAL (AxiomType .SAME_INDIVIDUAL , INDIVIDUAL ),
71
+ DIFFERENT_INDIVIDUALS (AxiomType .DIFFERENT_INDIVIDUALS , INDIVIDUAL ),
72
72
OBJECT_PROPERTY_ASSERTION (AxiomType .OBJECT_PROPERTY_ASSERTION , true , NAMED_OBJECT_PROPERTY , INDIVIDUAL ),
73
- NEGATIVE_OBJECT_PROPERTY_ASSERTION (AxiomType .NEGATIVE_OBJECT_PROPERTY_ASSERTION , false , OBJECT_PROPERTY_EXPRESSION , INDIVIDUAL ),
73
+ NEGATIVE_OBJECT_PROPERTY_ASSERTION (AxiomType .NEGATIVE_OBJECT_PROPERTY_ASSERTION , OBJECT_PROPERTY_EXPRESSION , INDIVIDUAL ),
74
74
DATA_PROPERTY_ASSERTION (AxiomType .DATA_PROPERTY_ASSERTION , true , DATATYPE_PROPERTY , LITERAL , INDIVIDUAL ),
75
- NEGATIVE_DATA_PROPERTY_ASSERTION (AxiomType .NEGATIVE_DATA_PROPERTY_ASSERTION , false , DATATYPE_PROPERTY , INDIVIDUAL , LITERAL ),
76
- EQUIVALENT_OBJECT_PROPERTIES (AxiomType .EQUIVALENT_OBJECT_PROPERTIES , false , OBJECT_PROPERTY_EXPRESSION ),
77
- SUB_OBJECT_PROPERTY (AxiomType .SUB_OBJECT_PROPERTY , false , OBJECT_PROPERTY_EXPRESSION ),
78
- INVERSE_OBJECT_PROPERTIES (AxiomType .INVERSE_OBJECT_PROPERTIES , false , OBJECT_PROPERTY_EXPRESSION ),
79
- FUNCTIONAL_OBJECT_PROPERTY (AxiomType .FUNCTIONAL_OBJECT_PROPERTY , true , OBJECT_PROPERTY_EXPRESSION ),
80
- INVERSE_FUNCTIONAL_OBJECT_PROPERTY (AxiomType .INVERSE_FUNCTIONAL_OBJECT_PROPERTY , true , OBJECT_PROPERTY_EXPRESSION ),
81
- SYMMETRIC_OBJECT_PROPERTY (AxiomType .SYMMETRIC_OBJECT_PROPERTY , true , OBJECT_PROPERTY_EXPRESSION ),
82
- ASYMMETRIC_OBJECT_PROPERTY (AxiomType .ASYMMETRIC_OBJECT_PROPERTY , true , OBJECT_PROPERTY_EXPRESSION ),
83
- TRANSITIVE_OBJECT_PROPERTY (AxiomType .TRANSITIVE_OBJECT_PROPERTY , true , OBJECT_PROPERTY_EXPRESSION ),
84
- REFLEXIVE_OBJECT_PROPERTY (AxiomType .REFLEXIVE_OBJECT_PROPERTY , true , OBJECT_PROPERTY_EXPRESSION ),
85
- IRREFLEXIVE_OBJECT_PROPERTY (AxiomType .IRREFLEXIVE_OBJECT_PROPERTY , true , OBJECT_PROPERTY_EXPRESSION ),
86
- OBJECT_PROPERTY_DOMAIN (AxiomType .OBJECT_PROPERTY_DOMAIN , true , OBJECT_PROPERTY_EXPRESSION , CLASS_EXPRESSION ),
87
- OBJECT_PROPERTY_RANGE (AxiomType .OBJECT_PROPERTY_RANGE , true , OBJECT_PROPERTY_EXPRESSION , CLASS_EXPRESSION ),
88
- DISJOINT_OBJECT_PROPERTIES (AxiomType .DISJOINT_OBJECT_PROPERTIES , false , OBJECT_PROPERTY_EXPRESSION ),
89
- SUB_PROPERTY_CHAIN_OF (AxiomType .SUB_PROPERTY_CHAIN_OF , false , OBJECT_PROPERTY_EXPRESSION ),
90
- EQUIVALENT_DATA_PROPERTIES (AxiomType .EQUIVALENT_DATA_PROPERTIES , false , DATATYPE_PROPERTY ),
75
+ NEGATIVE_DATA_PROPERTY_ASSERTION (AxiomType .NEGATIVE_DATA_PROPERTY_ASSERTION , DATATYPE_PROPERTY , INDIVIDUAL , LITERAL ),
76
+ EQUIVALENT_OBJECT_PROPERTIES (AxiomType .EQUIVALENT_OBJECT_PROPERTIES , OBJECT_PROPERTY_EXPRESSION ),
77
+ SUB_OBJECT_PROPERTY (AxiomType .SUB_OBJECT_PROPERTY , OBJECT_PROPERTY_EXPRESSION ),
78
+ INVERSE_OBJECT_PROPERTIES (AxiomType .INVERSE_OBJECT_PROPERTIES , OBJECT_PROPERTY_EXPRESSION ),
79
+ FUNCTIONAL_OBJECT_PROPERTY (AxiomType .FUNCTIONAL_OBJECT_PROPERTY , OBJECT_PROPERTY_EXPRESSION ),
80
+ INVERSE_FUNCTIONAL_OBJECT_PROPERTY (AxiomType .INVERSE_FUNCTIONAL_OBJECT_PROPERTY , OBJECT_PROPERTY_EXPRESSION ),
81
+ SYMMETRIC_OBJECT_PROPERTY (AxiomType .SYMMETRIC_OBJECT_PROPERTY , OBJECT_PROPERTY_EXPRESSION ),
82
+ ASYMMETRIC_OBJECT_PROPERTY (AxiomType .ASYMMETRIC_OBJECT_PROPERTY , OBJECT_PROPERTY_EXPRESSION ),
83
+ TRANSITIVE_OBJECT_PROPERTY (AxiomType .TRANSITIVE_OBJECT_PROPERTY , OBJECT_PROPERTY_EXPRESSION ),
84
+ REFLEXIVE_OBJECT_PROPERTY (AxiomType .REFLEXIVE_OBJECT_PROPERTY , OBJECT_PROPERTY_EXPRESSION ),
85
+ IRREFLEXIVE_OBJECT_PROPERTY (AxiomType .IRREFLEXIVE_OBJECT_PROPERTY , OBJECT_PROPERTY_EXPRESSION ),
86
+ OBJECT_PROPERTY_DOMAIN (AxiomType .OBJECT_PROPERTY_DOMAIN , OBJECT_PROPERTY_EXPRESSION , CLASS_EXPRESSION ),
87
+ OBJECT_PROPERTY_RANGE (AxiomType .OBJECT_PROPERTY_RANGE , OBJECT_PROPERTY_EXPRESSION , CLASS_EXPRESSION ),
88
+ DISJOINT_OBJECT_PROPERTIES (AxiomType .DISJOINT_OBJECT_PROPERTIES , OBJECT_PROPERTY_EXPRESSION ),
89
+ SUB_PROPERTY_CHAIN_OF (AxiomType .SUB_PROPERTY_CHAIN_OF , OBJECT_PROPERTY_EXPRESSION ),
90
+ EQUIVALENT_DATA_PROPERTIES (AxiomType .EQUIVALENT_DATA_PROPERTIES , DATATYPE_PROPERTY ),
91
91
SUB_DATA_PROPERTY (AxiomType .SUB_DATA_PROPERTY , true , DATATYPE_PROPERTY ),
92
92
FUNCTIONAL_DATA_PROPERTY (AxiomType .FUNCTIONAL_DATA_PROPERTY , true , DATATYPE_PROPERTY ),
93
- DATA_PROPERTY_DOMAIN (AxiomType .DATA_PROPERTY_DOMAIN , true , DATATYPE_PROPERTY , CLASS_EXPRESSION ),
94
- DATA_PROPERTY_RANGE (AxiomType .DATA_PROPERTY_RANGE , true , DATATYPE_PROPERTY , DATA_RANGE ),
95
- DISJOINT_DATA_PROPERTIES (AxiomType .DISJOINT_DATA_PROPERTIES , false , DATATYPE_PROPERTY ),
96
- HAS_KEY (AxiomType .HAS_KEY , false , CLASS_EXPRESSION , DATATYPE_PROPERTY , OBJECT_PROPERTY_EXPRESSION ),
97
- SWRL_RULE (AxiomType .SWRL_RULE , false , SWRL_ATOM ),
93
+ DATA_PROPERTY_DOMAIN (AxiomType .DATA_PROPERTY_DOMAIN , DATATYPE_PROPERTY , CLASS_EXPRESSION ),
94
+ DATA_PROPERTY_RANGE (AxiomType .DATA_PROPERTY_RANGE , DATATYPE_PROPERTY , DATA_RANGE ),
95
+ DISJOINT_DATA_PROPERTIES (AxiomType .DISJOINT_DATA_PROPERTIES , DATATYPE_PROPERTY ),
96
+ HAS_KEY (AxiomType .HAS_KEY , CLASS_EXPRESSION , DATATYPE_PROPERTY , OBJECT_PROPERTY_EXPRESSION ),
97
+ SWRL_RULE (AxiomType .SWRL_RULE , SWRL_ATOM ),
98
98
ANNOTATION_ASSERTION (AxiomType .ANNOTATION_ASSERTION , true , ANNOTATION_PROPERTY , LITERAL , ANONYMOUS_INDIVIDUAL , IRI ),
99
99
SUB_ANNOTATION_PROPERTY_OF (AxiomType .SUB_ANNOTATION_PROPERTY_OF , true , ANNOTATION_PROPERTY ),
100
100
ANNOTATION_PROPERTY_RANGE (AxiomType .ANNOTATION_PROPERTY_RANGE , true , ANNOTATION_PROPERTY , IRI ),
101
101
ANNOTATION_PROPERTY_DOMAIN (AxiomType .ANNOTATION_PROPERTY_DOMAIN , true , ANNOTATION_PROPERTY , IRI ),
102
- DATATYPE_DEFINITION (AxiomType .DATATYPE_DEFINITION , true , DATATYPE , DATA_RANGE ),
102
+ DATATYPE_DEFINITION (AxiomType .DATATYPE_DEFINITION , DATATYPE , DATA_RANGE ),
103
103
;
104
104
105
- private static final Set <OWLContentType > AXIOMS ;
106
- private static final Set <OWLContentType > LOGICAL ;
105
+ private static final Set <OWLContentType > ALL_AXIOMS ;
106
+ private static final Set <OWLContentType > LOGICAL_AXIOMS ;
107
107
108
108
static {
109
109
Set <OWLContentType > axioms = EnumSet .noneOf (OWLContentType .class );
@@ -116,14 +116,23 @@ void write(OntGraphModel m, OWLObject v) {
116
116
logical .add (x );
117
117
}
118
118
}
119
- AXIOMS = axioms ;
120
- LOGICAL = logical ;
119
+ ALL_AXIOMS = axioms ;
120
+ LOGICAL_AXIOMS = logical ;
121
121
}
122
122
123
123
private final AxiomType <OWLAxiom > type ;
124
124
private final boolean distinct ;
125
125
private final Set <OWLComponentType > components ;
126
126
127
+ OWLContentType (AxiomType <? extends OWLAxiom > type , OWLComponentType ... types ) {
128
+ this (type , false , types );
129
+ }
130
+
131
+ /**
132
+ * @param type {@link AxiomType} or {@code null} if ontology header
133
+ * @param distinct see {@link #isDistinct()}
134
+ * @param types an {@code Array} of top-level components
135
+ */
127
136
@ SuppressWarnings ("unchecked" )
128
137
OWLContentType (AxiomType <? extends OWLAxiom > type , boolean distinct , OWLComponentType ... types ) {
129
138
this .type = (AxiomType <OWLAxiom >) type ;
@@ -181,7 +190,7 @@ static ExtendedIterator<OWLContentType> listAll() {
181
190
* @return {@code Stream} of {@link OWLContentType}s
182
191
*/
183
192
public static Stream <OWLContentType > axioms () {
184
- return AXIOMS .stream ();
193
+ return ALL_AXIOMS .stream ();
185
194
}
186
195
187
196
/**
@@ -190,7 +199,7 @@ public static Stream<OWLContentType> axioms() {
190
199
* @return {@code Stream} of {@link OWLContentType}s
191
200
*/
192
201
public static Stream <OWLContentType > logical () {
193
- return LOGICAL .stream ();
202
+ return LOGICAL_AXIOMS .stream ();
194
203
}
195
204
196
205
/**
@@ -231,12 +240,13 @@ boolean hasAnnotations(OWLObject container) {
231
240
}
232
241
233
242
/**
234
- * Answers {@code true} if and only if
235
- * there can be only one unique content object of this enum-type,
236
- * which means that there is only one statement in the graph, to which that object corresponds.
237
- * Returns {@code false}, if an object of the enum-type can be derived from different RDF statements.
238
- * <p>
239
- * Several examples when the method returns {@code false}:
243
+ * Answers {@code true} iff
244
+ * an object of this type can be derived from one and only one main triple,
245
+ * and returns {@code false}, if several main triples can correspond to the same object.
246
+ * Usually the method returns {@code false}, only few types allow mapping to be distinct.
247
+ * An example of distinct type is {@link #DECLARATION}:
248
+ * any triple {@code x rdf:type y} uniquely corresponds to the entity {@code x} of the type {@code y}.
249
+ * Below are examples of non-distinct types:
240
250
* <ul>
241
251
* <li>{@link #DIFFERENT_INDIVIDUALS}: the same axiom {@code DifferentIndividuals(<A> <B>)} can be derived
242
252
* form three statements: {@code a1 owl:differentFrom a2}, {@code a2 owl:differentFrom a1}
@@ -246,6 +256,9 @@ boolean hasAnnotations(OWLObject container) {
246
256
* {@code C1 owl:disjointUnionOf ( C2 ) . C1 owl:disjointUnionOf ( C2 ) . }</li>
247
257
* <li>{@link #ANNOTATION}: bulk annotation is a b-node, RDF graph can contain any number of b-nodes
248
258
* with the same content (annotation property and annotation value)</li>
259
+ * <li>{@link #FUNCTIONAL_OBJECT_PROPERTY}:
260
+ * the axiom {@code FunctionalObjectProperty(ObjectInverseOf(P))} can be derived from
261
+ * the any statements of the form {@code _:bi rdf:type owl:FunctionalProperty . _:bi owl:inverseOf P .}</li>
249
262
* </ul>
250
263
*
251
264
* @return boolean
0 commit comments