mirror of
https://github.com/fankes/moshi.git
synced 2025-10-19 16:09:21 +08:00
Merge pull request #245 from NightlyNexus/eric/platform-fields
Fix isPlatformType
This commit is contained in:
@@ -46,7 +46,7 @@ final class ClassJsonAdapter<T> extends JsonAdapter<T> {
|
|||||||
Type type, Set<? extends Annotation> annotations, Moshi moshi) {
|
Type type, Set<? extends Annotation> annotations, Moshi moshi) {
|
||||||
Class<?> rawType = Types.getRawType(type);
|
Class<?> rawType = Types.getRawType(type);
|
||||||
if (rawType.isInterface() || rawType.isEnum()) return null;
|
if (rawType.isInterface() || rawType.isEnum()) return null;
|
||||||
if (isPlatformType(rawType)) {
|
if (isPlatformType(rawType) && !Types.isAllowedPlatformType(rawType)) {
|
||||||
throw new IllegalArgumentException("Platform "
|
throw new IllegalArgumentException("Platform "
|
||||||
+ type
|
+ type
|
||||||
+ " annotated "
|
+ " annotated "
|
||||||
@@ -111,11 +111,11 @@ final class ClassJsonAdapter<T> extends JsonAdapter<T> {
|
|||||||
*/
|
*/
|
||||||
private boolean isPlatformType(Class<?> rawType) {
|
private boolean isPlatformType(Class<?> rawType) {
|
||||||
String name = rawType.getName();
|
String name = rawType.getName();
|
||||||
return (name.startsWith("android.")
|
return name.startsWith("android.")
|
||||||
|| name.startsWith("java.")
|
|| name.startsWith("java.")
|
||||||
|| name.startsWith("javax.")
|
|| name.startsWith("javax.")
|
||||||
|| name.startsWith("kotlin.")
|
|| name.startsWith("kotlin.")
|
||||||
|| name.startsWith("scala.")) && !Types.isAllowedPlatformType(rawType);
|
|| name.startsWith("scala.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns true if fields with {@code modifiers} are included in the emitted JSON. */
|
/** Returns true if fields with {@code modifiers} are included in the emitted JSON. */
|
||||||
|
Reference in New Issue
Block a user