Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#418 abstract json with generics and inheritance
- Loading branch information
Showing
9 changed files
with
92 additions
and
16 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
value-fixture/src/nonimmutables/recurs/AbstractMySomethingContent.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,8 @@ | ||
package nonimmutables.recurs; | ||
|
||
import org.immutables.value.Value; | ||
|
||
@Value.Immutable | ||
public interface AbstractMySomethingContent extends MyContent { | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
value-fixture/src/nonimmutables/recurs/AbstractSomething.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,18 @@ | ||
package nonimmutables.recurs; | ||
|
||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; | ||
import org.immutables.value.Value.Immutable; | ||
|
||
@JsonSerialize | ||
@Immutable | ||
public interface AbstractSomething extends IHaveGetContentAndWithId<MySomethingContent, Something> { | ||
|
||
// this override is not needed with 2.2, hooray! \o/ | ||
// @Override | ||
// MySomethingContent getContent(); | ||
|
||
// without this override it generates the withId method that returns T instead of Something for | ||
// the Json class ;( | ||
// @Override | ||
// Something withId(int id); | ||
} |
6 changes: 6 additions & 0 deletions
6
value-fixture/src/nonimmutables/recurs/IHaveGetContentAndWithId.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,6 @@ | ||
package nonimmutables.recurs; | ||
|
||
public interface IHaveGetContentAndWithId<T extends MyContent, A extends MyBase> extends MyBase, IHaveWithIdMethod<A> { | ||
|
||
T getContent(); | ||
} |
7 changes: 7 additions & 0 deletions
7
value-fixture/src/nonimmutables/recurs/IHaveWithIdMethod.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,7 @@ | ||
package nonimmutables.recurs; | ||
|
||
public interface IHaveWithIdMethod<T extends MyBase> { | ||
|
||
T withId(int id); // I that having getId in MyBase will generate this but I need an interface to | ||
// use commonly on multiple class that inherit from MyBase | ||
} |
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,6 @@ | ||
package nonimmutables.recurs; | ||
|
||
public interface MyBase { | ||
|
||
int getId(); | ||
} |
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,3 @@ | ||
package nonimmutables.recurs; | ||
public interface MyContent {} | ||
|
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,4 @@ | ||
@org.immutables.value.Value.Style( | ||
typeAbstract = "Abstract*", | ||
typeImmutable = "*") | ||
package nonimmutables.recurs; |
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