Skip to content

Package: OwlapiListIterator

OwlapiListIterator

nameinstructionbranchcomplexitylinemethod
OwlapiListIterator()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
checkIsNamed(OWLIndividual)
M: 5 C: 4
44%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 1 C: 2
67%
M: 0 C: 1
100%
checkMaxSuccessors(OWLObjectProperty, Collection)
M: 0 C: 22
100%
M: 0 C: 2
100%
M: 0 C: 2
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.owlapi.list;
16:
17: import cz.cvut.kbss.ontodriver.exception.IntegrityConstraintViolatedException;
18: import cz.cvut.kbss.ontodriver.model.Axiom;
19: import cz.cvut.kbss.ontodriver.model.NamedResource;
20: import org.semanticweb.owlapi.model.OWLIndividual;
21: import org.semanticweb.owlapi.model.OWLObjectProperty;
22: import org.semanticweb.owlapi.model.OWLOntologyChange;
23:
24: import java.util.Collection;
25: import java.util.List;
26:
27: abstract class OwlapiListIterator {
28:
29: abstract boolean hasNext();
30:
31: abstract Axiom<NamedResource> next();
32:
33: abstract NamedResource nextValue();
34:
35: /**
36: * Gets the current list node.
37: * <p>
38: * Gets the current list node, which for simple lists is the same as {@link #nextValue()}, but for referenced list,
39: * it returns the actual node in the list, not its value.
40: *
41: * @return Current list node
42: */
43: abstract NamedResource getCurrentNode();
44:
45: /**
46: * Removes the current element without reconnecting the previous node to the following one.
47: * <p>
48: * This effectively breaks the list. It should be used only for removing all of the following nodes from the list.
49: * <p>
50: * Note that this method just creates the changes, it does not apply them.
51: *
52: * @return List of changes to apply
53: */
54: abstract List<OWLOntologyChange> removeWithoutReconnect();
55:
56: /**
57: * Replaces the current value with the specified one.
58: * <p>
59: * Note that this method just creates the changes, it does not apply them.
60: *
61: * @param newValue The new value to use
62: * @return List of changes to apply
63: */
64: abstract List<OWLOntologyChange> replaceNode(NamedResource newValue);
65:
66: void checkMaxSuccessors(OWLObjectProperty property, Collection<? extends OWLIndividual> successors) {
67:• if (successors.size() > 1) {
68: throw new IntegrityConstraintViolatedException(
69: "Invalid number of successors. Expected only 1 value of property " + property + ", but got " +
70: successors.size());
71: }
72: }
73:
74: void checkIsNamed(OWLIndividual individual) {
75:• if (!individual.isNamed()) {
76: throw new IllegalArgumentException("Expected OWLNamedIndividual, but got an anonymous one.");
77: }
78: }
79: }