Skip to content

Package: ToLexicalFormConverter

ToLexicalFormConverter

nameinstructionbranchcomplexitylinemethod
ToLexicalFormConverter()
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%
convertToAttribute(Object)
M: 4 C: 13
76%
M: 1 C: 3
75%
M: 1 C: 2
67%
M: 0 C: 2
100%
M: 0 C: 1
100%
convertToAxiomValue(String)
M: 0 C: 2
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
static {...}
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%
supportsAxiomValueType(Class)
M: 0 C: 8
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: /**
2: * Copyright (C) 2020 Czech Technical University in Prague
3: * <p>
4: * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
5: * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
6: * version.
7: * <p>
8: * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9: * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
10: * details. You should have received a copy of the GNU General Public License along with this program. If not, see
11: * <http://www.gnu.org/licenses/>.
12: */
13: package cz.cvut.kbss.jopa.oom.converter;
14:
15: import cz.cvut.kbss.ontodriver.model.LangString;
16: import cz.cvut.kbss.ontodriver.model.NamedResource;
17:
18: /**
19: * Converts literal lexical form to Java {@code String}.
20: * <p>
21: * This converter ensures seamless support for lexical forms.
22: */
23: public class ToLexicalFormConverter implements ConverterWrapper<String, Object> {
24:
25: public static final ToLexicalFormConverter INSTANCE = new ToLexicalFormConverter();
26:
27: @Override
28: public boolean supportsAxiomValueType(Class<?> type) {
29: // Anything but a NamedResource (i.e., a literal since anonymous individuals are not supported) can be transformed to lexical form
30:• return !NamedResource.class.isAssignableFrom(type);
31: }
32:
33: @Override
34: public Object convertToAxiomValue(String value) {
35: return value;
36: }
37:
38: @Override
39: public String convertToAttribute(Object value) {
40:• assert value != null;
41:• return value instanceof LangString ? ((LangString) value).getValue() : value.toString();
42: }
43: }