From c4023869bfd508bc2d243b39fbe1f829aabf9798 Mon Sep 17 00:00:00 2001 From: ghubstan <36207203+ghubstan@users.noreply.github.com> Date: Mon, 24 Aug 2020 15:29:32 -0300 Subject: [PATCH] Remove duplicate CompositeOptionSet class This commit changes the access modifier on bisq.common.config.CompositeOptionSet to make it visible to bisq.apitest.config.ApiTestConfig, and the duplicate bisq.apitest.config.ApiTestConfig was deleted from 'apitest'. --- .../bisq/apitest/config/ApiTestConfig.java | 2 + .../apitest/config/CompositeOptionSet.java | 61 ------------------- .../common/config/CompositeOptionSet.java | 2 +- 3 files changed, 3 insertions(+), 62 deletions(-) delete mode 100644 apitest/src/main/java/bisq/apitest/config/CompositeOptionSet.java diff --git a/apitest/src/main/java/bisq/apitest/config/ApiTestConfig.java b/apitest/src/main/java/bisq/apitest/config/ApiTestConfig.java index 15193feae8..6a9e9a6448 100644 --- a/apitest/src/main/java/bisq/apitest/config/ApiTestConfig.java +++ b/apitest/src/main/java/bisq/apitest/config/ApiTestConfig.java @@ -17,6 +17,8 @@ package bisq.apitest.config; +import bisq.common.config.CompositeOptionSet; + import joptsimple.AbstractOptionSpec; import joptsimple.ArgumentAcceptingOptionSpec; import joptsimple.HelpFormatter; diff --git a/apitest/src/main/java/bisq/apitest/config/CompositeOptionSet.java b/apitest/src/main/java/bisq/apitest/config/CompositeOptionSet.java deleted file mode 100644 index 341b1e0101..0000000000 --- a/apitest/src/main/java/bisq/apitest/config/CompositeOptionSet.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * This file is part of Bisq. - * - * Bisq is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bisq is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Bisq. If not, see . - */ - -package bisq.apitest.config; - -import joptsimple.OptionSet; -import joptsimple.OptionSpec; - -import java.util.ArrayList; -import java.util.List; - -/** - * Composes multiple JOptSimple {@link OptionSet} instances such that calls to - * {@link #valueOf(OptionSpec)} and co will search all instances in the order they were - * added and return any value explicitly set, otherwise returning the default value for - * the given option or null if no default has been set. The API found here loosely - * emulates the {@link OptionSet} API without going through the unnecessary work of - * actually extending it. In practice, this class is used to compose options provided at - * the command line with those provided via config file, such that those provided at the - * command line take precedence over those provided in the config file. - */ -class CompositeOptionSet { - - private final List optionSets = new ArrayList<>(); - - public void addOptionSet(OptionSet optionSet) { - optionSets.add(optionSet); - } - - public boolean has(OptionSpec option) { - for (OptionSet optionSet : optionSets) - if (optionSet.has(option)) - return true; - - return false; - } - - public V valueOf(OptionSpec option) { - for (OptionSet optionSet : optionSets) - if (optionSet.has(option)) - return optionSet.valueOf(option); - - // None of the provided option sets specified the given option so fall back to - // the default value (if any) provided by the first specified OptionSet - return optionSets.get(0).valueOf(option); - } -} diff --git a/common/src/main/java/bisq/common/config/CompositeOptionSet.java b/common/src/main/java/bisq/common/config/CompositeOptionSet.java index 2fb2fa0668..f6a28ee3a6 100644 --- a/common/src/main/java/bisq/common/config/CompositeOptionSet.java +++ b/common/src/main/java/bisq/common/config/CompositeOptionSet.java @@ -17,7 +17,7 @@ import java.util.List; * the command line with those provided via config file, such that those provided at the * command line take precedence over those provided in the config file. */ -class CompositeOptionSet { +public class CompositeOptionSet { private final List optionSets = new ArrayList<>();