Skip to content

Package: ProcessingContext

ProcessingContext

nameinstructionbranchcomplexitylinemethod
ProcessingContext(JsonbContext)
M: 11 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
addProcessedObject(Object)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getJsonbContext()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getMappingContext()
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
removeProcessedObject(Object)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * Copyright (c) 2015, 2022 Oracle and/or its affiliates. All rights reserved.
3: *
4: * This program and the accompanying materials are made available under the
5: * terms of the Eclipse Public License v. 2.0 which is available at
6: * http://www.eclipse.org/legal/epl-2.0,
7: * or the Eclipse Distribution License v. 1.0 which is available at
8: * http://www.eclipse.org/org/documents/edl-v10.php.
9: *
10: * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
11: */
12:
13: package org.eclipse.yasson.internal;
14:
15: import java.util.HashSet;
16: import java.util.Set;
17:
18: /**
19: * Jsonb processing (serializing/deserializing) context.
20: * Instance is thread bound (in contrast to {@link JsonbContext}.
21: */
22: public abstract class ProcessingContext {
23:
24: private final JsonbContext jsonbContext;
25:
26: /**
27: * Used to avoid StackOverflowError, when adapted / serialized object
28: * contains instance of its type inside it or when object has recursive reference.
29: */
30: private final Set<Object> currentlyProcessedObjects = new HashSet<>();
31:
32: /**
33: * Parent for marshaller and unmarshaller.
34: *
35: * @param jsonbContext context of Jsonb
36: */
37: public ProcessingContext(JsonbContext jsonbContext) {
38: this.jsonbContext = jsonbContext;
39: }
40:
41: /**
42: * Jsonb context.
43: *
44: * @return jsonb context
45: */
46: public JsonbContext getJsonbContext() {
47: return jsonbContext;
48: }
49:
50: /**
51: * Mapping context.
52: *
53: * @return mapping context
54: */
55: public MappingContext getMappingContext() {
56: return getJsonbContext().getMappingContext();
57: }
58:
59: /**
60: * Adds currently processed object to the {@link Set}.
61: *
62: * @param object processed object
63: * @return if object was added
64: */
65: public boolean addProcessedObject(Object object) {
66: return this.currentlyProcessedObjects.add(object);
67: }
68:
69: /**
70: * Removes processed object from the {@link Set}.
71: *
72: * @param object processed object
73: * @return if object was removed
74: */
75: public boolean removeProcessedObject(Object object) {
76: return currentlyProcessedObjects.remove(object);
77: }
78:
79: }