genericBox;
26 | }
27 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/defaultmapping/generics/model/PropagatedGenericClass.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, 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.defaultmapping.generics.model;
14 |
15 | import java.util.List;
16 |
17 | /**
18 | * @author Roman Grigoriadi
19 | */
20 | public class PropagatedGenericClass {
21 | public List, X>> genericList;
22 | public GenericTestClass genericTestClass;
23 | }
24 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/customization/model/JsonbNillableOverridesInterface.java:
--------------------------------------------------------------------------------
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.customization.model;
14 |
15 | import jakarta.json.bind.annotation.JsonbNillable;
16 |
17 | /**
18 | * @author Roman Grigoriadi
19 | */
20 | @JsonbNillable(false)
21 | public class JsonbNillableOverridesInterface implements JsonbNillableInterfaceBaseTwo {
22 | public String nillableField;
23 | }
24 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/defaultmapping/generics/model/GenericWithUnboundedWildcardClass.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, 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.defaultmapping.generics.model;
14 |
15 | import java.util.List;
16 |
17 | /**
18 | * @author Roman Grigoriadi
19 | */
20 | public class GenericWithUnboundedWildcardClass {
21 | public List> wildcardList;
22 |
23 | public GenericWithUnboundedWildcardClass() {
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/defaultmapping/generics/model/TreeTypeContainer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 Red Hat, Inc. and/or its affiliates.
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.defaultmapping.generics.model;
14 |
15 | import java.util.List;
16 |
17 | /**
18 | * @author James R. Perkins
19 | */
20 | public interface TreeTypeContainer> {
21 |
22 | List getChildren();
23 |
24 | void setChildren(List children);
25 | }
26 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/defaultmapping/inheritance/model/generics/ExtendsPropagatedGenericClass.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, 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.defaultmapping.inheritance.model.generics;
14 |
15 | import org.eclipse.yasson.defaultmapping.generics.model.PropagatedGenericClass;
16 |
17 | /**
18 | * @author Roman Grigoriadi
19 | */
20 | public class ExtendsPropagatedGenericClass extends PropagatedGenericClass {
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/org/eclipse/yasson/internal/serializer/AbstractSerializer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 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 | /**
16 | * Abstract model serializer with delegate.
17 | */
18 | abstract class AbstractSerializer implements ModelSerializer {
19 |
20 | final ModelSerializer delegate;
21 |
22 | AbstractSerializer(ModelSerializer delegate) {
23 | this.delegate = delegate;
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/TestTypeToken.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019, 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;
14 |
15 | import java.lang.reflect.ParameterizedType;
16 | import java.lang.reflect.Type;
17 |
18 | /**
19 | * @author Roman Grigoriadi
20 | */
21 | public abstract class TestTypeToken {
22 | public Type getType() {
23 | return ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/adapters/model/BoxToCratePropagatedTypeArgsAdapter.java:
--------------------------------------------------------------------------------
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.adapters.model;
14 |
15 | import jakarta.json.bind.adapter.JsonbAdapter;
16 | import java.util.List;
17 |
18 | /**
19 | * @author Roman Grigoriadi
20 | */
21 | public abstract class BoxToCratePropagatedTypeArgsAdapter implements JsonbAdapter, GenericCrate>>> {
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/adapters/model/Foo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019, 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.adapters.model;
14 |
15 | public class Foo {
16 |
17 | private String bar;
18 |
19 | public Foo(String bar) {
20 | this.bar = bar;
21 | }
22 |
23 | public String getBar() {
24 | return bar;
25 | }
26 |
27 | public void setBar(String bar) {
28 | this.bar = bar;
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/customization/model/JsonbNillableInterfaceBaseTwo.java:
--------------------------------------------------------------------------------
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.customization.model;
14 |
15 | import jakarta.json.bind.annotation.JsonbNillable;
16 |
17 | /**
18 | * Overrides super interface nillable value.
19 | *
20 | * @author Roman Grigoriadi
21 | */
22 | @JsonbNillable(false)
23 | public interface JsonbNillableInterfaceBaseTwo extends JsonbNillableInterfaceBase {
24 | }
25 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/customization/model/InterfacedPojoA.java:
--------------------------------------------------------------------------------
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.customization.model;
14 |
15 | import jakarta.json.bind.annotation.JsonbProperty;
16 |
17 | /**
18 | * @author Roman Grigoriadi
19 | */
20 | public interface InterfacedPojoA {
21 |
22 |
23 | @JsonbProperty("propA")
24 | String getPropertyA();
25 |
26 | @JsonbProperty("propA")
27 | void setPropertyA(String property);
28 | }
29 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/defaultmapping/dates/model/CollectionDatePojo.java:
--------------------------------------------------------------------------------
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.defaultmapping.dates.model;
14 |
15 | import jakarta.json.bind.annotation.JsonbDateFormat;
16 | import java.util.Date;
17 | import java.util.List;
18 |
19 | /**
20 | * @author Roman Grigoriadi
21 | */
22 | public class CollectionDatePojo {
23 |
24 | @JsonbDateFormat("HH:mm:ss | dd-MM-yyyy")
25 | public List dates;
26 | }
27 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/defaultmapping/inheritance/model/AbstractZeroLevel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, 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.defaultmapping.inheritance.model;
14 |
15 | /**
16 | * @author Roman Grigoriadi
17 | */
18 | public abstract class AbstractZeroLevel {
19 |
20 | protected String inZeroOverriddenInFirst;
21 |
22 | abstract String getInZeroOverriddenInFirst();
23 |
24 | abstract void setInZeroOverriddenInFirst(String value);
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/defaultmapping/lambda/Pet.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019, 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.defaultmapping.lambda;
14 |
15 | /**
16 | * A functional interface with one default property.
17 | */
18 | public interface Pet extends Addressable {
19 |
20 | /**
21 | * Public readable property with default value.
22 | *
23 | * @return pet's age in months
24 | */
25 | default int getAge() {
26 | return 0;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/defaultmapping/generics/model/Shape.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, 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.defaultmapping.generics.model;
14 |
15 | /**
16 | * @author Roman Grigoriadi
17 | */
18 | public class Shape {
19 | private Double area;
20 |
21 | public Shape() {
22 | }
23 |
24 | public Double getArea() {
25 | return area;
26 | }
27 |
28 | public void setArea(Double area) {
29 | this.area = area;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/internal/cdi/MethodCalledEvent.java:
--------------------------------------------------------------------------------
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.cdi;
14 |
15 | /**
16 | * @author Roman Grigoriadi
17 | */
18 | public class MethodCalledEvent {
19 |
20 | private final String methodName;
21 |
22 | public MethodCalledEvent(String methodName) {
23 | this.methodName = methodName;
24 | }
25 |
26 | public String getMethodName() {
27 | return methodName;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/logger/JsonbLoggerFormatter.java:
--------------------------------------------------------------------------------
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.logger;
14 |
15 | import java.util.logging.LogRecord;
16 |
17 | /**
18 | * @author Roman Grigoriadi
19 | */
20 | public class JsonbLoggerFormatter extends java.util.logging.Formatter {
21 | @Override
22 | public String format(LogRecord record) {
23 | return String.format("%-8s",record.getLevel()) + " => " + record.getMessage()+"\n";
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/etc/checkstyle-suppressions.xml:
--------------------------------------------------------------------------------
1 |
2 |
15 |
16 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/customization/model/InterfacedPojoB.java:
--------------------------------------------------------------------------------
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.customization.model;
14 |
15 | import jakarta.json.bind.annotation.JsonbProperty;
16 |
17 | /**
18 | * @author Roman Grigoriadi
19 | */
20 | public interface InterfacedPojoB extends InterfacedPojoA {
21 |
22 | @JsonbProperty("propB")
23 | String getPropertyB();
24 |
25 | @JsonbProperty("propB")
26 | void setPropertyB(String propertyB);
27 | }
28 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/customization/model/InterfacedPojoC.java:
--------------------------------------------------------------------------------
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.customization.model;
14 |
15 | import jakarta.json.bind.annotation.JsonbProperty;
16 |
17 | /**
18 | * @author Roman Grigoriadi
19 | */
20 | public interface InterfacedPojoC extends InterfacedPojoB {
21 |
22 | @JsonbProperty("propC")
23 | String getPropertyC();
24 |
25 | @JsonbProperty("propC")
26 | void setPropertyC(String propertyC);
27 | }
28 |
--------------------------------------------------------------------------------
/yasson-jmh/src/main/java/org/eclipse/yasson/jmh/model/ScalarData.java:
--------------------------------------------------------------------------------
1 | package org.eclipse.yasson.jmh.model;
2 |
3 | public class ScalarData {
4 |
5 | private String stringValue;
6 |
7 | private Integer integerValue;
8 |
9 | public ScalarData(String stringValue, Integer integerValue) {
10 | this.stringValue = stringValue;
11 | this.integerValue = integerValue;
12 | }
13 |
14 | public ScalarData() {
15 | this.stringValue = "Short string";
16 | this.integerValue = 10;
17 | }
18 |
19 | public String getStringValue() {
20 | return stringValue;
21 | }
22 |
23 | public void setStringValue(String stringValue) {
24 | this.stringValue = stringValue;
25 | }
26 |
27 | public Integer getIntegerValue() {
28 | return integerValue;
29 | }
30 |
31 | public void setIntegerValue(Integer integerValue) {
32 | this.integerValue = integerValue;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/defaultmapping/jsonp/model/JsonpPojo.java:
--------------------------------------------------------------------------------
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.defaultmapping.jsonp.model;
14 |
15 | import jakarta.json.*;
16 |
17 | /**
18 | * @author Roman Grigoriadi
19 | */
20 | public class JsonpPojo {
21 |
22 | public JsonObject jsonObject;
23 |
24 | public JsonArray jsonArray;
25 |
26 | public JsonNumber jsonNumber;
27 |
28 | public JsonString jsonString;
29 |
30 | public JsonValue jsonValue;
31 | }
32 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/customization/model/CreatorIncompatibleTypePojo.java:
--------------------------------------------------------------------------------
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.customization.model;
14 |
15 | import jakarta.json.bind.annotation.JsonbCreator;
16 | import java.io.Serializable;
17 |
18 | /**
19 | * @author Roman Grigoriadi
20 | */
21 | public class CreatorIncompatibleTypePojo {
22 |
23 | public String s1;
24 |
25 | @JsonbCreator
26 | public static Serializable getInstance() {
27 | return null;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/test/resources/test.policy:
--------------------------------------------------------------------------------
1 | grant {
2 | //needed to be able to read all files including META-INF entries
3 | permission "java.io.FilePermission" "<>", "read";
4 |
5 | permission "java.lang.reflect.ReflectPermission" "suppressAccessChecks";
6 | permission "java.lang.RuntimePermission" "accessDeclaredMembers";
7 |
8 | permission "java.lang.RuntimePermission" "createSecurityManager";
9 | permission java.lang.RuntimePermission "setSecurityManager";
10 | permission "java.lang.RuntimePermission" "getProtectionDomain";
11 | permission "java.lang.RuntimePermission" "getClassLoader";
12 | permission "java.util.PropertyPermission" "*", "write";
13 |
14 | permission "java.util.PropertyPermission" "jsonb.creator-parameters-required", "read";
15 | permission "java.util.PropertyPermission" "yasson.time-in-millis-as-a-string", "read";
16 | permission "java.util.PropertyPermission" "jakarta.json.provider", "read";
17 | };
--------------------------------------------------------------------------------
/src/main/java/org/eclipse/yasson/JsonBindingProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, 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;
14 |
15 | import jakarta.json.bind.JsonbBuilder;
16 | import jakarta.json.bind.spi.JsonbProvider;
17 |
18 | import org.eclipse.yasson.internal.JsonBindingBuilder;
19 |
20 | /**
21 | * JsonbProvider implementation.
22 | */
23 | public class JsonBindingProvider extends JsonbProvider {
24 |
25 | @Override
26 | public JsonbBuilder create() {
27 | return new JsonBindingBuilder();
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/customization/model/ImplementationClassPojo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, 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.customization.model;
14 |
15 | import org.eclipse.yasson.ImplementationClass;
16 |
17 | public class ImplementationClassPojo {
18 |
19 | @ImplementationClass(Dog.class)
20 | private Animal animal;
21 |
22 | public Animal getAnimal() {
23 | return animal;
24 | }
25 |
26 | public void setAnimal(Animal animal) {
27 | this.animal = animal;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/records/CarWithMultipleConstructorsAndCreator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022, 2024 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.records;
14 |
15 | import jakarta.json.bind.annotation.JsonbCreator;
16 | import jakarta.json.bind.annotation.JsonbProperty;
17 |
18 | public record CarWithMultipleConstructorsAndCreator(String type, String color) {
19 |
20 | @JsonbCreator
21 | public CarWithMultipleConstructorsAndCreator(@JsonbProperty("type") String type) {
22 | this(type, "red");
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/customization/model/InheritsNillableRecursion.java:
--------------------------------------------------------------------------------
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.customization.model;
14 |
15 | import java.lang.annotation.Retention;
16 | import java.lang.annotation.RetentionPolicy;
17 | import java.lang.annotation.Target;
18 |
19 | import static java.lang.annotation.ElementType.*;
20 |
21 | @InheritsNillable
22 | @Retention(RetentionPolicy.RUNTIME)
23 | @Target({ANNOTATION_TYPE, TYPE, PACKAGE})
24 | public @interface InheritsNillableRecursion {
25 | }
26 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/records/CarWithCreator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022, 2024 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.records;
14 |
15 | import jakarta.json.bind.annotation.JsonbCreator;
16 | import jakarta.json.bind.annotation.JsonbProperty;
17 |
18 | public record CarWithCreator(String type, String color) {
19 |
20 | @JsonbCreator
21 | public static CarWithCreator create(@JsonbProperty("type") String type, @JsonbProperty("color") String color) {
22 | return new CarWithCreator(type, color);
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/adapters/model/ReturnNullAdapter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, 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.adapters.model;
14 |
15 | import jakarta.json.bind.adapter.JsonbAdapter;
16 |
17 | public class ReturnNullAdapter implements JsonbAdapter {
18 | @Override
19 | public String adaptToJson(Number obj) throws Exception {
20 | return null;
21 | }
22 |
23 | @Override
24 | public Number adaptFromJson(String obj) throws Exception {
25 | return null;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/customization/model/FieldSpecificOrder.java:
--------------------------------------------------------------------------------
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.customization.model;
14 |
15 | import jakarta.json.bind.annotation.JsonbPropertyOrder;
16 |
17 | /**
18 | * @author David Kral
19 | */
20 | @JsonbPropertyOrder({"aField", "dField"})
21 | public class FieldSpecificOrder {
22 |
23 | public String aField = "aValue";
24 | public String dField = "dValue";
25 | public String bField = "bValue";
26 | public String cField = "cValue";
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/customization/model/JsonbNillableOverridesClass.java:
--------------------------------------------------------------------------------
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.customization.model;
14 |
15 | import jakarta.json.bind.annotation.JsonbNillable;
16 | import jakarta.json.bind.annotation.JsonbProperty;
17 |
18 | /**
19 | * @author Roman Grigoriadi
20 | */
21 | @JsonbNillable
22 | public class JsonbNillableOverridesClass extends JsonbNillableOverridesInterface {
23 | @JsonbProperty("overridesNillableInParent")
24 | public String nillableField;
25 | }
26 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/defaultmapping/generics/model/Circle.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, 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.defaultmapping.generics.model;
14 |
15 | /**
16 | * @author Roman Grigoriadi
17 | */
18 | public class Circle extends Shape {
19 | public Double radius;
20 |
21 | public Circle() {
22 | super();
23 | }
24 |
25 | public Double getRadius() {
26 | return radius;
27 | }
28 |
29 | public void setRadius(double radius) {
30 | this.radius = radius;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/defaultmapping/lambda/Cat.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019, 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.defaultmapping.lambda;
14 |
15 | /**
16 | * Class used to control serialization of lambda expression generated from functional interfaces with defaults.
17 | */
18 | public class Cat implements Pet {
19 |
20 | private String name;
21 |
22 | Cat(String name) {
23 | this.name = name;
24 | }
25 |
26 | @Override
27 | public String getName() {
28 | return this.name;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/customization/model/FieldOrderNameAnnotation.java:
--------------------------------------------------------------------------------
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.customization.model;
14 |
15 | import jakarta.json.bind.annotation.JsonbProperty;
16 |
17 | /**
18 | * @author David Kral
19 | */
20 | public class FieldOrderNameAnnotation {
21 |
22 | @JsonbProperty(value = "zField")
23 | public String aField = "aValue";
24 | public String dField = "dValue";
25 | public String bField = "bValue";
26 | public String cField = "cValue";
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/serializers/model/GenericPropertyPojo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019, 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.serializers.model;
14 |
15 | import jakarta.json.bind.annotation.JsonbTypeSerializer;
16 |
17 | @JsonbTypeSerializer(GenericPropertyPojoSerializer.class)
18 | public class GenericPropertyPojo {
19 | private T property;
20 |
21 | public T getProperty() {
22 | return property;
23 | }
24 |
25 | public void setProperty(T property) {
26 | this.property = property;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/customization/model/FieldCustomOrder.java:
--------------------------------------------------------------------------------
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.customization.model;
14 |
15 | import jakarta.json.bind.annotation.JsonbPropertyOrder;
16 |
17 | /**
18 | * @author David Kral
19 | */
20 | @JsonbPropertyOrder({"aField", "cField", "dField" ,"bField"})
21 | public class FieldCustomOrder {
22 |
23 | public String aField = "aValue";
24 | public String dField = "dValue";
25 | public String bField = "bValue";
26 | public String cField = "cValue";
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/defaultmapping/dates/model/ClassLevelDateAnnotationParent.java:
--------------------------------------------------------------------------------
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.defaultmapping.dates.model;
14 |
15 | import jakarta.json.bind.annotation.JsonbDateFormat;
16 | import java.time.LocalDateTime;
17 | import java.util.Date;
18 |
19 | /**
20 | * @author Roman Grigoriadi
21 | */
22 | @JsonbDateFormat("dd-MM-yyyy HH:mm:ss")
23 | public class ClassLevelDateAnnotationParent {
24 |
25 | public Date date;
26 |
27 | public LocalDateTime localDateTime;
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/defaultmapping/lambda/Robot.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019, 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.defaultmapping.lambda;
14 |
15 | /**
16 | * Class used to control serialization of lambda expression generated from functional interfaces with no defaults.
17 | */
18 | public class Robot implements Addressable {
19 |
20 | private String name;
21 |
22 | Robot(String name) {
23 | this.name = name;
24 | }
25 |
26 | @Override
27 | public String getName() {
28 | return this.name;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/serializers/model/AnnotatedGenericWithSerializerType.java:
--------------------------------------------------------------------------------
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.serializers.model;
14 |
15 | import jakarta.json.bind.annotation.JsonbTypeDeserializer;
16 | import jakarta.json.bind.annotation.JsonbTypeSerializer;
17 |
18 | @JsonbTypeSerializer(AnnotatedGenericWithSerializerTypeSerializer.class)
19 | @JsonbTypeDeserializer(AnnotatedGenericWithSerializerTypeDeserializer.class)
20 | public class AnnotatedGenericWithSerializerType {
21 |
22 | public T value;
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/org/eclipse/yasson/internal/deserializer/types/ByteDeserializer.java:
--------------------------------------------------------------------------------
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.deserializer.types;
14 |
15 | /**
16 | * Deserializer of the {@link Byte} type.
17 | */
18 | class ByteDeserializer extends AbstractNumberDeserializer {
19 |
20 | ByteDeserializer(TypeDeserializerBuilder builder) {
21 | super(builder, true);
22 | }
23 |
24 | @Override
25 | Byte parseNumberValue(String value) {
26 | return Byte.parseByte(value);
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/defaultmapping/generics/model/BoundedGenericClass.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, 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.defaultmapping.generics.model;
14 |
15 | import java.util.List;
16 | import java.util.Set;
17 |
18 | /**
19 | * @author Roman Grigoriadi
20 | */
21 | public class BoundedGenericClass, U> {
22 | public List extends U> upperBoundedList;
23 | public List super U> lowerBoundedList;
24 | public T boundedSet;
25 |
26 | public BoundedGenericClass() {
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/org/eclipse/yasson/internal/deserializer/types/FloatDeserializer.java:
--------------------------------------------------------------------------------
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.deserializer.types;
14 |
15 | /**
16 | * Deserializer of the {@link Float} type.
17 | */
18 | class FloatDeserializer extends AbstractNumberDeserializer {
19 |
20 | FloatDeserializer(TypeDeserializerBuilder builder) {
21 | super(builder, false);
22 | }
23 |
24 | @Override
25 | Float parseNumberValue(String value) {
26 | return Float.parseFloat(value);
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/org/eclipse/yasson/internal/deserializer/types/ShortDeserializer.java:
--------------------------------------------------------------------------------
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.deserializer.types;
14 |
15 | /**
16 | * Deserializer of the {@link Short} type.
17 | */
18 | class ShortDeserializer extends AbstractNumberDeserializer {
19 |
20 | ShortDeserializer(TypeDeserializerBuilder builder) {
21 | super(builder, true);
22 | }
23 |
24 | @Override
25 | Short parseNumberValue(String value) {
26 | return Short.parseShort(value);
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/customization/model/CollectionsWithFormatters.java:
--------------------------------------------------------------------------------
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.customization.model;
14 |
15 | import java.util.List;
16 |
17 | import jakarta.json.bind.annotation.JsonbNumberFormat;
18 |
19 | @JsonbNumberFormat(value = "000.000", locale = "en-us")
20 | public class CollectionsWithFormatters {
21 |
22 | public List doubleList;
23 |
24 | @JsonbNumberFormat(locale = "da-da")
25 | public List doubleList2;
26 |
27 | public List doubleList3;
28 | }
29 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/defaultmapping/dates/model/DateWithZonePojo.java:
--------------------------------------------------------------------------------
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.defaultmapping.dates.model;
14 |
15 | import java.util.Date;
16 |
17 | /**
18 | * @author Dennis Kriechel
19 | */
20 | public class DateWithZonePojo extends AbstractDateTimePojo {
21 |
22 | public DateWithZonePojo() {
23 | }
24 |
25 | public DateWithZonePojo(Date dateObj) {
26 | super(dateObj);
27 | this.dateWithZone = dateObj;
28 | }
29 |
30 | public Date dateWithZone;
31 | }
32 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/customization/model/InterfacedPojoAbsImpl.java:
--------------------------------------------------------------------------------
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.customization.model;
14 |
15 | /**
16 | * @author Roman Grigoriadi
17 | */
18 | public abstract class InterfacedPojoAbsImpl implements InterfacedPojoA {
19 |
20 | private String propertyA;
21 |
22 | @Override
23 | public String getPropertyA() {
24 | return propertyA;
25 | }
26 |
27 | @Override
28 | public void setPropertyA(String property) {
29 | this.propertyA = property;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/defaultmapping/generics/model/TreeContainer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 Red Hat, Inc. and/or its affiliates.
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.defaultmapping.generics.model;
14 |
15 | /**
16 | * @author James R. Perkins
17 | */
18 | public class TreeContainer> {
19 |
20 | private TreeTypeContainer tree;
21 |
22 | public TreeTypeContainer getTree() {
23 | return tree;
24 | }
25 |
26 | public void setTree(final TreeTypeContainer tree) {
27 | this.tree = tree;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/org/eclipse/yasson/internal/deserializer/types/DoubleDeserializer.java:
--------------------------------------------------------------------------------
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.deserializer.types;
14 |
15 | /**
16 | * Deserializer of the {@link Double} type.
17 | */
18 | class DoubleDeserializer extends AbstractNumberDeserializer {
19 |
20 | DoubleDeserializer(TypeDeserializerBuilder builder) {
21 | super(builder, false);
22 | }
23 |
24 | @Override
25 | Double parseNumberValue(String value) {
26 | return Double.parseDouble(value);
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/serializers/model/AnnotatedWithSerializerType.java:
--------------------------------------------------------------------------------
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.serializers.model;
14 |
15 | import jakarta.json.bind.annotation.JsonbTypeDeserializer;
16 | import jakarta.json.bind.annotation.JsonbTypeSerializer;
17 |
18 | /**
19 | * @author Roman Grigoriadi
20 | */
21 | @JsonbTypeSerializer(AnnotatedWithSerializerTypeSerializer.class)
22 | @JsonbTypeDeserializer(AnnotatedWithSerializerTypeDeserializer.class)
23 | public class AnnotatedWithSerializerType {
24 |
25 | public String value;
26 | }
27 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/customization/model/Dog.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019, 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.customization.model;
14 |
15 | public class Dog implements Animal {
16 |
17 | private String dogProperty;
18 |
19 | public Dog() {
20 | }
21 |
22 | public Dog(String dogProperty) {
23 | this.dogProperty = dogProperty;
24 | }
25 |
26 | public String getDogProperty() {
27 | return dogProperty;
28 | }
29 |
30 | public void setDogProperty(String dogProperty) {
31 | this.dogProperty = dogProperty;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/customization/model/InterfacedPojoImpl.java:
--------------------------------------------------------------------------------
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.customization.model;
14 |
15 | /**
16 | * @author Roman Grigoriadi
17 | */
18 | public class InterfacedPojoImpl extends InterfacedPojoAbsImpl implements InterfacedPojoB {
19 |
20 | private String propertyB;
21 |
22 | @Override
23 | public String getPropertyB() {
24 | return propertyB;
25 | }
26 |
27 | @Override
28 | public void setPropertyB(String propertyB) {
29 | this.propertyB = propertyB;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/org/eclipse/yasson/internal/serializer/types/LongSerializer.java:
--------------------------------------------------------------------------------
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.types;
14 |
15 | import jakarta.json.stream.JsonGenerator;
16 |
17 | /**
18 | * Serializer of the {@link Long} type.
19 | */
20 | class LongSerializer extends AbstractNumberSerializer {
21 |
22 | LongSerializer(TypeSerializerBuilder builder) {
23 | super(builder);
24 | }
25 |
26 | @Override
27 | void writeValue(Long value, JsonGenerator generator) {
28 | generator.write(value);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/adapters/model/NumberAdapter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, 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.adapters.model;
14 |
15 | import jakarta.json.bind.adapter.JsonbAdapter;
16 |
17 | public class NumberAdapter implements JsonbAdapter {
18 | @Override
19 | public String adaptToJson(Number obj) throws Exception {
20 | return Integer.valueOf(((Integer)obj) + 1).toString();
21 | }
22 |
23 | @Override
24 | public Number adaptFromJson(String obj) throws Exception {
25 | return Integer.parseInt(obj) - 1;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/org/eclipse/yasson/internal/serializer/types/ByteSerializer.java:
--------------------------------------------------------------------------------
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.types;
14 |
15 | import jakarta.json.stream.JsonGenerator;
16 |
17 | /**
18 | * Serializer of the {@link Byte} type.
19 | */
20 | class ByteSerializer extends AbstractNumberSerializer {
21 |
22 | ByteSerializer(TypeSerializerBuilder builder) {
23 | super(builder);
24 | }
25 |
26 | @Override
27 | void writeValue(Byte value, JsonGenerator generator) {
28 | generator.write(value);
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/org/eclipse/yasson/internal/serializer/types/DoubleSerializer.java:
--------------------------------------------------------------------------------
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.types;
14 |
15 | import jakarta.json.stream.JsonGenerator;
16 |
17 | /**
18 | * Serializer of the {@link Double} type.
19 | */
20 | class DoubleSerializer extends AbstractNumberSerializer {
21 |
22 | DoubleSerializer(TypeSerializerBuilder builder) {
23 | super(builder);
24 | }
25 |
26 | @Override
27 | void writeValue(Double value, JsonGenerator generator) {
28 | generator.write(value);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/org/eclipse/yasson/internal/serializer/types/ShortSerializer.java:
--------------------------------------------------------------------------------
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.types;
14 |
15 | import jakarta.json.stream.JsonGenerator;
16 |
17 | /**
18 | * Serializer of the {@link Short} type.
19 | */
20 | class ShortSerializer extends AbstractNumberSerializer {
21 |
22 | ShortSerializer(TypeSerializerBuilder builder) {
23 | super(builder);
24 | }
25 |
26 | @Override
27 | void writeValue(Short value, JsonGenerator generator) {
28 | generator.write(value);
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/defaultmapping/generics/model/WildcardMultipleBoundsClass.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, 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.defaultmapping.generics.model;
14 |
15 | import java.io.Serializable;
16 | import java.util.List;
17 |
18 | /**
19 | * @author Roman Grigoriadi
20 | */
21 | public class WildcardMultipleBoundsClass> {
22 |
23 | public T wildcardField;
24 |
25 | public GenericTestClass genericTestClassPropagatedWildCard;
26 |
27 | public List extends T> propagatedWildcardList;
28 | }
29 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/defaultmapping/inheritance/model/generics/SecondLevelGeneric.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, 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.defaultmapping.inheritance.model.generics;
14 |
15 | /**
16 | * @author Roman Grigoriadi
17 | */
18 | public class SecondLevelGeneric extends FirstLevelGeneric {
19 |
20 | private S inSecondLevel;
21 |
22 | public S getInSecondLevel() {
23 | return inSecondLevel;
24 | }
25 |
26 | public void setInSecondLevel(S inSecondLevel) {
27 | this.inSecondLevel = inSecondLevel;
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/serializers/model/NumberSerializer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, 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.serializers.model;
14 |
15 | import jakarta.json.bind.serializer.JsonbSerializer;
16 | import jakarta.json.bind.serializer.SerializationContext;
17 | import jakarta.json.stream.JsonGenerator;
18 |
19 | public class NumberSerializer implements JsonbSerializer {
20 | @Override
21 | public void serialize(Number obj, JsonGenerator generator, SerializationContext ctx) {
22 | generator.write(Integer.valueOf(obj.intValue() + 1).toString());
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/customization/model/InheritsNillable.java:
--------------------------------------------------------------------------------
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.customization.model;
14 |
15 | import jakarta.json.bind.annotation.JsonbNillable;
16 | import java.lang.annotation.Retention;
17 | import java.lang.annotation.RetentionPolicy;
18 | import java.lang.annotation.Target;
19 |
20 | import static java.lang.annotation.ElementType.*;
21 |
22 | @JsonbNillable()
23 | @Retention(RetentionPolicy.RUNTIME)
24 | @Target({ANNOTATION_TYPE, TYPE, PACKAGE})
25 | public @interface InheritsNillable {
26 | String value() default "abc";
27 | }
28 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/defaultmapping/specific/model/OptionalWrapper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019, 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.defaultmapping.specific.model;
14 |
15 | import java.util.Optional;
16 |
17 | /**
18 | * @author Roman Grigoriadi
19 | */
20 | public class OptionalWrapper {
21 |
22 | private Optional streetOptional;
23 |
24 | public Optional getStreetOptional() {
25 | return streetOptional;
26 | }
27 |
28 | public void setStreetOptional(Optional streetOptional) {
29 | this.streetOptional = streetOptional;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/internal/cdi/MockJndiContextFactory.java:
--------------------------------------------------------------------------------
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.cdi;
14 |
15 | import javax.naming.Context;
16 | import javax.naming.NamingException;
17 | import javax.naming.spi.InitialContextFactory;
18 | import java.util.Hashtable;
19 |
20 | /**
21 | * @author Roman Grigoriadi
22 | */
23 | public class MockJndiContextFactory implements InitialContextFactory {
24 | @Override
25 | public Context getInitialContext(Hashtable, ?> environment) throws NamingException {
26 | return new MockJndiContext();
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/internal/cdi/NonCdiAdapter.java:
--------------------------------------------------------------------------------
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.cdi;
14 |
15 | import jakarta.json.bind.adapter.JsonbAdapter;
16 |
17 | /**
18 | * @author Roman Grigoriadi
19 | */
20 | public class NonCdiAdapter implements JsonbAdapter {
21 | @Override
22 | public Integer adaptToJson(String obj) throws Exception {
23 | return Integer.valueOf(obj);
24 | }
25 |
26 | @Override
27 | public String adaptFromJson(Integer obj) throws Exception {
28 | return String.valueOf(obj);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/org/eclipse/yasson/internal/serializer/types/IntegerSerializer.java:
--------------------------------------------------------------------------------
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.types;
14 |
15 | import jakarta.json.stream.JsonGenerator;
16 |
17 | /**
18 | * Serializer of the {@link Integer} type.
19 | */
20 | class IntegerSerializer extends AbstractNumberSerializer {
21 |
22 | IntegerSerializer(TypeSerializerBuilder builder) {
23 | super(builder);
24 | }
25 |
26 | @Override
27 | void writeValue(Integer value, JsonGenerator generator) {
28 | generator.write(value);
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/defaultmapping/generics/model/ScalarValueWrapper.java:
--------------------------------------------------------------------------------
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.defaultmapping.generics.model;
14 |
15 | /**
16 | * @author Roman Grigoriadi
17 | */
18 | public class ScalarValueWrapper {
19 |
20 | private T value;
21 |
22 | public ScalarValueWrapper() {
23 | }
24 |
25 | public ScalarValueWrapper(T value) {
26 | this.value = value;
27 | }
28 |
29 | public T getValue() {
30 | return value;
31 | }
32 |
33 | public void setValue(T value) {
34 | this.value = value;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/internal/cdi/AdaptedPojo.java:
--------------------------------------------------------------------------------
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.cdi;
14 |
15 | import jakarta.json.bind.annotation.JsonbTypeAdapter;
16 |
17 | /**
18 | * @author Roman Grigoriadi
19 | */
20 |
21 | public class AdaptedPojo {
22 |
23 | @JsonbTypeAdapter(CdiDependentAdapter.class)
24 | public String adaptedValue1 = "1111";
25 |
26 | @JsonbTypeAdapter(CdiDependentAdapter.class)
27 | public String adaptedValue2 = "1001";
28 |
29 | @JsonbTypeAdapter(NonCdiAdapter.class)
30 | public String adaptedValue3 = "1010";
31 |
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/internal/cdi/MockInjectionTargetFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 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.cdi;
14 |
15 | import jakarta.enterprise.inject.spi.Bean;
16 | import jakarta.enterprise.inject.spi.InjectionTarget;
17 | import jakarta.enterprise.inject.spi.InjectionTargetFactory;
18 |
19 | /**
20 | * TODO javadoc
21 | */
22 | public class MockInjectionTargetFactory implements InjectionTargetFactory {
23 | @Override
24 | public InjectionTarget createInjectionTarget(Bean bean) {
25 | return (InjectionTarget) new MockInjectionTarget();
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/serializers/model/BoxWithAnnotations.java:
--------------------------------------------------------------------------------
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.serializers.model;
14 |
15 | import jakarta.json.bind.annotation.JsonbTypeDeserializer;
16 | import jakarta.json.bind.annotation.JsonbTypeSerializer;
17 |
18 | /**
19 | * @author Roman Grigoriadi
20 | */
21 | public class BoxWithAnnotations {
22 |
23 | public String boxStr;
24 |
25 | @JsonbTypeSerializer(CrateSerializerWithConversion.class)
26 | @JsonbTypeDeserializer(CrateDeserializer.class)
27 | public Crate crate;
28 |
29 |
30 | public String secondBoxStr;
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/org/eclipse/yasson/internal/deserializer/types/BigDecimalDeserializer.java:
--------------------------------------------------------------------------------
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.deserializer.types;
14 |
15 | import java.math.BigDecimal;
16 |
17 | /**
18 | * Deserializer of the {@link BigDecimal} type.
19 | */
20 | class BigDecimalDeserializer extends AbstractNumberDeserializer {
21 |
22 | BigDecimalDeserializer(TypeDeserializerBuilder builder) {
23 | super(builder, false);
24 | }
25 |
26 | @Override
27 | BigDecimal parseNumberValue(String value) {
28 | return new BigDecimal(value);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/org/eclipse/yasson/internal/deserializer/types/BigIntegerDeserializer.java:
--------------------------------------------------------------------------------
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.deserializer.types;
14 |
15 | import java.math.BigInteger;
16 |
17 | /**
18 | * Deserializer of the {@link BigInteger} type.
19 | */
20 | class BigIntegerDeserializer extends AbstractNumberDeserializer {
21 |
22 | BigIntegerDeserializer(TypeDeserializerBuilder builder) {
23 | super(builder, true);
24 | }
25 |
26 | @Override
27 | BigInteger parseNumberValue(String value) {
28 | return new BigInteger(value);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/adapters/model/SerializableAdapter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, 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.adapters.model;
14 |
15 | import jakarta.json.bind.adapter.JsonbAdapter;
16 | import java.io.Serializable;
17 |
18 | public class SerializableAdapter implements JsonbAdapter {
19 | @Override
20 | public Integer adaptToJson(Serializable obj) throws Exception {
21 | return Integer.valueOf(obj.toString()) + 1;
22 | }
23 |
24 | @Override
25 | public Serializable adaptFromJson(Integer obj) throws Exception {
26 | return obj - 1;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/defaultmapping/dates/model/DatePojo.java:
--------------------------------------------------------------------------------
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.defaultmapping.dates.model;
14 |
15 | import jakarta.json.bind.annotation.JsonbDateFormat;
16 | import java.util.Date;
17 |
18 | /**
19 | * @author Roman Grigoriadi
20 | */
21 | public class DatePojo extends AbstractDateTimePojo {
22 |
23 | public DatePojo() {
24 | }
25 |
26 | public DatePojo(Date dateObj) {
27 | super(dateObj);
28 | this.customDate = dateObj;
29 | }
30 |
31 | @JsonbDateFormat("HH:mm:ss | dd-MM-yyyy")
32 | public Date customDate;
33 | }
34 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/serializers/model/CrateInner.java:
--------------------------------------------------------------------------------
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.serializers.model;
14 |
15 | import jakarta.json.bind.annotation.JsonbDateFormat;
16 | import jakarta.json.bind.annotation.JsonbProperty;
17 | import java.math.BigDecimal;
18 | import java.util.Date;
19 |
20 | /**
21 | * @author Roman Grigoriadi
22 | */
23 | @JsonbDateFormat("dd.MM.yyyy || HH:mm:ss")
24 | public class CrateInner {
25 |
26 | @JsonbProperty("crate_inner_str")
27 | public String crateInnerStr;
28 |
29 | public BigDecimal crateInnerBigDec;
30 |
31 | public Date date;
32 | }
33 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/serializers/model/NumberDeserializer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2018, 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.serializers.model;
14 |
15 | import jakarta.json.bind.serializer.DeserializationContext;
16 | import jakarta.json.bind.serializer.JsonbDeserializer;
17 | import jakarta.json.stream.JsonParser;
18 | import java.lang.reflect.Type;
19 |
20 | public class NumberDeserializer implements JsonbDeserializer {
21 | @Override
22 | public Number deserialize(JsonParser parser, DeserializationContext ctx, Type rtType) {
23 | return Integer.valueOf(parser.getString()) - 1;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/serializers/model/SimpleContainer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, 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 | /*
14 | * $Id$
15 | */
16 |
17 | package org.eclipse.yasson.serializers.model;
18 |
19 |
20 |
21 | public class SimpleContainer {
22 | private String instance = "Test";
23 |
24 | public SimpleContainer() {
25 | }
26 |
27 | public SimpleContainer(String instance) {
28 | this.instance = instance;
29 | }
30 |
31 | public String getInstance() {
32 | return instance;
33 | }
34 |
35 | public void setInstance(String instance) {
36 | this.instance = instance;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/serializers/model/StringPaddingSerializer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019, 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.serializers.model;
14 |
15 | import jakarta.json.bind.serializer.JsonbSerializer;
16 | import jakarta.json.bind.serializer.SerializationContext;
17 | import jakarta.json.stream.JsonGenerator;
18 |
19 | /**
20 | * @author Roman Grigoriadi
21 | */
22 | public class StringPaddingSerializer implements JsonbSerializer {
23 | @Override
24 | public void serialize(String obj, JsonGenerator generator, SerializationContext ctx) {
25 | generator.write(" "+obj);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/org/eclipse/yasson/internal/model/ReverseTreeMap.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, 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.model;
14 |
15 | import java.util.Comparator;
16 | import java.util.TreeMap;
17 |
18 | /**
19 | * TreeMap with a reverse ordering by default.
20 | *
21 | * @param comparable key
22 | * @param value
23 | */
24 | public class ReverseTreeMap, V> extends TreeMap {
25 |
26 | /**
27 | * Default constructor of a TreeMap with reverse order.
28 | */
29 | public ReverseTreeMap() {
30 | super(Comparator.reverseOrder());
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/adapters/model/FirstNameAdapter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019, 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.adapters.model;
14 |
15 | import jakarta.json.Json;
16 | import jakarta.json.JsonValue;
17 | import jakarta.json.bind.adapter.JsonbAdapter;
18 |
19 | public class FirstNameAdapter implements JsonbAdapter {
20 | @Override
21 | public JsonValue adaptToJson(String firstName) {
22 | return Json.createValue(firstName.subSequence(0,1).toString());
23 | }
24 | @Override
25 | public String adaptFromJson(JsonValue json) {
26 | return json.toString();
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/customization/model/JsonbNillableClassFirstLevel.java:
--------------------------------------------------------------------------------
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.customization.model;
14 |
15 | /**
16 | * Implements a class with nillable annotation.
17 | *
18 | * @author Roman Grigoriadi
19 | */
20 | public class JsonbNillableClassFirstLevel implements JsonbNillableInterfaceBaseOne {
21 |
22 | private String classNillable;
23 |
24 | public String getClassNillable() {
25 | return classNillable;
26 | }
27 |
28 | public void setClassNillable(String classNillable) {
29 | this.classNillable = classNillable;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/yasson-jmh/src/main/java/org/eclipse/yasson/jmh/TenPropertySerializationTest.java:
--------------------------------------------------------------------------------
1 | package org.eclipse.yasson.jmh;
2 |
3 | import org.eclipse.yasson.jmh.model.TenPropertyData;
4 | import org.openjdk.jmh.annotations.*;
5 |
6 | import jakarta.json.bind.*;
7 | import java.util.List;
8 | import java.util.concurrent.TimeUnit;
9 |
10 | /**
11 | * Test for serializing a pojo with 10 properties
12 | */
13 | @BenchmarkMode(Mode.Throughput)
14 | @Timeout(time = 20)
15 | @State(Scope.Benchmark)
16 | @Warmup(iterations = 3)
17 | @OutputTimeUnit(TimeUnit.MILLISECONDS)
18 | public class TenPropertySerializationTest {
19 | private Jsonb json;
20 | private TenPropertyData testData;
21 |
22 | @Setup
23 | public void setup() {
24 | json = JsonbBuilder.create();
25 | testData = new TenPropertyData("prop1", "prop2", 42, 3.14, new String[] {"props", "propsss", "psssss"},
26 | List.of(5, 1, 3), "prop7", 800, new int[] {5555, 6666, 7777, 8888}, Long.MAX_VALUE);
27 | }
28 |
29 | @Benchmark
30 | public String testSerialize() {
31 | return json.toJson(testData);
32 | }
33 | }
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/defaultmapping/dates/model/InstantPojo.java:
--------------------------------------------------------------------------------
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.defaultmapping.dates.model;
14 |
15 | import jakarta.json.bind.annotation.JsonbDateFormat;
16 | import java.time.Instant;
17 |
18 | /**
19 | * @author Roman Grigoriadi
20 | */
21 | public class InstantPojo extends AbstractDateTimePojo {
22 |
23 | public InstantPojo() {
24 | }
25 |
26 | public InstantPojo(Instant dateObj) {
27 | super(dateObj);
28 | this.instant = dateObj;
29 | }
30 |
31 | @JsonbDateFormat("HH:mm:ss | dd-MM-yyyy")
32 | public Instant instant;
33 | }
34 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/defaultmapping/dates/model/LocalTimePojo.java:
--------------------------------------------------------------------------------
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.defaultmapping.dates.model;
14 |
15 | import jakarta.json.bind.annotation.JsonbDateFormat;
16 | import java.time.LocalTime;
17 |
18 | /**
19 | * @author Roman Grigoriadi
20 | */
21 | public class LocalTimePojo extends AbstractDateTimePojo {
22 |
23 | public LocalTimePojo() {
24 | }
25 |
26 | public LocalTimePojo(LocalTime date) {
27 | super(date);
28 | this.localTime = date;
29 | }
30 |
31 | @JsonbDateFormat("HH:mm:ss")
32 | public LocalTime localTime;
33 | }
34 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/adapters/model/FooSerializer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019, 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.adapters.model;
14 |
15 | import jakarta.json.bind.serializer.JsonbSerializer;
16 | import jakarta.json.bind.serializer.SerializationContext;
17 | import jakarta.json.stream.JsonGenerator;
18 |
19 | public class FooSerializer implements JsonbSerializer{
20 |
21 | @Override
22 | public void serialize(Foo obj, JsonGenerator generator, SerializationContext ctx) {
23 | generator.writeStartObject();
24 | generator.write("bar", obj.getBar());
25 | generator.writeEnd();
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/defaultmapping/generics/model/MultipleBoundsContainer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, 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 | /*
14 | * $Id$
15 | */
16 |
17 | package org.eclipse.yasson.defaultmapping.generics.model;
18 |
19 | import java.util.List;
20 | import java.util.Queue;
21 |
22 | public class MultipleBoundsContainer implements TypeContainer> {
23 | protected List instance;
24 |
25 | @Override
26 | public List getInstance() {
27 | return instance;
28 | }
29 |
30 | @Override
31 | public void setInstance(List instance) {
32 | this.instance = instance;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/defaultmapping/inheritance/model/PartialOverride.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019, 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.defaultmapping.inheritance.model;
14 |
15 | /**
16 | * Bias property is not readable by putting field and getter in other class than setter.
17 | *
18 | * @author Roman Grigoriadi
19 | */
20 | public class PartialOverride extends PartialOverrideBase {
21 |
22 | @Override
23 | public void setIntValue(int intValue) {
24 | super.setIntValue(intValue);
25 | }
26 |
27 | @Override
28 | public void setStrValue(String strValue) {
29 | super.setStrValue(strValue);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/internal/cdi/Hello1.java:
--------------------------------------------------------------------------------
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.cdi;
14 |
15 | import jakarta.enterprise.inject.Default;
16 | import jakarta.inject.Qualifier;
17 | import java.lang.annotation.ElementType;
18 | import java.lang.annotation.Retention;
19 | import java.lang.annotation.RetentionPolicy;
20 | import java.lang.annotation.Target;
21 |
22 | /**
23 | * @author Roman Grigoriadi
24 | */
25 | @Default
26 | @Qualifier
27 | @Target({ElementType.TYPE, ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD})
28 | @Retention(RetentionPolicy.RUNTIME)
29 | public @interface Hello1 {
30 | }
31 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/internal/cdi/Hello2.java:
--------------------------------------------------------------------------------
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.cdi;
14 |
15 | import jakarta.enterprise.inject.Default;
16 | import jakarta.inject.Qualifier;
17 | import java.lang.annotation.ElementType;
18 | import java.lang.annotation.Retention;
19 | import java.lang.annotation.RetentionPolicy;
20 | import java.lang.annotation.Target;
21 |
22 | /**
23 | * @author Roman Grigoriadi
24 | */
25 | @Default
26 | @Qualifier
27 | @Target({ElementType.TYPE, ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD})
28 | @Retention(RetentionPolicy.RUNTIME)
29 | public @interface Hello2 {
30 | }
31 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/adapters/model/UUIDMapperClsBased.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019, 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.adapters.model;
14 |
15 | import java.util.Optional;
16 | import java.util.UUID;
17 |
18 | public class UUIDMapperClsBased extends MultilevelAdapterClass {
19 |
20 | @Override
21 | public String adaptToJson(UUID obj) throws Exception {
22 | return Optional.ofNullable(obj).map(UUID::toString).orElse(null);
23 | }
24 |
25 | @Override
26 | public UUID adaptFromJson(String obj) throws Exception {
27 | return Optional.ofNullable(obj).map(UUID::fromString).orElse(null);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/adapters/model/UUIDMapperIfcBased.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019, 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.adapters.model;
14 |
15 | import java.util.Optional;
16 | import java.util.UUID;
17 |
18 | public class UUIDMapperIfcBased implements MultiinterfaceAdapter {
19 |
20 | @Override
21 | public String adaptToJson(UUID obj) throws Exception {
22 | return Optional.ofNullable(obj).map(UUID::toString).orElse(null);
23 | }
24 |
25 | @Override
26 | public UUID adaptFromJson(String obj) throws Exception {
27 | return Optional.ofNullable(obj).map(UUID::fromString).orElse(null);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/defaultmapping/anonymous/OuterPojo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, 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.defaultmapping.anonymous;
14 |
15 | /**
16 | * Test class.
17 | *
18 | * @author Dmitry Kornilov
19 | */
20 | public class OuterPojo {
21 | private Integer id = 1;
22 | private String name;
23 |
24 | public Integer getId() {
25 | return id;
26 | }
27 |
28 | public void setId(Integer id) {
29 | this.id = id;
30 | }
31 |
32 | public String getName() {
33 | return name;
34 | }
35 |
36 | public void setName(String name) {
37 | this.name = name;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/defaultmapping/dates/model/LocalDatePojo.java:
--------------------------------------------------------------------------------
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.defaultmapping.dates.model;
14 |
15 | import jakarta.json.bind.annotation.JsonbDateFormat;
16 | import java.time.LocalDate;
17 |
18 | /**
19 | * @author Roman Grigoriadi
20 | */
21 | public class LocalDatePojo extends AbstractDateTimePojo {
22 |
23 | public LocalDatePojo() {
24 | }
25 |
26 | public LocalDatePojo(LocalDate date) {
27 | super(date);
28 | this.customLocalDate = date;
29 | }
30 |
31 | @JsonbDateFormat("dd-MM-yyyy")
32 | public LocalDate customLocalDate;
33 | }
34 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/defaultmapping/dates/model/OffsetTimePojo.java:
--------------------------------------------------------------------------------
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.defaultmapping.dates.model;
14 |
15 | import jakarta.json.bind.annotation.JsonbDateFormat;
16 | import java.time.OffsetTime;
17 |
18 | /**
19 | * @author Roman Grigoriadi
20 | */
21 | public class OffsetTimePojo extends AbstractDateTimePojo {
22 |
23 | public OffsetTimePojo() {
24 | }
25 |
26 | public OffsetTimePojo(OffsetTime date) {
27 | super(date);
28 | this.offsetTime = date;
29 | }
30 |
31 | @JsonbDateFormat("HH:mm:ssZ")
32 | public OffsetTime offsetTime;
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/org/eclipse/yasson/internal/serializer/types/BigDecimalSerializer.java:
--------------------------------------------------------------------------------
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.types;
14 |
15 | import java.math.BigDecimal;
16 |
17 | import jakarta.json.stream.JsonGenerator;
18 |
19 | /**
20 | * Serializer of the {@link BigDecimal} type.
21 | */
22 | class BigDecimalSerializer extends AbstractNumberSerializer {
23 |
24 | BigDecimalSerializer(TypeSerializerBuilder builder) {
25 | super(builder);
26 | }
27 |
28 | @Override
29 | void writeValue(BigDecimal value, JsonGenerator generator) {
30 | generator.write(value);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/org/eclipse/yasson/internal/serializer/types/BigIntegerSerializer.java:
--------------------------------------------------------------------------------
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.types;
14 |
15 | import java.math.BigInteger;
16 |
17 | import jakarta.json.stream.JsonGenerator;
18 |
19 | /**
20 | * Serializer of the {@link BigInteger} type.
21 | */
22 | class BigIntegerSerializer extends AbstractNumberSerializer {
23 |
24 | BigIntegerSerializer(TypeSerializerBuilder builder) {
25 | super(builder);
26 | }
27 |
28 | @Override
29 | void writeValue(BigInteger value, JsonGenerator generator) {
30 | generator.write(value);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/customization/model/packagelevelannotations/JsonbNillablePackageLevel.java:
--------------------------------------------------------------------------------
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.customization.model.packagelevelannotations;
14 |
15 | /**
16 | * @author Roman Grigoriadi
17 | */
18 | public class JsonbNillablePackageLevel {
19 |
20 | private String packageLevelNillableField;
21 |
22 | public String getPackageLevelNillableField() {
23 | return packageLevelNillableField;
24 | }
25 |
26 | public void setPackageLevelNillableField(String packageLevelNillableField) {
27 | this.packageLevelNillableField = packageLevelNillableField;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/jsonstructure/InnerPojo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019, 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.jsonstructure;
14 |
15 | public final class InnerPojo {
16 | private String innerFirst;
17 | private String innerSecond;
18 |
19 | public String getInnerFirst() {
20 | return innerFirst;
21 | }
22 |
23 | public void setInnerFirst(String innerFirst) {
24 | this.innerFirst = innerFirst;
25 | }
26 |
27 | public String getInnerSecond() {
28 | return innerSecond;
29 | }
30 |
31 | public void setInnerSecond(String innerSecond) {
32 | this.innerSecond = innerSecond;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/org/eclipse/yasson/internal/serializer/types/NumberSerializer.java:
--------------------------------------------------------------------------------
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.types;
14 |
15 | import java.math.BigDecimal;
16 |
17 | import jakarta.json.stream.JsonGenerator;
18 |
19 | /**
20 | * Serializer of the {@link Number} type.
21 | */
22 | class NumberSerializer extends AbstractNumberSerializer {
23 |
24 | NumberSerializer(TypeSerializerBuilder builder) {
25 | super(builder);
26 | }
27 |
28 | @Override
29 | void writeValue(Number value, JsonGenerator generator) {
30 | generator.write(new BigDecimal(String.valueOf(value)));
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/customization/model/InheritsJsonbProperty.java:
--------------------------------------------------------------------------------
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.customization.model;
14 |
15 | import jakarta.json.bind.annotation.JsonbProperty;
16 | import java.lang.annotation.ElementType;
17 | import java.lang.annotation.Retention;
18 | import java.lang.annotation.RetentionPolicy;
19 | import java.lang.annotation.Target;
20 |
21 | @JsonbProperty("renamedProperty")
22 | @Retention(RetentionPolicy.RUNTIME)
23 | @Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER})
24 | public @interface InheritsJsonbProperty {
25 | String value() default "abc";
26 | }
27 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/customization/model/JsonbNillableClassSecondLevel.java:
--------------------------------------------------------------------------------
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.customization.model;
14 |
15 | /**
16 | * Extends a class which implements interface which is nillable.
17 | *
18 | * @author Roman Grigoriadi
19 | */
20 | public class JsonbNillableClassSecondLevel extends JsonbNillableClassFirstLevel {
21 |
22 | private String subclassNillable;
23 |
24 | public String getSubclassNillable() {
25 | return subclassNillable;
26 | }
27 |
28 | public void setSubclassNillable(String subclassNillable) {
29 | this.subclassNillable = subclassNillable;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/defaultmapping/dates/model/CalendarPojo.java:
--------------------------------------------------------------------------------
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.defaultmapping.dates.model;
14 |
15 | import jakarta.json.bind.annotation.JsonbDateFormat;
16 | import java.util.Calendar;
17 |
18 | /**
19 | * @author Roman Grigoriadi
20 | */
21 | public class CalendarPojo extends AbstractDateTimePojo {
22 |
23 | public CalendarPojo() {
24 | }
25 |
26 | public CalendarPojo(Calendar dateObj) {
27 | super(dateObj);
28 | this.customCalendar = dateObj;
29 | }
30 |
31 | @JsonbDateFormat("HH:mm:ss | dd-MM-yyyy, Z")
32 | public Calendar customCalendar;
33 | }
34 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/defaultmapping/basic/model/BigDecimalInNumber.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, 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.defaultmapping.basic.model;
14 |
15 | /**
16 | * Encapsulates Number type of field so the serialization and deserialization of number can be tested
17 | *
18 | * @author David Kral
19 | */
20 | public class BigDecimalInNumber {
21 |
22 | private Number bigDecValue;
23 |
24 | public BigDecimalInNumber(){
25 | }
26 |
27 | public Number getBigDecValue() {
28 | return bigDecValue;
29 | }
30 |
31 | public void setBigDecValue(Number bigDecValue) {
32 | this.bigDecValue = bigDecValue;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/org/eclipse/yasson/internal/deserializer/types/CharDeserializer.java:
--------------------------------------------------------------------------------
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.deserializer.types;
14 |
15 | import java.lang.reflect.Type;
16 |
17 | import org.eclipse.yasson.internal.DeserializationContextImpl;
18 |
19 | /**
20 | * Deserializer of the {@link Character} type.
21 | */
22 | class CharDeserializer extends TypeDeserializer {
23 |
24 | CharDeserializer(TypeDeserializerBuilder builder) {
25 | super(builder);
26 | }
27 |
28 | @Override
29 | Object deserializeStringValue(String value, DeserializationContextImpl context, Type rType) {
30 | return value.charAt(0);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/customization/model/JsonbNillableValue.java:
--------------------------------------------------------------------------------
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.customization.model;
14 |
15 | import jakarta.json.bind.annotation.JsonbNillable;
16 |
17 | /**
18 | * @author Roman Grigoriadi
19 | */
20 | @JsonbNillable
21 | public class JsonbNillableValue {
22 |
23 | private String nillableField;
24 |
25 | private String privateField;
26 |
27 | private static String staticField;
28 |
29 | public String getNillableField() {
30 | return nillableField;
31 | }
32 |
33 | public void setNillableField(String nillableField) {
34 | this.nillableField = nillableField;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/defaultmapping/inheritance/model/generics/AbstractZeroLevelGeneric.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, 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.defaultmapping.inheritance.model.generics;
14 |
15 | /**
16 | * @author Roman Grigoriadi
17 | */
18 | public abstract class AbstractZeroLevelGeneric {
19 |
20 | private Z inZero;
21 |
22 | protected ZF inZeroOverriddenInFirst;
23 |
24 | abstract ZF getInZeroOverriddenInFirst();
25 |
26 | abstract void setInZeroOverriddenInFirst(ZF value);
27 |
28 | public Z getInZero() {
29 | return inZero;
30 | }
31 |
32 | public void setInZero(Z inZero) {
33 | this.inZero = inZero;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/module-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, 2024 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 | /**
14 | * Yasson, the implementation of the Jakarta JSON Binding.
15 | */
16 | module org.eclipse.yasson {
17 | requires jakarta.json;
18 | requires jakarta.json.bind;
19 | requires java.logging;
20 | requires static java.xml;
21 | requires static java.naming;
22 | requires static java.sql;
23 | requires static java.desktop;
24 | requires static jakarta.cdi;
25 |
26 | exports org.eclipse.yasson;
27 | exports org.eclipse.yasson.spi;
28 | provides jakarta.json.bind.spi.JsonbProvider with org.eclipse.yasson.JsonBindingProvider;
29 | uses org.eclipse.yasson.spi.JsonbComponentInstanceCreator;
30 | }
31 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/customization/model/CreatorWithoutJavabeanProperty.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019, 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.customization.model;
14 |
15 | import jakarta.json.bind.annotation.JsonbCreator;
16 | import jakarta.json.bind.annotation.JsonbProperty;
17 |
18 | /**
19 | * @author Roman Grigoriadi
20 | */
21 | public class CreatorWithoutJavabeanProperty {
22 |
23 | private String strField;
24 |
25 | @JsonbCreator
26 | public CreatorWithoutJavabeanProperty(@JsonbProperty("s1") String s1, @JsonbProperty("s2") String s2) {
27 | this.strField = s1 + s2;
28 | }
29 |
30 | public String getStrField() {
31 | return strField;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/customization/transients/models/TransientGetterPlusCustomizationAnnotatedFieldContainer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019, 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.customization.transients.models;
14 |
15 | import jakarta.json.bind.annotation.JsonbProperty;
16 | import jakarta.json.bind.annotation.JsonbTransient;
17 |
18 | public class TransientGetterPlusCustomizationAnnotatedFieldContainer {
19 | @JsonbProperty("instance")
20 | private String instance;
21 |
22 | @JsonbTransient
23 | public String getInstance() {
24 | return instance;
25 | }
26 |
27 | public void setInstance(String instance) {
28 | this.instance = instance;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/defaultmapping/basic/model/BooleanModel.java:
--------------------------------------------------------------------------------
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.defaultmapping.basic.model;
14 |
15 | /**
16 | * Encapsulates different types of boolean values as a field so that the boolean value's serialization and
17 | * deserialization could be tested.
18 | *
19 | * @author Ehsan Zaery Moghaddam (zaerymoghaddam@gmail.com)
20 | */
21 | public class BooleanModel {
22 | public Boolean field1;
23 | public boolean field2;
24 |
25 | public BooleanModel() {
26 | }
27 |
28 | public BooleanModel(boolean field1, Boolean field2) {
29 | this.field2 = field2;
30 | this.field1 = field1;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/defaultmapping/dates/model/LocalDateTimePojo.java:
--------------------------------------------------------------------------------
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.defaultmapping.dates.model;
14 |
15 | import jakarta.json.bind.annotation.JsonbDateFormat;
16 | import java.time.LocalDateTime;
17 |
18 | /**
19 | * @author Roman Grigoriadi
20 | */
21 | public class LocalDateTimePojo extends AbstractDateTimePojo {
22 |
23 | public LocalDateTimePojo() {
24 | }
25 |
26 | public LocalDateTimePojo(LocalDateTime date) {
27 | super(date);
28 | this.customLocalDate = date;
29 | }
30 |
31 | @JsonbDateFormat("dd-MM-yyyy--ss:mm:HH")
32 | public LocalDateTime customLocalDate;
33 | }
34 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/defaultmapping/dates/model/OffsetDateTimePojo.java:
--------------------------------------------------------------------------------
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.defaultmapping.dates.model;
14 |
15 | import jakarta.json.bind.annotation.JsonbDateFormat;
16 | import java.time.OffsetDateTime;
17 |
18 | /**
19 | * @author Roman Grigoriadi
20 | */
21 | public class OffsetDateTimePojo extends AbstractDateTimePojo {
22 |
23 | public OffsetDateTimePojo() {
24 | }
25 |
26 | public OffsetDateTimePojo(OffsetDateTime date) {
27 | super(date);
28 | this.offsetDateTime = date;
29 | }
30 |
31 | @JsonbDateFormat("Z dd-MM-yyyy--ss:mm:HH")
32 | public OffsetDateTime offsetDateTime;
33 | }
34 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/defaultmapping/dates/model/ZonedDateTimePojo.java:
--------------------------------------------------------------------------------
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.defaultmapping.dates.model;
14 |
15 | import jakarta.json.bind.annotation.JsonbDateFormat;
16 | import java.time.ZonedDateTime;
17 |
18 | /**
19 | * @author Roman Grigoriadi
20 | */
21 | public class ZonedDateTimePojo extends AbstractDateTimePojo {
22 |
23 | public ZonedDateTimePojo() {
24 | }
25 |
26 | public ZonedDateTimePojo(ZonedDateTime date) {
27 | super(date);
28 | this.customZonedDate = date;
29 | }
30 |
31 | @JsonbDateFormat("XVV | dd-MM-yyyy--ss:mm:HH")
32 | public ZonedDateTime customZonedDate;
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/org/eclipse/yasson/internal/deserializer/types/UriDeserializer.java:
--------------------------------------------------------------------------------
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.deserializer.types;
14 |
15 | import java.lang.reflect.Type;
16 | import java.net.URI;
17 |
18 | import org.eclipse.yasson.internal.DeserializationContextImpl;
19 |
20 | /**
21 | * Deserializer of the {@link URI} type.
22 | */
23 | class UriDeserializer extends TypeDeserializer {
24 |
25 | UriDeserializer(TypeDeserializerBuilder builder) {
26 | super(builder);
27 | }
28 |
29 | @Override
30 | Object deserializeStringValue(String value, DeserializationContextImpl context, Type rType) {
31 | return URI.create(value);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/serializers/model/ContaineeSerializer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 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.serializers.model;
14 |
15 | import jakarta.json.bind.serializer.JsonbSerializer;
16 | import jakarta.json.bind.serializer.SerializationContext;
17 | import jakarta.json.stream.JsonGenerator;
18 |
19 | public class ContaineeSerializer implements JsonbSerializer {
20 |
21 | @Override
22 | public void serialize(Containee obj, JsonGenerator generator, SerializationContext ctx) {
23 | generator.writeStartObject();
24 | generator.write("key", obj.key);
25 | generator.write("value", obj.value);
26 | generator.writeEnd();
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/org/eclipse/yasson/internal/deserializer/types/UuidDeserializer.java:
--------------------------------------------------------------------------------
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.deserializer.types;
14 |
15 | import java.lang.reflect.Type;
16 | import java.util.UUID;
17 |
18 | import org.eclipse.yasson.internal.DeserializationContextImpl;
19 |
20 | /**
21 | * Deserializer of the {@link UUID} type.
22 | */
23 | class UuidDeserializer extends TypeDeserializer {
24 |
25 | UuidDeserializer(TypeDeserializerBuilder builder) {
26 | super(builder);
27 | }
28 |
29 | @Override
30 | Object deserializeStringValue(String value, DeserializationContextImpl context, Type rType) {
31 | return UUID.fromString(value);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/org/eclipse/yasson/internal/serializer/types/BooleanSerializer.java:
--------------------------------------------------------------------------------
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.types;
14 |
15 | import jakarta.json.stream.JsonGenerator;
16 |
17 | import org.eclipse.yasson.internal.SerializationContextImpl;
18 |
19 | /**
20 | * Serializer of the {@link Boolean} type.
21 | */
22 | class BooleanSerializer extends TypeSerializer {
23 |
24 | BooleanSerializer(TypeSerializerBuilder serializerBuilder) {
25 | super(serializerBuilder);
26 | }
27 |
28 | @Override
29 | void serializeValue(Boolean value, JsonGenerator generator, SerializationContextImpl context) {
30 | generator.write(value);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/org/eclipse/yasson/internal/deserializer/types/ZoneIdDeserializer.java:
--------------------------------------------------------------------------------
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.deserializer.types;
14 |
15 | import java.lang.reflect.Type;
16 | import java.time.ZoneId;
17 |
18 | import org.eclipse.yasson.internal.DeserializationContextImpl;
19 |
20 | /**
21 | * Deserializer of the {@link ZoneId} type.
22 | */
23 | class ZoneIdDeserializer extends TypeDeserializer {
24 |
25 | ZoneIdDeserializer(TypeDeserializerBuilder builder) {
26 | super(builder);
27 | }
28 |
29 | @Override
30 | Object deserializeStringValue(String value, DeserializationContextImpl context, Type rType) {
31 | return ZoneId.of(value);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/customization/model/CreatorMultipleDeclarationErrorPojo.java:
--------------------------------------------------------------------------------
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.customization.model;
14 |
15 | import jakarta.json.bind.annotation.JsonbCreator;
16 | import jakarta.json.bind.annotation.JsonbProperty;
17 |
18 | /**
19 | * @author Roman Grigoriadi
20 | */
21 | public class CreatorMultipleDeclarationErrorPojo {
22 |
23 | public String s1;
24 |
25 | @JsonbCreator
26 | public CreatorMultipleDeclarationErrorPojo(@JsonbProperty("val1") String s1) {
27 | this.s1 = s1;
28 | }
29 |
30 | @JsonbCreator
31 | public static CreatorMultipleDeclarationErrorPojo getInstance() {
32 | return null;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/defaultmapping/inheritance/model/PartialOverrideBase.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019, 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.defaultmapping.inheritance.model;
14 |
15 | /**
16 | * @author Roman Grigoriadi
17 | */
18 | public class PartialOverrideBase {
19 |
20 | private int intValue;
21 | private String strValue;
22 |
23 | public int getIntValue() {
24 | return intValue;
25 | }
26 |
27 | public void setIntValue(int intValue) {
28 | this.intValue = intValue;
29 | }
30 |
31 | public String getStrValue() {
32 | return strValue;
33 | }
34 |
35 | public void setStrValue(String strValue) {
36 | this.strValue = strValue;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/org/eclipse/yasson/internal/deserializer/types/PeriodDeserializer.java:
--------------------------------------------------------------------------------
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.deserializer.types;
14 |
15 | import java.lang.reflect.Type;
16 | import java.time.Period;
17 |
18 | import org.eclipse.yasson.internal.DeserializationContextImpl;
19 |
20 | /**
21 | * Deserializer of the {@link Period} type.
22 | */
23 | class PeriodDeserializer extends TypeDeserializer {
24 |
25 | PeriodDeserializer(TypeDeserializerBuilder builder) {
26 | super(builder);
27 | }
28 |
29 | @Override
30 | Object deserializeStringValue(String value, DeserializationContextImpl context, Type rType) {
31 | return Period.parse(value);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/defaultmapping/inheritance/model/PropertyOrderFirst.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019, 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.defaultmapping.inheritance.model;
14 |
15 | /**
16 | * @author Roman Grigoriadi
17 | */
18 | public class PropertyOrderFirst extends PropertyOrderZero {
19 |
20 | private String first;
21 |
22 | public String getFirst() {
23 | return first;
24 | }
25 |
26 | public void setFirst(String first) {
27 | this.first = first;
28 | }
29 |
30 | @Override
31 | public void setZeroPartiallyOverriddenInFirst(String zeroPartiallyOverriddenInFirst) {
32 | super.setZeroPartiallyOverriddenInFirst(zeroPartiallyOverriddenInFirst);
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/jsonstructure/InnerPojoSerializer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019, 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.jsonstructure;
14 |
15 | import jakarta.json.bind.serializer.JsonbSerializer;
16 | import jakarta.json.bind.serializer.SerializationContext;
17 | import jakarta.json.stream.JsonGenerator;
18 |
19 | public class InnerPojoSerializer implements JsonbSerializer {
20 |
21 | @Override
22 | public void serialize(InnerPojo obj, JsonGenerator generator, SerializationContext ctx) {
23 | generator.writeStartObject();
24 | generator.write("first", obj.getInnerFirst());
25 | generator.write("second", obj.getInnerSecond());
26 | generator.writeEnd();
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/org/eclipse/yasson/internal/deserializer/types/PathDeserializer.java:
--------------------------------------------------------------------------------
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.deserializer.types;
14 |
15 | import java.lang.reflect.Type;
16 | import java.nio.file.Paths;
17 |
18 | import org.eclipse.yasson.internal.DeserializationContextImpl;
19 |
20 | /**
21 | * Deserializer of the {@link java.nio.file.Path} type.
22 | */
23 | class PathDeserializer extends TypeDeserializer {
24 |
25 | PathDeserializer(TypeDeserializerBuilder builder) {
26 | super(builder);
27 | }
28 |
29 | @Override
30 | Object deserializeStringValue(String value, DeserializationContextImpl context, Type rType) {
31 | return Paths.get(value);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/adapters/model/Author.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019, 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.adapters.model;
14 |
15 | import jakarta.json.bind.annotation.JsonbTypeAdapter;
16 |
17 | public class Author {
18 | @JsonbTypeAdapter(FirstNameAdapter.class)
19 | private String firstName;
20 | private String lastName;
21 |
22 | public String getFirstName() {
23 | return firstName;
24 | }
25 |
26 | public void setFirstName(String firstName) {
27 | this.firstName = firstName;
28 | }
29 |
30 | public String getLastName() {
31 | return lastName;
32 | }
33 |
34 | public void setLastName(String lastName) {
35 | this.lastName = lastName;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/customization/transients/models/TransientSetterPlusCustomizationAnnotatedFieldContainer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, 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 | /*
14 | * $Id$
15 | */
16 |
17 | package org.eclipse.yasson.customization.transients.models;
18 |
19 |
20 | import jakarta.json.bind.annotation.JsonbProperty;
21 | import jakarta.json.bind.annotation.JsonbTransient;
22 |
23 | public class TransientSetterPlusCustomizationAnnotatedFieldContainer {
24 | @JsonbProperty("instance")
25 | private String instance;
26 |
27 | public String getInstance() {
28 | return instance;
29 | }
30 |
31 | @JsonbTransient
32 | public void setInstance(String instance) {
33 | this.instance = instance;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/defaultmapping/dates/model/ClassLevelDateAnnotation.java:
--------------------------------------------------------------------------------
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.defaultmapping.dates.model;
14 |
15 | import jakarta.json.bind.annotation.JsonbDateFormat;
16 | import java.time.ZonedDateTime;
17 | import java.util.Calendar;
18 |
19 | /**
20 | * @author Roman Grigoriadi
21 | */
22 | @JsonbDateFormat(value = "X z E MMMM dd-MM-yyyy HH:mm:ss", locale = "fr")
23 | public class ClassLevelDateAnnotation extends ClassLevelDateAnnotationParent {
24 |
25 | public ZonedDateTime zonedDateTime;
26 |
27 | public Calendar calendar;
28 |
29 | @JsonbDateFormat(value = JsonbDateFormat.DEFAULT_FORMAT)
30 | public ZonedDateTime defaultZoned;
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/org/eclipse/yasson/internal/deserializer/types/NumberDeserializer.java:
--------------------------------------------------------------------------------
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.deserializer.types;
14 |
15 | import java.lang.reflect.Type;
16 | import java.math.BigDecimal;
17 |
18 | import org.eclipse.yasson.internal.DeserializationContextImpl;
19 |
20 | /**
21 | * Deserializer of the {@link Number} type.
22 | */
23 | class NumberDeserializer extends TypeDeserializer {
24 |
25 | NumberDeserializer(TypeDeserializerBuilder builder) {
26 | super(builder);
27 | }
28 |
29 | @Override
30 | Object deserializeStringValue(String value, DeserializationContextImpl context, Type rType) {
31 | return new BigDecimal(value);
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/org/eclipse/yasson/internal/serializer/types/CharSerializer.java:
--------------------------------------------------------------------------------
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.types;
14 |
15 | import jakarta.json.stream.JsonGenerator;
16 |
17 | import org.eclipse.yasson.internal.SerializationContextImpl;
18 |
19 | /**
20 | * Serializer of the {@link Character} type.
21 | */
22 | class CharSerializer extends TypeSerializer {
23 |
24 | CharSerializer(TypeSerializerBuilder serializerBuilder) {
25 | super(serializerBuilder);
26 | }
27 |
28 | @Override
29 | void serializeValue(Character value, JsonGenerator generator, SerializationContextImpl context) {
30 | generator.write(String.valueOf(value));
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/org/eclipse/yasson/internal/serializer/types/FloatSerializer.java:
--------------------------------------------------------------------------------
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.types;
14 |
15 | import java.math.BigDecimal;
16 |
17 | import jakarta.json.stream.JsonGenerator;
18 |
19 | /**
20 | * Serializer of the {@link Float} type.
21 | */
22 | class FloatSerializer extends AbstractNumberSerializer {
23 |
24 | FloatSerializer(TypeSerializerBuilder builder) {
25 | super(builder);
26 | }
27 |
28 | @Override
29 | void writeValue(Float value, JsonGenerator generator) {
30 | //floats lose precision, after upcasting to doubles in jsonp
31 | generator.write(new BigDecimal(String.valueOf(value)));
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/defaultmapping/generics/model/LowerBoundTypeVariableWithCollectionAttributeClass.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, 2023 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.defaultmapping.generics.model;
14 |
15 | import java.util.Collection;
16 |
17 | /**
18 | * @author Alessandro Moscatelli
19 | */
20 | public class LowerBoundTypeVariableWithCollectionAttributeClass {
21 |
22 | private Collection> value;
23 |
24 | public Collection> getValue() {
25 | return value;
26 | }
27 |
28 | public void setValue(Collection> value) {
29 | this.value = value;
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/org/eclipse/yasson/ImplementationClass.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, 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;
14 |
15 | import java.lang.annotation.ElementType;
16 | import java.lang.annotation.Retention;
17 | import java.lang.annotation.RetentionPolicy;
18 | import java.lang.annotation.Target;
19 |
20 | /**
21 | * Marks an interface with implementation class, which should be used for deserialiation.
22 | */
23 | @Retention(RetentionPolicy.RUNTIME)
24 | @Target({ElementType.FIELD, ElementType.METHOD})
25 | public @interface ImplementationClass {
26 |
27 | /**
28 | * Class, which will be used as implementation for annotated member.
29 | *
30 | * @return Serializaer to use.
31 | */
32 | Class> value();
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/org/eclipse/yasson/internal/deserializer/types/EnumDeserializer.java:
--------------------------------------------------------------------------------
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.deserializer.types;
14 |
15 | import java.lang.reflect.Type;
16 |
17 | import org.eclipse.yasson.internal.DeserializationContextImpl;
18 |
19 | /**
20 | * Deserializer of the {@link Enum}.
21 | */
22 | class EnumDeserializer extends TypeDeserializer {
23 |
24 | EnumDeserializer(TypeDeserializerBuilder builder) {
25 | super(builder);
26 | }
27 |
28 | @SuppressWarnings("unchecked")
29 | @Override
30 | Object deserializeStringValue(String value, DeserializationContextImpl context, Type rType) {
31 | return Enum.valueOf((Class) rType, value);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/org/eclipse/yasson/internal/serializer/types/UriSerializer.java:
--------------------------------------------------------------------------------
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.types;
14 |
15 | import java.net.URI;
16 |
17 | import jakarta.json.stream.JsonGenerator;
18 |
19 | import org.eclipse.yasson.internal.SerializationContextImpl;
20 |
21 | /**
22 | * Serializer of the {@link URI} type.
23 | */
24 | class UriSerializer extends TypeSerializer {
25 |
26 | UriSerializer(TypeSerializerBuilder serializerBuilder) {
27 | super(serializerBuilder);
28 | }
29 |
30 | @Override
31 | void serializeValue(URI value, JsonGenerator generator, SerializationContextImpl context) {
32 | generator.write(value.toString());
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/org/eclipse/yasson/internal/serializer/types/UrlSerializer.java:
--------------------------------------------------------------------------------
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.types;
14 |
15 | import java.net.URL;
16 |
17 | import jakarta.json.stream.JsonGenerator;
18 |
19 | import org.eclipse.yasson.internal.SerializationContextImpl;
20 |
21 | /**
22 | * Serializer of the {@link URL} type.
23 | */
24 | class UrlSerializer extends TypeSerializer {
25 |
26 | UrlSerializer(TypeSerializerBuilder serializerBuilder) {
27 | super(serializerBuilder);
28 | }
29 |
30 | @Override
31 | void serializeValue(URL value, JsonGenerator generator, SerializationContextImpl context) {
32 | generator.write(value.toString());
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/org/eclipse/yasson/internal/deserializer/types/ZoneOffsetDeserializer.java:
--------------------------------------------------------------------------------
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.deserializer.types;
14 |
15 | import java.lang.reflect.Type;
16 | import java.time.ZoneOffset;
17 |
18 | import org.eclipse.yasson.internal.DeserializationContextImpl;
19 |
20 | /**
21 | * Deserializer of the {@link ZoneOffset} type.
22 | */
23 | class ZoneOffsetDeserializer extends TypeDeserializer {
24 |
25 | ZoneOffsetDeserializer(TypeDeserializerBuilder builder) {
26 | super(builder);
27 | }
28 |
29 | @Override
30 | Object deserializeStringValue(String value, DeserializationContextImpl context, Type rType) {
31 | return ZoneOffset.of(value);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/adapters/model/AdaptedPojo.java:
--------------------------------------------------------------------------------
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.adapters.model;
14 |
15 | import java.util.List;
16 | import java.util.Map;
17 |
18 | /**
19 | * @author Roman Grigoriadi
20 | */
21 | public class AdaptedPojo {
22 | public String strField;
23 | public Integer intField;
24 | public Box box;
25 | public GenericBox intBox;
26 | public GenericBox strBox;
27 | public GenericBox tBox;
28 | public List> tGenericBoxList;
29 | public List integerList;
30 | public List stringList;
31 | public Map stringIntegerMap;
32 | public Map tMap;
33 | public T tVar;
34 | }
35 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/defaultmapping/specific/model/StreetWithPrimitives.java:
--------------------------------------------------------------------------------
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.defaultmapping.specific.model;
14 |
15 | /**
16 | * @author Roman Grigoriadi
17 | */
18 | public class StreetWithPrimitives {
19 | private String name = "defaultName";
20 | private int number = 11;
21 |
22 | public StreetWithPrimitives() {
23 | }
24 |
25 | public String getName() {
26 | return name;
27 | }
28 |
29 | public void setName(String name) {
30 | this.name = name;
31 | }
32 |
33 | public int getNumber() {
34 | return number;
35 | }
36 |
37 | public void setNumber(int number) {
38 | this.number = number;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/org/eclipse/yasson/internal/deserializer/types/DurationDeserializer.java:
--------------------------------------------------------------------------------
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.deserializer.types;
14 |
15 | import java.lang.reflect.Type;
16 | import java.time.Duration;
17 |
18 | import org.eclipse.yasson.internal.DeserializationContextImpl;
19 |
20 | /**
21 | * Deserializer of the {@link Duration} type.
22 | */
23 | class DurationDeserializer extends TypeDeserializer {
24 |
25 | DurationDeserializer(TypeDeserializerBuilder builder) {
26 | super(builder);
27 | }
28 |
29 | @Override
30 | public Object deserializeStringValue(String value, DeserializationContextImpl context, Type rType) {
31 | return Duration.parse(value);
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/org/eclipse/yasson/internal/serializer/types/UuidSerializer.java:
--------------------------------------------------------------------------------
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.types;
14 |
15 | import java.util.UUID;
16 |
17 | import jakarta.json.stream.JsonGenerator;
18 |
19 | import org.eclipse.yasson.internal.SerializationContextImpl;
20 |
21 | /**
22 | * Serializer of the {@link UUID} type.
23 | */
24 | class UuidSerializer extends TypeSerializer {
25 |
26 | UuidSerializer(TypeSerializerBuilder serializerBuilder) {
27 | super(serializerBuilder);
28 | }
29 |
30 | @Override
31 | void serializeValue(UUID value, JsonGenerator generator, SerializationContextImpl context) {
32 | generator.write(value.toString());
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/adapters/model/FooAdapter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019, 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.adapters.model;
14 |
15 | import java.util.HashMap;
16 | import java.util.Map;
17 |
18 | import jakarta.json.bind.adapter.JsonbAdapter;
19 |
20 | public class FooAdapter implements JsonbAdapter>{
21 |
22 | @Override
23 | public Map adaptToJson(Foo obj) throws Exception {
24 | Map map = new HashMap<>();
25 | map.put("bar", obj.getBar());
26 | return map;
27 | }
28 |
29 | @Override
30 | public Foo adaptFromJson( Map obj) throws Exception {
31 | return new Foo(obj.get("bar").toString());
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/customization/model/packagelevelannotations/PackageLevelOverriddenWithClassLevel.java:
--------------------------------------------------------------------------------
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.customization.model.packagelevelannotations;
14 |
15 | import jakarta.json.bind.annotation.JsonbNillable;
16 |
17 | /**
18 | * @author Roman Grigoriadi
19 | */
20 | @JsonbNillable(false)
21 | public class PackageLevelOverriddenWithClassLevel {
22 |
23 | private String nillableOverriddenField;
24 |
25 | public String getNillableOverriddenField() {
26 | return nillableOverriddenField;
27 | }
28 |
29 | public void setNillableOverriddenField(String nillableOverriddenField) {
30 | this.nillableOverriddenField = nillableOverriddenField;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/customization/transients/models/TransientSetterPlusCustomizationAnnotatedGetterContainer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017, 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 | /*
14 | * $Id$
15 | */
16 |
17 | package org.eclipse.yasson.customization.transients.models;
18 |
19 |
20 | import jakarta.json.bind.annotation.JsonbProperty;
21 | import jakarta.json.bind.annotation.JsonbTransient;
22 |
23 | public class TransientSetterPlusCustomizationAnnotatedGetterContainer {
24 | private String instance = "INSTANCE";
25 |
26 | @JsonbProperty("instance")
27 | public String getInstance() {
28 | return instance;
29 | }
30 |
31 | @JsonbTransient
32 | public void setInstance(String instance) {
33 | this.instance = instance;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/test/java/org/eclipse/yasson/defaultmapping/generics/model/GenericTestClass.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015, 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.defaultmapping.generics.model;
14 |
15 | /**
16 | * Test class used in generics tests.
17 | *
18 | * @author Dmitry Kornilov
19 | */
20 | public class GenericTestClass {
21 | public T field1;
22 | public U field2;
23 |
24 | public GenericTestClass() {}
25 |
26 | public T getField1() {
27 | return field1;
28 | }
29 |
30 | public void setField1(T field1) {
31 | this.field1 = field1;
32 | }
33 |
34 | public U getField2() {
35 | return field2;
36 | }
37 |
38 | public void setField2(U field2) {
39 | this.field2 = field2;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/org/eclipse/yasson/internal/components/DefaultConstructorCreator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2016, 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.components;
14 |
15 | import java.io.IOException;
16 |
17 | import org.eclipse.yasson.internal.InstanceCreator;
18 | import org.eclipse.yasson.spi.JsonbComponentInstanceCreator;
19 |
20 | /**
21 | * Creates components instance with default constructor.
22 | */
23 | public class DefaultConstructorCreator implements JsonbComponentInstanceCreator {
24 |
25 | @Override
26 | public T getOrCreateComponent(Class componentClass) {
27 | return InstanceCreator.createInstance(componentClass);
28 | }
29 |
30 | @Override
31 | public void close() throws IOException {
32 |
33 | }
34 | }
35 |
--------------------------------------------------------------------------------