Package: CollectionPendingReference
CollectionPendingReference
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
CollectionPendingReference(Collection) |
|
|
|
|
|
||||||||||||||||||||
apply(Object) |
|
|
|
|
|
||||||||||||||||||||
static {...} |
|
|
|
|
|
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.Collection;
21: import java.util.Objects;
22:
23: /**
24: * Represents a collection-based pending reference.
25: * <p>
26: * That is, a collection containing a reference to an object.
27: */
28: public class CollectionPendingReference implements PendingReference {
29:
30: private final Collection targetCollection;
31:
32: public CollectionPendingReference(Collection targetCollection) {
33: this.targetCollection = Objects.requireNonNull(targetCollection);
34: }
35:
36: @Override
37: public void apply(Object referencedObject) {
38:• assert referencedObject != null;
39: // Note, that this will not preserve ordering in Lists. If it becomes a problem, we'll need to provide a specialized
40: // version for lists where a placeholder would be put into the list and replaced by the referenced object later
41: // to ensure correct order
42: targetCollection.add(referencedObject);
43: }
44: }