Skip to content

Package: AdapterBinding

AdapterBinding

nameinstructionbranchcomplexitylinemethod
AdapterBinding(Type, Type, JsonbAdapter)
M: 16 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 6 C: 0
0%
M: 1 C: 0
0%
getAdapter()
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%
getComponentClass()
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%
getToType()
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%

Coverage

1: /*
2: * Copyright (c) 2016, 2020 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.components;
14:
15: import java.lang.reflect.Type;
16: import java.util.Objects;
17:
18: import jakarta.json.bind.adapter.JsonbAdapter;
19:
20: /**
21: * Wrapper for JsonbAdapter generic information and an components itself.
22: */
23: public class AdapterBinding extends AbstractComponentBinding {
24:
25: private final Type toType;
26:
27: private final JsonbAdapter<?, ?> adapter;
28:
29: /**
30: * Adapter info with type to "adapt from", type to "adapt to" and an components itself.
31: *
32: * @param fromType from not null
33: * @param toType to not null
34: * @param adapter components not null
35: */
36: public AdapterBinding(Type fromType, Type toType, JsonbAdapter<?, ?> adapter) {
37: super(fromType);
38: Objects.requireNonNull(toType);
39: Objects.requireNonNull(adapter);
40: this.toType = toType;
41: this.adapter = adapter;
42: }
43:
44: /**
45: * Represents a type to which to adapt into.
46: *
47: * During marshalling object property is adapted to this type and result is marshalled.
48: * During unmarshalling object is unmarshalled into this type first, than converted to field type and set.
49: *
50: * @return Type from which to adapt
51: */
52: public Type getToType() {
53: return toType;
54: }
55:
56: /**
57: * Get actual components to adapt object value.
58: *
59: * @return components
60: */
61: public JsonbAdapter<?, ?> getAdapter() {
62: return adapter;
63: }
64:
65: @Override
66: public Class<?> getComponentClass() {
67: return adapter.getClass();
68: }
69: }