Skip to content

Package: Rdf4jTypes

Rdf4jTypes

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