Skip to content

Package: AttributeConverter

AttributeConverter

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.model;
16:
17: /**
18: * A class that implements this interface can be used to convert entity attribute state into axiom/triple value
19: * representation and back again.
20: * <p>
21: * Note that the X and Y types may be the same Java type.
22: *
23: * @param <X> the type of the entity attribute
24: * @param <Y> the type of the axiom/triple value
25: */
26: public interface AttributeConverter<X, Y> {
27:
28: /**
29: * Converts the value stored in the entity attribute into the data representation to be stored in the repository and
30: * supported by the OntoDriver API.
31: *
32: * @param value Value to convert
33: * @return Converted data
34: */
35: Y convertToAxiomValue(X value);
36:
37: /**
38: * Converts the data stored in the repository into the value to be stored in the entity attribute.
39: * <p>
40: * Note that it is the responsibility of the converter writer to specify the correct {@code value} type for the
41: * corresponding value for use by the OntoDriver: i.e., persistence providers are not expected to do such type
42: * conversion.
43: *
44: * @param value Value to convert
45: * @return Converted data
46: */
47: X convertToAttribute(Y value);
48: }