Skip to content

Package: OwlapiTypes

OwlapiTypes

nameinstructionbranchcomplexitylinemethod
OwlapiTypes(OwlapiAdapter, Procedure, Procedure)
M: 0 C: 12
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
addTypes(NamedResource, URI, Set)
M: 0 C: 18
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
ensureValidity(NamedResource, Set)
M: 0 C: 14
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
getTypes(NamedResource, Collection, boolean)
M: 0 C: 16
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
removeTypes(NamedResource, URI, Set)
M: 0 C: 18
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%

Coverage

1: /*
2: * JOPA
3: * Copyright (C) 2024 Czech Technical University in Prague
4: *
5: * This library is free software; you can redistribute it and/or
6: * modify it under the terms of the GNU Lesser General Public
7: * License as published by the Free Software Foundation; either
8: * version 3.0 of the License, or (at your option) any later version.
9: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library.
17: */
18: package cz.cvut.kbss.ontodriver.owlapi;
19:
20: import cz.cvut.kbss.ontodriver.Types;
21: import cz.cvut.kbss.ontodriver.exception.OntoDriverException;
22: import cz.cvut.kbss.ontodriver.model.Axiom;
23: import cz.cvut.kbss.ontodriver.model.NamedResource;
24: import cz.cvut.kbss.ontodriver.owlapi.exception.OwlapiDriverException;
25: import cz.cvut.kbss.ontodriver.owlapi.util.Procedure;
26:
27: import java.net.URI;
28: import java.util.Collection;
29: import java.util.Objects;
30: import java.util.Set;
31:
32: import static cz.cvut.kbss.ontodriver.util.ErrorUtils.getNPXMessageSupplier;
33:
34: public class OwlapiTypes implements Types {
35:
36: private final OwlapiAdapter adapter;
37:
38: private final Procedure beforeCallback;
39: private final Procedure afterChangeCallback;
40:
41: public OwlapiTypes(OwlapiAdapter adapter, Procedure beforeCallback, Procedure afterChangeCallback) {
42: this.adapter = adapter;
43: this.beforeCallback = beforeCallback;
44: this.afterChangeCallback = afterChangeCallback;
45: }
46:
47: @Override
48: public Set<Axiom<URI>> getTypes(NamedResource individual, Collection<URI> contexts, boolean includeInferred)
49: throws OntoDriverException {
50: Objects.requireNonNull(individual, getNPXMessageSupplier("individual"));
51: beforeCallback.execute();
52: return adapter.getTypesHandler().getTypes(individual, contexts, includeInferred);
53: }
54:
55: @Override
56: public void addTypes(NamedResource individual, URI context, Set<URI> types) throws OntoDriverException {
57: ensureValidity(individual, types);
58:• if (!types.isEmpty()) {
59: adapter.getTypesHandler().addTypes(individual, context, types);
60: }
61: afterChangeCallback.execute();
62: }
63:
64: private void ensureValidity(NamedResource individual, Set<URI> types) throws OwlapiDriverException {
65: Objects.requireNonNull(individual, getNPXMessageSupplier("individual"));
66: Objects.requireNonNull(types, getNPXMessageSupplier("types"));
67: beforeCallback.execute();
68: }
69:
70: @Override
71: public void removeTypes(NamedResource individual, URI context, Set<URI> types) throws OntoDriverException {
72: ensureValidity(individual, types);
73:• if (!types.isEmpty()) {
74: adapter.getTypesHandler().removeTypes(individual, context, types);
75: }
76: afterChangeCallback.execute();
77: }
78: }