-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#606] test case missing type deserializer
- Loading branch information
Showing
3 changed files
with
82 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Copyright (c) 2023, 2023 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0, | ||
* or the Eclipse Distribution License v. 1.0 which is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause | ||
*/ | ||
|
||
package org.eclipse.yasson.records; | ||
|
||
import java.util.UUID; | ||
|
||
record CarId(UUID value) { | ||
} |
40 changes: 40 additions & 0 deletions
40
src/test/java16/org/eclipse/yasson/records/CarWithUuidDeserializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright (c) 2023, 2023 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0, | ||
* or the Eclipse Distribution License v. 1.0 which is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause | ||
*/ | ||
|
||
package org.eclipse.yasson.records; | ||
|
||
import jakarta.json.bind.annotation.JsonbProperty; | ||
import jakarta.json.bind.annotation.JsonbTypeDeserializer; | ||
import jakarta.json.bind.serializer.DeserializationContext; | ||
import jakarta.json.bind.serializer.JsonbDeserializer; | ||
import jakarta.json.stream.JsonParser; | ||
|
||
import java.lang.reflect.Type; | ||
import java.util.UUID; | ||
|
||
public record CarWithUuidDeserializer( | ||
@JsonbProperty("car.id") @JsonbTypeDeserializer(CarUuidDeserializer.class) CarId carId, | ||
@JsonbProperty("colour") String colour | ||
) { | ||
public static class CarUuidDeserializer implements JsonbDeserializer<CarId> { | ||
|
||
@Override | ||
public CarId deserialize(JsonParser parser, DeserializationContext ctx, Type rtType) { | ||
String givenString = parser.getString(); | ||
var carUuid = UUID.fromString(givenString); | ||
|
||
return new CarId(carUuid); | ||
} | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters