Skip to content

Package: AbstractAxiomDescriptor

AbstractAxiomDescriptor

nameinstructionbranchcomplexitylinemethod
AbstractAxiomDescriptor(NamedResource)
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
equals(Object)
M: 4 C: 15
79%
M: 2 C: 2
50%
M: 2 C: 1
33%
M: 2 C: 4
67%
M: 0 C: 1
100%
getSubject()
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%
hashCode()
M: 9 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * Copyright (C) 2023 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.descriptor;
16:
17: import cz.cvut.kbss.ontodriver.model.Assertion;
18: import cz.cvut.kbss.ontodriver.model.NamedResource;
19:
20: import java.net.URI;
21: import java.util.Objects;
22: import java.util.Set;
23:
24: /**
25: * Defines common API for axiom descriptors.
26: */
27: public abstract class AbstractAxiomDescriptor {
28:
29: private final NamedResource subject;
30:
31: protected AbstractAxiomDescriptor(NamedResource subject) {
32: this.subject = Objects.requireNonNull(subject);
33: }
34:
35: public NamedResource getSubject() {
36: return subject;
37: }
38:
39: /**
40: * Gets the set of assertions in this descriptor.
41: *
42: * @return Set of assertions
43: */
44: public abstract Set<Assertion> getAssertions();
45:
46: /**
47: * Checks whether this descriptor contains the specified assertion.
48: *
49: * @param assertion Assertion to look for
50: * @return {@code boolean} result
51: */
52: public abstract boolean containsAssertion(Assertion assertion);
53:
54: /**
55: * Gets the set of repository context identifiers in which this descriptor's subject may be.
56: * <p>
57: * The contract of this method is as follows: it must not return {@code null}, if the the subject is in the default
58: * context, an empty set is returned.
59: *
60: * @return Set of context identifiers
61: */
62: public abstract Set<URI> getSubjectContexts();
63:
64: /**
65: * Gets the set of repository context identifiers in which the specified assertion values may be.
66: * <p>
67: * If no context was explicitly set, the same contexts as the subject's are returned. An empty result indicates that
68: * the default context should be used.
69: *
70: * @return Set of context identifiers
71: */
72: public abstract Set<URI> getAssertionContexts(Assertion assertion);
73:
74: @Override
75: public boolean equals(Object o) {
76:• if (this == o) {
77: return true;
78: }
79:• if (!(o instanceof AbstractAxiomDescriptor)) {
80: return false;
81: }
82: AbstractAxiomDescriptor that = (AbstractAxiomDescriptor) o;
83: return subject.equals(that.subject);
84: }
85:
86: @Override
87: public int hashCode() {
88: return Objects.hash(subject);
89: }
90: }