forked from mbknor/mbknor-jackson-jsonSchema
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Proper handling of Polymorphic types when JsonTypeInfo.Id is DEDUCTION (
- Loading branch information
Showing
5 changed files
with
132 additions
and
19 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
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
21 changes: 21 additions & 0 deletions
21
src/test/scala/com/kjetland/jackson/jsonSchema/testData/polymorphism7/Child71.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,21 @@ | ||
package com.kjetland.jackson.jsonSchema.testData.polymorphism7; | ||
|
||
import java.util.Objects; | ||
|
||
public class Child71 extends Parent7 { | ||
public String firstName; | ||
|
||
@Override | ||
public boolean equals(final Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
if (!super.equals(o)) return false; | ||
final Child71 child71 = (Child71) o; | ||
return Objects.equals(firstName, child71.firstName); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(super.hashCode(), firstName); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/test/scala/com/kjetland/jackson/jsonSchema/testData/polymorphism7/Child72.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,22 @@ | ||
package com.kjetland.jackson.jsonSchema.testData.polymorphism7; | ||
|
||
import java.util.Objects; | ||
|
||
public class Child72 extends Parent7 { | ||
public String middleName; | ||
public String lastName; | ||
|
||
@Override | ||
public boolean equals(final Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
if (!super.equals(o)) return false; | ||
final Child72 child72 = (Child72) o; | ||
return Objects.equals(middleName, child72.middleName) && Objects.equals(lastName, child72.lastName); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(super.hashCode(), middleName, lastName); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/test/scala/com/kjetland/jackson/jsonSchema/testData/polymorphism7/Parent7.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,27 @@ | ||
package com.kjetland.jackson.jsonSchema.testData.polymorphism7; | ||
|
||
import java.util.Objects; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.annotation.JsonSubTypes; | ||
import com.fasterxml.jackson.annotation.JsonTypeInfo; | ||
|
||
@JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION, defaultImpl = Child71.class) | ||
@JsonSubTypes({@JsonSubTypes.Type(Child72.class), @JsonSubTypes.Type(Child71.class)}) | ||
abstract public class Parent7 { | ||
@JsonProperty(required = true) | ||
public Integer id; | ||
|
||
@Override | ||
public boolean equals(final Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
final Parent7 parent7 = (Parent7) o; | ||
return Objects.equals(id, parent7.id); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(id); | ||
} | ||
} |