-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Failsafe mode improvements, adapted for modular structure
- Loading branch information
Showing
37 changed files
with
518 additions
and
542 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
28 changes: 0 additions & 28 deletions
28
...ydonate/easydonate4j/json/serialization/deserializer/gson/DiscountsArrayDeserializer.java
This file was deleted.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
...java/ru/easydonate/easydonate4j/json/serialization/failsafe/gson/ApiV3FailsafeModule.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,14 @@ | ||
package ru.easydonate.easydonate4j.json.serialization.failsafe.gson; | ||
|
||
import com.google.gson.Gson; | ||
import org.jetbrains.annotations.NotNull; | ||
import ru.easydonate.easydonate4j.api.v3.data.model.gson.shop.purchase.DiscountsModel; | ||
|
||
public final class ApiV3FailsafeModule extends GsonFailsafeModule { | ||
|
||
public ApiV3FailsafeModule(@NotNull Gson unsafeGsonInstance) { | ||
// Bug [12.01.22]: some payment objects has an empty array instead of `null` for the `sales` field | ||
super.registerTypeAdapter(DiscountsModel.class, DiscountsModel.getDeserializer(unsafeGsonInstance)); | ||
} | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
...u/easydonate/easydonate4j/json/serialization/failsafe/gson/CallbackApiFailsafeModule.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,14 @@ | ||
package ru.easydonate.easydonate4j.json.serialization.failsafe.gson; | ||
|
||
import com.google.gson.Gson; | ||
import org.jetbrains.annotations.NotNull; | ||
import ru.easydonate.easydonate4j.callback.data.model.gson.purchase.DiscountsModel; | ||
|
||
public final class CallbackApiFailsafeModule extends GsonFailsafeModule { | ||
|
||
public CallbackApiFailsafeModule(@NotNull Gson unsafeGsonInstance) { | ||
// Bug [12.01.22]: some payment objects has an empty array instead of `null` for the `sales` field | ||
super.registerTypeAdapter(DiscountsModel.class, DiscountsModel.getDeserializer(unsafeGsonInstance)); | ||
} | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
.../java/ru/easydonate/easydonate4j/json/serialization/failsafe/gson/GsonFailsafeModule.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,27 @@ | ||
package ru.easydonate.easydonate4j.json.serialization.failsafe.gson; | ||
|
||
import com.google.gson.GsonBuilder; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.lang.reflect.Type; | ||
import java.util.LinkedHashMap; | ||
import java.util.Map; | ||
|
||
public abstract class GsonFailsafeModule { | ||
|
||
protected final Map<Type, Object> typeAdapters; | ||
|
||
protected GsonFailsafeModule() { | ||
this.typeAdapters = new LinkedHashMap<>(); | ||
} | ||
|
||
protected void registerTypeAdapter(@NotNull Type type, @NotNull Object typeAdapter) { | ||
typeAdapters.put(type, typeAdapter); | ||
} | ||
|
||
public void register(@NotNull GsonBuilder... gsonBuilders) { | ||
for(GsonBuilder gsonBuilder : gsonBuilders) | ||
typeAdapters.forEach(gsonBuilder::registerTypeAdapter); | ||
} | ||
|
||
} |
45 changes: 0 additions & 45 deletions
45
...donate4j/json/serialization/implementation/registry/api/v3/gson/PluginModelsRegistry.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.