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