Skip to content

Package: NamedResource

NamedResource

nameinstructionbranchcomplexitylinemethod
NamedResource(URI)
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%
create(String)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
create(URI)
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
equals(Object)
M: 2 C: 23
92%
M: 1 C: 5
83%
M: 1 C: 3
75%
M: 1 C: 7
88%
M: 0 C: 1
100%
getIdentifier()
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: 0 C: 14
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
toString()
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: /*
2: * JOPA
3: * Copyright (C) 2023 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.model;
19:
20: import java.io.Serializable;
21: import java.net.URI;
22: import java.util.Objects;
23:
24: /**
25: * Represents named resources, i.e. resources identified by a URI.
26: */
27: public class NamedResource implements Serializable {
28:
29: private static final long serialVersionUID = 5932515448919851871L;
30:
31: private final URI identifier;
32:
33: NamedResource(URI uri) {
34: this.identifier = Objects.requireNonNull(uri);
35: }
36:
37: /**
38: * Gets the identifier of this resource.
39: *
40: * @return URI
41: */
42: public URI getIdentifier() {
43: return identifier;
44: }
45:
46: @Override
47: public int hashCode() {
48: final int prime = 31;
49: int result = 1;
50: result = prime * result + identifier.hashCode();
51: return result;
52: }
53:
54: @Override
55: public boolean equals(Object obj) {
56:• if (this == obj)
57: return true;
58:• if (obj == null)
59: return false;
60:• if (getClass() != obj.getClass())
61: return false;
62: NamedResource other = (NamedResource) obj;
63: return identifier.equals(other.identifier);
64: }
65:
66: @Override
67: public String toString() {
68: return identifier.toString();
69: }
70:
71: /**
72: * Creates new named resource from the specified URI.
73: *
74: * @param uri Resource identifier
75: * @return NamedResource instance
76: */
77: public static NamedResource create(URI uri) {
78: return new NamedResource(uri);
79: }
80:
81: /**
82: * Creates new named resource from the specified string identifier.
83: *
84: * @param iri Resource identifier
85: * @return NamedResource instance
86: */
87: public static NamedResource create(String iri) {
88: return new NamedResource(URI.create(iri));
89: }
90: }