Skip to content

Package: LiteralNode

LiteralNode

nameinstructionbranchcomplexitylinemethod
LiteralNode(Object)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
LiteralNode(String, Object)
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: 38
90%
M: 5 C: 11
69%
M: 5 C: 4
44%
M: 0 C: 5
100%
M: 0 C: 1
100%
getValue()
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: 8 C: 9
53%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 1 C: 3
75%
M: 0 C: 1
100%
toString()
M: 0 C: 13
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: /**
2: * Copyright (C) 2020 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.jsonld.serialization.model;
16:
17: import java.util.Objects;
18:
19: public abstract class LiteralNode<T> extends JsonNode {
20:
21: final T value;
22:
23: public LiteralNode(T value) {
24: this.value = Objects.requireNonNull(value);
25: }
26:
27: public LiteralNode(String name, T value) {
28: super(name);
29: this.value = Objects.requireNonNull(value);
30: }
31:
32: public T getValue() {
33: return value;
34: }
35:
36: @Override
37: public String toString() {
38: return super.toString() + value + "}";
39: }
40:
41: @Override
42: public boolean equals(Object o) {
43:• if (this == o) return true;
44:• if (o == null || getClass() != o.getClass()) return false;
45:
46: LiteralNode<?> that = (LiteralNode<?>) o;
47:
48:• return (getName() == null || getName().equals(that.getName())) &&
49:• (getName() != null || that.getName() == null) && value.equals(that.value);
50:
51: }
52:
53: @Override
54: public int hashCode() {
55: int result = value.hashCode();
56:• if (getName() != null) {
57: result = 31 * result + getName().hashCode();
58: }
59: return result;
60: }
61: }