Skip to content

Package: LangString

LangString

nameinstructionbranchcomplexitylinemethod
LangString()
M: 9 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
LangString(String)
M: 0 C: 11
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
LangString(String, String)
M: 0 C: 11
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
equals(Object)
M: 2 C: 27
93%
M: 1 C: 7
88%
M: 1 C: 4
80%
M: 1 C: 5
83%
M: 0 C: 1
100%
getLanguage()
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%
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: 0 C: 14
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
toString()
M: 3 C: 10
77%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 1
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.model;
19:
20: import java.io.Serializable;
21: import java.util.Objects;
22: import java.util.Optional;
23:
24: /**
25: * Represents a string value with a (optional) language tag.
26: */
27: public class LangString implements Serializable {
28:
29: private final String value;
30:
31: private final String language;
32:
33: /**
34: * Explicit no-arg constructor allowing deserialization from JSON.
35: */
36: private LangString() {
37: this.value = null;
38: this.language = null;
39: }
40:
41: public LangString(String value) {
42: this.value = Objects.requireNonNull(value);
43: this.language = null;
44: }
45:
46: public LangString(String value, String language) {
47: this.value = Objects.requireNonNull(value);
48: this.language = language;
49: }
50:
51: /**
52: * Gets the lexical value of this string.
53: *
54: * @return Lexical value
55: */
56: public String getValue() {
57: return value;
58: }
59:
60: /**
61: * Gets the language tag (if present).
62: *
63: * @return Optional language tag value
64: */
65: public Optional<String> getLanguage() {
66: return Optional.ofNullable(language);
67: }
68:
69: @Override
70: public boolean equals(Object o) {
71:• if (this == o) {
72: return true;
73: }
74:• if (!(o instanceof LangString)) {
75: return false;
76: }
77: LangString that = (LangString) o;
78:• return Objects.equals(value, that.value) && Objects.equals(language, that.language);
79: }
80:
81: @Override
82: public int hashCode() {
83: return Objects.hash(value, language);
84: }
85:
86: @Override
87: public String toString() {
88:• return language != null ? "\"" + value + "\"@" + language : "\"" + value + '"';
89: }
90: }