Skip to content

Commit

Permalink
added null checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Iulian Masar committed Feb 11, 2025
1 parent e05aff8 commit 5a61e9d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ public class CardInfoTypeDeserializer implements JsonDeserializer<CardInfoType>
@Override
public CardInfoType deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
String value = json.getAsString();
if ("null".equals(value)) {
return null;
}
if ("CHARGE CARD".equals(value)) {
return CardInfoType.CHARGE_CARD;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package com.mangopay.core.serializer;

import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.google.gson.*;
import com.mangopay.core.enumerations.CardInfoType;

import java.lang.reflect.Type;

public class CardInfoTypeSerializer implements JsonSerializer<CardInfoType> {
@Override
public JsonElement serialize(CardInfoType src, Type typeOfSrc, JsonSerializationContext context) {
if (src == null) {
return JsonNull.INSTANCE;
}
if (src == CardInfoType.CHARGE_CARD) {
return new JsonPrimitive("CHARGE CARD");
}
Expand Down

0 comments on commit 5a61e9d

Please sign in to comment.