Skip to content

Package: ValueSerializer

ValueSerializer

nameinstructionbranchcomplexitylinemethod
configure(Configuration)
M: 0 C: 1
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: /**
2: * Copyright (C) 2022 Czech Technical University in Prague
3: * <p>
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: * <p>
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.jsonld.serialization.serializer;
16:
17: import cz.cvut.kbss.jsonld.Configuration;
18: import cz.cvut.kbss.jsonld.common.Configurable;
19: import cz.cvut.kbss.jsonld.serialization.model.JsonNode;
20: import cz.cvut.kbss.jsonld.serialization.traversal.SerializationContext;
21:
22: /**
23: * Serializes values.
24: */
25: @FunctionalInterface
26: public interface ValueSerializer<T> extends Configurable {
27:
28: /**
29: * Serializes the specified value, returning a JSON-LD node representing it.
30: * <p>
31: * Note that if the value is a singular, the returned node should also contain the identifier of the serialized attribute (available
32: * through the provided serialization context).
33: *
34: * @param value Value to serialize
35: * @param ctx Serialization context
36: * @return Serialization result
37: */
38: JsonNode serialize(T value, SerializationContext<T> ctx);
39:
40: /**
41: * Applies the specified configuration to this serializer.
42: * <p>
43: * Should be called at the beginning of serialization of an object graph so that potential runtime changes in configuration
44: * can be reflected by the serialization process.
45: * <p>
46: * Implementations are free to apply configuration on initialization and rely on the default implementation of this
47: * method which does nothing.
48: *
49: * @param config Configuration to apply
50: */
51: @Override
52: default void configure(Configuration config) {
53: }
54: }