Skip to content

Package: PendingReference

PendingReference

nameinstructionbranchcomplexitylinemethod
getTargetType()
M: 0 C: 2
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.deserialization.reference;
19:
20: import java.util.Optional;
21:
22: /**
23: * Represents a pending reference.
24: * <p>
25: * A pending reference represents a situation when the JSON-LD contains just an object with and {@code @id}, while the
26: * mapped attribute expects a full-blown object. In this case, it is expected that somewhere in the JSON-LD, there is
27: * the object's full serialization and this is only a reference to it.
28: */
29: public interface PendingReference {
30:
31: /**
32: * Applies the specified referenced object to this pending reference, resolving it.
33: * <p>
34: * Resolving the reference basically means inserting the referenced object into the place represented by this
35: * instance (e.g., field value, collection).
36: *
37: * @param referencedObject The object referenced by this pending reference
38: */
39: void apply(Object referencedObject);
40:
41: /**
42: * Gets the target type of the pending reference.
43: * <p>
44: * If the target type cannot be reliably determined (for instance, because it is a collection), this method should
45: * return {@link Optional#empty()}.
46: *
47: * @return The target type
48: */
49: default Optional<Class<?>> getTargetType() {
50: return Optional.empty();
51: }
52: }