Skip to content

Package: AttributeConverter

AttributeConverter

Coverage

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