[gson] Add GsonHolders.modifyBuilder
This commit is contained in:
parent
5dd5926cb6
commit
fdfcb51123
@ -21,7 +21,7 @@ public class GsonHolder {
|
||||
}
|
||||
|
||||
public static void modifyBuilder(Consumer<GsonBuilder> func) {
|
||||
GsonHolders.API.modifyBuilder(func);
|
||||
GsonHolders.modifyBuilder(func);
|
||||
}
|
||||
|
||||
public static void register() {
|
||||
|
@ -27,16 +27,17 @@ public class GsonHolders {
|
||||
);
|
||||
|
||||
public static void registerTypeAdapter(Type type, Object typeAdapter) {
|
||||
synchronized (KNOWN_INSTANCES) {
|
||||
KNOWN_MODIFICATIONS.add(b -> b.registerTypeAdapter(type, typeAdapter));
|
||||
for (GsonHolder holder : KNOWN_INSTANCES) holder.registerTypeAdapter(type, typeAdapter);
|
||||
}
|
||||
modifyBuilder(b -> b.registerTypeAdapter(type, typeAdapter));
|
||||
}
|
||||
|
||||
public static void registerTypeAdapterFactory(TypeAdapterFactory factory) {
|
||||
modifyBuilder(b -> b.registerTypeAdapterFactory(factory));
|
||||
}
|
||||
|
||||
public static void modifyBuilder(Consumer<GsonBuilder> func) {
|
||||
synchronized (KNOWN_INSTANCES) {
|
||||
KNOWN_MODIFICATIONS.add(b -> b.registerTypeAdapterFactory(factory));
|
||||
for (GsonHolder holder : KNOWN_INSTANCES) holder.registerTypeAdapterFactory(factory);
|
||||
KNOWN_MODIFICATIONS.add(func);
|
||||
for (GsonHolder holder : KNOWN_INSTANCES) holder.modifyBuilder(func);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user