From 0bd3e9825351cf538f55c236df1787a1314c14cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rg=20Prante?= Date: Mon, 18 Oct 2021 18:05:01 +0200 Subject: [PATCH] use static memory for settings by config params --- .../java/org/xbib/config/ConfigLoader.java | 3 +- .../java/org/xbib/config/ConfigParams.java | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/config/src/main/java/org/xbib/config/ConfigLoader.java b/config/src/main/java/org/xbib/config/ConfigLoader.java index 6089082..24882e1 100644 --- a/config/src/main/java/org/xbib/config/ConfigLoader.java +++ b/config/src/main/java/org/xbib/config/ConfigLoader.java @@ -29,12 +29,11 @@ import java.util.stream.Collectors; */ public class ConfigLoader { - private final Map map; + private static final Map map = new HashMap<>(); private ConfigLogger logger; private ConfigLoader() { - this.map = new HashMap<>(); } private static class Holder { diff --git a/config/src/main/java/org/xbib/config/ConfigParams.java b/config/src/main/java/org/xbib/config/ConfigParams.java index 9e810b8..07e5d3c 100644 --- a/config/src/main/java/org/xbib/config/ConfigParams.java +++ b/config/src/main/java/org/xbib/config/ConfigParams.java @@ -9,6 +9,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.List; +import java.util.Objects; public class ConfigParams implements Comparable { @@ -129,6 +130,36 @@ public class ConfigParams implements Comparable { return this; } + @Override + public int hashCode() { + return toString().hashCode(); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ConfigParams that = (ConfigParams) o; + return withSystemEnvironment == that.withSystemEnvironment && + withSystemProperties == that.withSystemProperties && + failIfEmpty == that.failIfEmpty && + includeAll == that.includeAll && + withStdin == that.withStdin && + withSystemPropertiesOverride == that.withSystemPropertiesOverride && + Objects.equals(classLoaders, that.classLoaders) && + Objects.equals(reader, that.reader) && + Objects.equals(jdbcLookups, that.jdbcLookups) && + Objects.equals(settings, that.settings) && + Objects.equals(args, that.args) && + Objects.equals(directoryName, that.directoryName) && + Objects.equals(fileNamesWithoutSuffix, that.fileNamesWithoutSuffix) && + Objects.equals(fileLocations, that.fileLocations); + } + @Override public int compareTo(ConfigParams o) { return COMPARATOR.compare(this, o);