Fix Gson native record support check
This commit is contained in:
parent
b2f5770461
commit
b6dba62fa4
@ -1,16 +1,16 @@
|
|||||||
package fr.pandacube.lib.core.json;
|
package fr.pandacube.lib.core.json;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.TypeAdapter;
|
import com.google.gson.TypeAdapter;
|
||||||
import com.google.gson.TypeAdapterFactory;
|
import com.google.gson.TypeAdapterFactory;
|
||||||
import com.google.gson.internal.bind.ReflectiveTypeAdapterFactory;
|
import com.google.gson.internal.reflect.ReflectionHelper;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides pre-instanciated {@link Gson} instances, all with support for Java records and additionnal
|
* Provides pre-instanciated {@link Gson} instances, all with support for Java records and additionnal
|
||||||
* {@link TypeAdapterFactory} provided with {@link #registerTypeAdapterFactory(TypeAdapterFactory)}.
|
* {@link TypeAdapterFactory} provided with {@link #registerTypeAdapterFactory(TypeAdapterFactory)}.
|
||||||
@ -91,12 +91,13 @@ public class Json {
|
|||||||
|
|
||||||
|
|
||||||
private static boolean hasGsonNativeRecordSupport() {
|
private static boolean hasGsonNativeRecordSupport() {
|
||||||
for (Class<?> innerClasses : ReflectiveTypeAdapterFactory.class.getDeclaredClasses()) {
|
try {
|
||||||
if (innerClasses.getSimpleName().equals("RecordAdapter"))
|
ReflectionHelper.class.getDeclaredField("RECORD_HELPER");
|
||||||
return true;
|
return true;
|
||||||
}
|
} catch (NoSuchFieldException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user