generated from micronaut-projects/micronaut-project-template
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move SimpleBuilderDeserializer into SpecificObjectDeserializer (#583)
This adds support for builders on subtypes.
- Loading branch information
Showing
6 changed files
with
108 additions
and
107 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
36 changes: 36 additions & 0 deletions
36
serde-jackson/src/test/java/io/micronaut/serde/jackson/builder/TestBuildSubtype.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,36 @@ | ||
package io.micronaut.serde.jackson.builder; | ||
|
||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
|
||
@JsonDeserialize(builder = TestBuildSubtype.Builder.class) | ||
public class TestBuildSubtype extends TestBuildSupertype { | ||
private final String bar; | ||
|
||
private TestBuildSubtype(String foo, String bar) { | ||
super(foo); | ||
this.bar = bar; | ||
} | ||
|
||
public String getBar() { | ||
return bar; | ||
} | ||
|
||
public static class Builder { | ||
private String foo; | ||
private String bar; | ||
|
||
public Builder foo(String foo) { | ||
this.foo = foo; | ||
return this; | ||
} | ||
|
||
public Builder bar(String bar) { | ||
this.bar = bar; | ||
return this; | ||
} | ||
|
||
public TestBuildSubtype build() { | ||
return new TestBuildSubtype(foo, bar); | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
serde-jackson/src/test/java/io/micronaut/serde/jackson/builder/TestBuildSupertype.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,23 @@ | ||
package io.micronaut.serde.jackson.builder; | ||
|
||
import com.fasterxml.jackson.annotation.JsonSubTypes; | ||
import com.fasterxml.jackson.annotation.JsonTypeInfo; | ||
|
||
@JsonSubTypes({ | ||
@JsonSubTypes.Type(value = TestBuildSubtype.class, name = "sub") | ||
}) | ||
@JsonTypeInfo( | ||
use = JsonTypeInfo.Id.NAME, | ||
include = JsonTypeInfo.As.WRAPPER_OBJECT | ||
) | ||
public abstract class TestBuildSupertype { | ||
private final String foo; | ||
|
||
TestBuildSupertype(String foo) { | ||
this.foo = foo; | ||
} | ||
|
||
public String getFoo() { | ||
return foo; | ||
} | ||
} |
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
98 changes: 0 additions & 98 deletions
98
...ort/src/main/java/io/micronaut/serde/support/deserializers/SimpleBuilderDeserializer.java
This file was deleted.
Oops, something went wrong.
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