Skip to content

Package: SesameTypes

SesameTypes

nameinstructionbranchcomplexitylinemethod
SesameTypes(SesameAdapter, 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%
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%
verifyValidity(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%

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.sesame;
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.sesame.exceptions.SesameDriverException;
22:
23: import java.net.URI;
24: import java.util.Objects;
25: import java.util.Set;
26:
27: import static cz.cvut.kbss.ontodriver.util.ErrorUtils.npxMessage;
28:
29: public class SesameTypes implements Types {
30:
31: private final SesameAdapter adapter;
32:
33: private Procedure beforeCallback;
34: private Procedure afterChangeCallback;
35:
36: public SesameTypes(SesameAdapter adapter, Procedure beforeCallback, Procedure afterChangeCallback) {
37: this.adapter = adapter;
38: this.beforeCallback = beforeCallback;
39: this.afterChangeCallback = afterChangeCallback;
40: }
41:
42: @Override
43: public Set<Axiom<URI>> getTypes(NamedResource individual, URI context, boolean includeInferred)
44: throws OntoDriverException {
45: Objects.requireNonNull(individual, npxMessage("individual"));
46: beforeCallback.execute();
47: return adapter.getTypesHandler().getTypes(individual, context, includeInferred);
48: }
49:
50: @Override
51: public void addTypes(NamedResource individual, URI context, Set<URI> types) throws OntoDriverException {
52: verifyValidity(individual, types);
53:• if (!types.isEmpty()) {
54: adapter.getTypesHandler().addTypes(individual, context, types);
55: }
56: afterChangeCallback.execute();
57: }
58:
59: private void verifyValidity(NamedResource individual, Set<URI> types) throws SesameDriverException {
60: Objects.requireNonNull(individual, npxMessage("individual"));
61: Objects.requireNonNull(types, npxMessage("types"));
62: beforeCallback.execute();
63: }
64:
65: @Override
66: public void removeTypes(NamedResource individual, URI context, Set<URI> types) throws OntoDriverException {
67: verifyValidity(individual, types);
68:• if (!types.isEmpty()) {
69: adapter.getTypesHandler().removeTypes(individual, context, types);
70: }
71: afterChangeCallback.execute();
72: }
73: }