Skip to content

Package: SerializerBuilderParams$Builder

SerializerBuilderParams$Builder

nameinstructionbranchcomplexitylinemethod
SerializerBuilderParams.Builder(Type)
M: 17 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 6 C: 0
0%
M: 1 C: 0
0%
build()
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%
customization(Customization)
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
key(boolean)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
objectBaseSerializer(ModelSerializer)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
resolveRootAdapter(boolean)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
root(boolean)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
type(Type)
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * Copyright (c) 2021, 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.serializer;
14:
15: import java.lang.reflect.Type;
16: import java.util.Objects;
17:
18: import org.eclipse.yasson.internal.model.customization.ClassCustomization;
19: import org.eclipse.yasson.internal.model.customization.Customization;
20:
21: /**
22: * Not currently supported. Possibly implemented in the future.
23: *
24: * Holder of serialization parameters during creation process. Reduces the number of needed parameters.
25: */
26: class SerializerBuilderParams {
27:
28: private final Type type;
29: private final Customization customization;
30: private final boolean root;
31: private final boolean key;
32: private final boolean resolveRootAdapter;
33: private final ModelSerializer objectBaseSerializer;
34:
35: private SerializerBuilderParams(Builder builder) {
36: this.type = builder.type;
37: this.customization = builder.customization;
38: this.root = builder.root;
39: this.key = builder.key;
40: this.resolveRootAdapter = builder.resolveRootAdapter;
41: this.objectBaseSerializer = builder.objectBaseSerializer;
42: }
43:
44: public static Builder builder(Type type) {
45: return new Builder(type);
46: }
47:
48: public Type getType() {
49: return type;
50: }
51:
52: public Customization getCustomization() {
53: return customization;
54: }
55:
56: public boolean isRoot() {
57: return root;
58: }
59:
60: public boolean isKey() {
61: return key;
62: }
63:
64: public boolean isResolveRootAdapter() {
65: return resolveRootAdapter;
66: }
67:
68: public ModelSerializer getObjectBaseSerializer() {
69: return objectBaseSerializer;
70: }
71:
72: static final class Builder {
73:
74: private Type type;
75: private Customization customization;
76: private boolean root;
77: private boolean key;
78: private boolean resolveRootAdapter;
79: private ModelSerializer objectBaseSerializer;
80:
81: private Builder(Type type) {
82: this.type = Objects.requireNonNull(type);
83: this.customization = ClassCustomization.empty();
84: this.root = true;
85: this.key = false;
86: }
87:
88: public Builder type(Type type) {
89: this.type = Objects.requireNonNull(type);
90: return this;
91: }
92:
93: public Builder customization(Customization customization) {
94: this.customization = Objects.requireNonNull(customization);
95: return this;
96: }
97:
98: public Builder root(boolean root) {
99: this.root = root;
100: return this;
101: }
102:
103: public Builder key(boolean key) {
104: this.key = key;
105: return this;
106: }
107:
108: public Builder resolveRootAdapter(boolean resolveRootAdapter) {
109: this.resolveRootAdapter = resolveRootAdapter;
110: return this;
111: }
112:
113: public Builder objectBaseSerializer(ModelSerializer objectBaseSerializer) {
114: this.objectBaseSerializer = objectBaseSerializer;
115: return this;
116: }
117:
118: public SerializerBuilderParams build() {
119: return new SerializerBuilderParams(this);
120: }
121:
122: }
123:
124: }