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