From 69c1c9b2b8d9a3b72fcd856f2b6da0e8c896802c Mon Sep 17 00:00:00 2001 From: Gavin Whelan Date: Tue, 26 Feb 2019 00:17:50 +0000 Subject: [PATCH] Better implementation of EvaluationReason serialization type adapter. --- .../gson/EvaluationReasonSerialization.java | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/launchdarkly-android-client/src/main/java/com/launchdarkly/android/gson/EvaluationReasonSerialization.java b/launchdarkly-android-client/src/main/java/com/launchdarkly/android/gson/EvaluationReasonSerialization.java index 13c27f79..30818361 100644 --- a/launchdarkly-android-client/src/main/java/com/launchdarkly/android/gson/EvaluationReasonSerialization.java +++ b/launchdarkly-android-client/src/main/java/com/launchdarkly/android/gson/EvaluationReasonSerialization.java @@ -26,22 +26,7 @@ private static > T parseEnum(Class c, String name, T fallba @Override public JsonElement serialize(EvaluationReason src, Type typeOfSrc, JsonSerializationContext context) { - if (src instanceof EvaluationReason.Off) { - return context.serialize(src, EvaluationReason.Off.class); - } else if (src instanceof EvaluationReason.Fallthrough) { - return context.serialize(src, EvaluationReason.Fallthrough.class); - } else if (src instanceof EvaluationReason.TargetMatch) { - return context.serialize(src, EvaluationReason.TargetMatch.class); - } else if (src instanceof EvaluationReason.RuleMatch) { - return context.serialize(src, EvaluationReason.RuleMatch.class); - } else if (src instanceof EvaluationReason.PrerequisiteFailed) { - return context.serialize(src, EvaluationReason.PrerequisiteFailed.class); - } else if (src instanceof EvaluationReason.Error) { - return context.serialize(src, EvaluationReason.Error.class); - } else if (src instanceof EvaluationReason.Unknown) { - return context.serialize(src, EvaluationReason.Unknown.class); - } - return null; + return context.serialize(src, src.getClass()); } @Override