From 801056fa48283585ef8271cba2e2ca2ab6a3e78d Mon Sep 17 00:00:00 2001 From: Thomas Zurkan Date: Thu, 10 Oct 2019 16:59:31 -0700 Subject: [PATCH 1/2] use a ParserSupplier to enable work on older versions of Android. --- .../ab/config/parser/DefaultConfigParser.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/core-api/src/main/java/com/optimizely/ab/config/parser/DefaultConfigParser.java b/core-api/src/main/java/com/optimizely/ab/config/parser/DefaultConfigParser.java index 5e6bc84ef..87abf0559 100644 --- a/core-api/src/main/java/com/optimizely/ab/config/parser/DefaultConfigParser.java +++ b/core-api/src/main/java/com/optimizely/ab/config/parser/DefaultConfigParser.java @@ -38,6 +38,16 @@ public static ConfigParser getInstance() { } //======== Helper methods ========// + @FunctionalInterface + public interface ParserSupplier { + + /** + * Gets a result. + * + * @return a result + */ + T get(); + } public enum ConfigParserSupplier { // WARNING THESE MUST REMAIN LAMBDAS!!! @@ -49,9 +59,9 @@ public enum ConfigParserSupplier { JSON_SIMPLE_CONFIG_PARSER("org.json.simple.JSONObject", () -> { return new JsonSimpleConfigParser(); }); private final String className; - private final Supplier supplier; + private final ParserSupplier supplier; - ConfigParserSupplier(String className, Supplier supplier) { + ConfigParserSupplier(String className, ParserSupplier supplier) { this.className = className; this.supplier = supplier; } From d0595309075b68c6dbc1455fe187f8bad15ea50e Mon Sep 17 00:00:00 2001 From: Thomas Zurkan Date: Thu, 10 Oct 2019 17:08:02 -0700 Subject: [PATCH 2/2] remove the generics --- .../optimizely/ab/config/parser/DefaultConfigParser.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core-api/src/main/java/com/optimizely/ab/config/parser/DefaultConfigParser.java b/core-api/src/main/java/com/optimizely/ab/config/parser/DefaultConfigParser.java index 87abf0559..ff1748cb0 100644 --- a/core-api/src/main/java/com/optimizely/ab/config/parser/DefaultConfigParser.java +++ b/core-api/src/main/java/com/optimizely/ab/config/parser/DefaultConfigParser.java @@ -39,14 +39,14 @@ public static ConfigParser getInstance() { //======== Helper methods ========// @FunctionalInterface - public interface ParserSupplier { + public interface ParserSupplier { /** * Gets a result. * * @return a result */ - T get(); + ConfigParser get(); } public enum ConfigParserSupplier { @@ -59,9 +59,9 @@ public enum ConfigParserSupplier { JSON_SIMPLE_CONFIG_PARSER("org.json.simple.JSONObject", () -> { return new JsonSimpleConfigParser(); }); private final String className; - private final ParserSupplier supplier; + private final ParserSupplier supplier; - ConfigParserSupplier(String className, ParserSupplier supplier) { + ConfigParserSupplier(String className, ParserSupplier supplier) { this.className = className; this.supplier = supplier; }