Skip to content

Package: CustomConverterWrapper

CustomConverterWrapper

nameinstructionbranchcomplexitylinemethod
CustomConverterWrapper(AttributeConverter, Class)
M: 11 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
convertToAttribute(Object)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
convertToAxiomValue(Object)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
supportsAxiomValueType(Class)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

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.jopa.oom.converter;
16:
17: import cz.cvut.kbss.jopa.model.AttributeConverter;
18:
19: import java.util.Objects;
20:
21: /**
22: * Instances of this class are used to wrap user-defined {@link AttributeConverter} implementation.
23: */
24: public class CustomConverterWrapper<X, Y> implements ConverterWrapper<X, Y> {
25:
26: private final AttributeConverter<X, Y> wrapped;
27: private final Class<Y> axiomValueType;
28:
29: public CustomConverterWrapper(AttributeConverter<X, Y> wrapped, Class<Y> axiomValueType) {
30: this.wrapped = Objects.requireNonNull(wrapped);
31: this.axiomValueType = axiomValueType;
32: }
33:
34: @Override
35: public Y convertToAxiomValue(X value) {
36: return wrapped.convertToAxiomValue(value);
37: }
38:
39: @Override
40: public X convertToAttribute(Y value) {
41: return wrapped.convertToAttribute(value);
42: }
43:
44: @Override
45: public boolean supportsAxiomValueType(Class<?> type) {
46: return axiomValueType.isAssignableFrom(type);
47: }
48: }