Package: LangString
LangString
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
LangString(String, String) |
|
|
|
|
|
||||||||||||||||||||
getLanguage() |
|
|
|
|
|
||||||||||||||||||||
toString() |
|
|
|
|
|
Coverage
1: /**
2: * Copyright (C) 2022 Czech Technical University in Prague
3: * <p>
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: * <p>
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.deserialization.util;
16:
17: import cz.cvut.kbss.jsonld.JsonLd;
18:
19: import java.util.Optional;
20:
21: /**
22: * Represents a string with a language tag.
23: */
24: public class LangString extends cz.cvut.kbss.ontodriver.model.LangString {
25:
26: public LangString(String value, String language) {
27: super(value, language);
28: }
29:
30: /**
31: * Gets the language set on this tagged string.
32: * <p>
33: * Note that if the language is {@link JsonLd#NONE} (JSON-LD 1.1 keyword), an empty {@link Optional} is returned to ensure
34: * consistency with {@link cz.cvut.kbss.jopa.model.MultilingualString} behavior.
35: *
36: * @return Language tag, possibly empty
37: */
38: @Override
39: public Optional<String> getLanguage() {
40: final Optional<String> superResult = super.getLanguage();
41:• return JsonLd.NONE.equals(superResult.get()) ? Optional.empty() : superResult;
42: }
43:
44: @Override
45: public String toString() {
46: // This implementation returns only value to allow its usage in DataTypeTransformer
47: return getValue();
48: }
49: }