Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
If generic type is used as type declaration it should be used from available generic types. This should be used for actual type mapping for concrete types. Therefore it can't be used for generic type mapping, as it should remain as-is. Improved writer caching. Cache raw types for generics so they can be looked up without searching for factories. Simplistic support for different ctor mapping. For now only recognize type variables. Ideally same index could/should be used for resolution. For now this only works when default name is used. Support for aliases still needs to be added. Recognize generic type during raw type analysis. If nothing is found, try to check extended lookup, otherwise converter is not invoked. While this does cover basic cases, additional support for more complicated cases is required. Along with testing of such cases, eg generics across several levels of hierarchy.
- Loading branch information
Showing
10 changed files
with
242 additions
and
8 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
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
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
31 changes: 31 additions & 0 deletions
31
processor/src/test/java/com/dslplatform/json/models/GenericBoundSelfReferences.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,31 @@ | ||
package com.dslplatform.json.models; | ||
|
||
import com.dslplatform.json.CompiledJson; | ||
|
||
public abstract class GenericBoundSelfReferences { | ||
@CompiledJson | ||
public static class GenericBoundSelfReferenceString extends GenericBoundSelfReference<String> { | ||
public GenericBoundSelfReferenceString(String stringValue) { | ||
super(stringValue); | ||
} | ||
} | ||
|
||
@CompiledJson | ||
public static class GenericBoundSelfReference<T> implements Comparable<GenericBoundSelfReference<T>> { | ||
|
||
final T genericField; | ||
|
||
public GenericBoundSelfReference(T genericField) { | ||
this.genericField = genericField; | ||
} | ||
|
||
public final T getGenericField() { | ||
return genericField; | ||
} | ||
|
||
@Override | ||
public int compareTo(GenericBoundSelfReference<T> other) { | ||
return 1; | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
processor/src/test/java/com/dslplatform/json/models/GenericSelfReference.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.dslplatform.json.models; | ||
|
||
import com.dslplatform.json.CompiledJson; | ||
|
||
@CompiledJson | ||
public class GenericSelfReference<T> implements Comparable<GenericSelfReference<T>> { | ||
|
||
final T genericField; | ||
|
||
public GenericSelfReference(T genericField) { | ||
this.genericField = genericField; | ||
} | ||
|
||
public final T getGenericField() { | ||
return genericField; | ||
} | ||
|
||
@Override | ||
public int compareTo(GenericSelfReference<T> other) { | ||
return 1; | ||
} | ||
} |
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