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