Skip to content

Commit f2b7cdd

Browse files
committed
ont-api: add OWLDisjointObjectPropertiesAxiom model-implementation (issue #2) + add and change tests
1 parent 961257a commit f2b7cdd

File tree

8 files changed

+464
-81
lines changed

8 files changed

+464
-81
lines changed

src/main/java/com/github/owlcs/ontapi/internal/OWLComponentType.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ public static OWLComponentType get(OWLObject o) {
421421
* Lists non-primitive components that can be shared.
422422
*
423423
* @return {@code Stream} of {@link OWLContentType}s
424-
* @see InternalModel#getUsedComponentTriples(OntGraphModel, OWLObject)
424+
* @see InternalModel#getUsedTriples(OntGraphModel, OWLObject)
425425
*/
426426
static Stream<OWLComponentType> sharedComponents() {
427427
return COMPLEX_COMPONENTS.stream();

src/main/java/com/github/owlcs/ontapi/internal/axioms/AbstractNaryTranslator.java

+86-5
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,6 @@ public final Collection<A> splitToAnnotatedPairs() {
199199
return walkPairwise((a, b) -> createAxiom(a, b, annotations));
200200
}
201201

202-
@Override
203-
public final boolean canContainAnnotationProperties() {
204-
return isAnnotated();
205-
}
206-
207202
/**
208203
* Answers {@code true} if the given axiom has mirror triple.
209204
*
@@ -245,6 +240,11 @@ boolean testSameContent(ONTStatementImpl other) {
245240
protected <T> Stream<T> fromPairs(OWLPairwiseVisitor<T, M> visitor) {
246241
return OWLAPIStreamUtils.allPairs(operands()).map(v -> visitor.visit(v.i, v.j)).filter(Objects::nonNull);
247242
}
243+
244+
@Override
245+
public final boolean canContainAnnotationProperties() {
246+
return isAnnotated();
247+
}
248248
}
249249

250250
/**
@@ -357,6 +357,37 @@ public Object toContentItem(ONTObject x) {
357357
}
358358
}
359359

360+
/**
361+
* An abstract {@link OWLNaryPropertyAxiom} implementation for member-type {@link OWLObjectPropertyExpression}.
362+
*
363+
* @param <A> either {@link OWLEquivalentObjectPropertiesAxiom} or {@link OWLDisjointObjectPropertiesAxiom}
364+
*/
365+
@SuppressWarnings("WeakerAccess")
366+
protected abstract static class ObjectPropertyNaryAxiomImpl<A extends OWLNaryPropertyAxiom<OWLObjectPropertyExpression>>
367+
extends PropertyNaryAxiomImpl<A, OWLObjectPropertyExpression> {
368+
369+
protected ObjectPropertyNaryAxiomImpl(Object subject, String predicate, Object object, Supplier<OntGraphModel> m) {
370+
super(subject, predicate, object, m);
371+
}
372+
373+
@Override
374+
public ExtendedIterator<ONTObject<? extends OWLObjectPropertyExpression>> listONTComponents(OntStatement statement,
375+
InternalObjectFactory factory) {
376+
return Iter.of(factory.getProperty(statement.getSubject(OntOPE.class)),
377+
factory.getProperty(statement.getObject(OntOPE.class)));
378+
}
379+
380+
@Override
381+
public ONTObject<? extends OWLObjectPropertyExpression> findByURI(String uri, InternalObjectFactory factory) {
382+
return ONTObjectPropertyImpl.find(uri, factory, model);
383+
}
384+
385+
@Override
386+
public final boolean canContainDataProperties() {
387+
return false;
388+
}
389+
}
390+
360391
/**
361392
* An abstraction, that combines common properties for {@link OWLNaryIndividualAxiom} and {@link OWLNaryClassAxiom}.
362393
*
@@ -386,4 +417,54 @@ public Collection<OWLSubClassOfAxiom> asOWLSubClassOfAxioms() {
386417
return walkAllPairwise((a, b) -> createSubClassOf(eraseModel(a), eraseModel(b)));
387418
}
388419
}
420+
421+
/**
422+
* An abstract {@link OWLNaryPropertyAxiom} implementation.
423+
*
424+
* @param <A> subtype of {@link OWLNaryPropertyAxiom}
425+
* @param <P> subtype of {@link OWLPropertyExpression}
426+
*/
427+
abstract static class PropertyNaryAxiomImpl<A extends OWLNaryPropertyAxiom<P>, P extends OWLPropertyExpression>
428+
extends NaryAxiomImpl<A, P> implements OWLNaryPropertyAxiom<P> {
429+
430+
PropertyNaryAxiomImpl(Object subject, String predicate, Object object, Supplier<OntGraphModel> m) {
431+
super(subject, predicate, object, m);
432+
}
433+
434+
@Override
435+
public Stream<P> properties() {
436+
return sorted().map(ONTObject::getOWLObject);
437+
}
438+
439+
@SuppressWarnings({"unchecked", "NullableProblems"})
440+
@Override
441+
public Set<P> getPropertiesMinus(P property) {
442+
return getSetMinus(property);
443+
}
444+
445+
@Override
446+
public final boolean canContainNamedClasses() {
447+
return false;
448+
}
449+
450+
@Override
451+
public final boolean canContainClassExpressions() {
452+
return false;
453+
}
454+
455+
@Override
456+
public final boolean canContainNamedIndividuals() {
457+
return false;
458+
}
459+
460+
@Override
461+
public final boolean canContainDatatypes() {
462+
return isAnnotated();
463+
}
464+
465+
@Override
466+
public final boolean canContainAnonymousIndividuals() {
467+
return isAnnotated();
468+
}
469+
}
389470
}

0 commit comments

Comments
 (0)