remove config logger loading in ConfigLoader

This commit is contained in:
Jörg Prante 2024-03-23 21:58:08 +01:00
parent a79c8a8e9e
commit 7c7dbace61
9 changed files with 36 additions and 36 deletions

View file

@ -4,10 +4,9 @@ import org.xbib.config.SystemConfigLogger;
import org.xbib.settings.SettingsLoader; import org.xbib.settings.SettingsLoader;
module org.xbib.config { module org.xbib.config {
requires transitive org.xbib.settings.datastructures;
exports org.xbib.config; exports org.xbib.config;
uses ConfigLogger; uses ConfigLogger;
uses SettingsLoader; uses SettingsLoader;
provides ConfigLogger with NullConfigLogger, SystemConfigLogger; provides ConfigLogger with NullConfigLogger, SystemConfigLogger;
requires org.xbib.settings.api;
requires transitive org.xbib.settings.datastructures;
} }

View file

@ -16,8 +16,6 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import java.util.ServiceLoader;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.xbib.settings.Settings; import org.xbib.settings.Settings;
import org.xbib.settings.SettingsBuilder; import org.xbib.settings.SettingsBuilder;
@ -36,18 +34,8 @@ public class ConfigLoader {
private ConfigLoader() { private ConfigLoader() {
} }
private static class Holder {
private static ConfigLogger createConfigLogger() {
ServiceLoader<ConfigLogger> serviceLoader = ServiceLoader.load(ConfigLogger.class);
Optional<ConfigLogger> optionalConfigLogger = serviceLoader.findFirst();
return optionalConfigLogger.orElse(new NullConfigLogger());
}
private static final ConfigLoader configLoader = new ConfigLoader().withLogger(createConfigLogger());
}
public static ConfigLoader getInstance() { public static ConfigLoader getInstance() {
return Holder.configLoader; return new ConfigLoader();
} }
public ConfigLoader withLogger(ConfigLogger logger) { public ConfigLoader withLogger(ConfigLogger logger) {

View file

@ -71,13 +71,7 @@ public interface SortedSetMultimap<K extends Object, V extends Object>
* behavior as {@link #get}, returning a live collection. When passed a key that is not present, * behavior as {@link #get}, returning a live collection. When passed a key that is not present,
* however, {@code asMap().get(Object)} returns {@code null} instead of an empty collection. * however, {@code asMap().get(Object)} returns {@code null} instead of an empty collection.
* *
* <p><b>Note:</b> The returned map's values are guaranteed to be of type {@link SortedSet}. To * <p><b>Note:</b> The returned map's values are guaranteed to be of type {@link SortedSet}.
* obtain this map with the more specific generic type {@code Map<K, SortedSet<V>>}, call {@link
* Multimaps#asMap(SortedSetMultimap)} instead. <b>However</b>, the returned map <i>itself</i> is
* not necessarily a {@link SortedMap}: A {@code SortedSetMultimap} must expose the <i>values</i>
* for a given key in sorted order, but it need not expose the <i>keys</i> in sorted order.
* Individual {@code SortedSetMultimap} implementations, like those built with {@link
* MultimapBuilder#treeKeys()}, may make additional guarantees.
*/ */
@Override @Override
Map<K, Collection<V>> asMap(); Map<K, Collection<V>> asMap();

View file

@ -15,7 +15,7 @@ import java.util.Set;
*/ */
public abstract class AbstractMultiMap<K, V> implements MultiMap<K, V> { public abstract class AbstractMultiMap<K, V> implements MultiMap<K, V> {
private final Map<K, Collection<V>> map; protected final Map<K, Collection<V>> map;
public AbstractMultiMap() { public AbstractMultiMap() {
this(null); this(null);

View file

@ -95,8 +95,7 @@ import static org.xbib.datastructures.immutable.ImmutableMap.checkNonnegative;
* <h3>For Java 8 users</h3> * <h3>For Java 8 users</h3>
* *
* <p>If you are using Java 8, this class is now obsolete. Most of its functionality is now provided * <p>If you are using Java 8, this class is now obsolete. Most of its functionality is now provided
* by {@link java.util.stream.Stream Stream} and by {@link Comparator} itself, and the rest can now * by {@link java.util.stream.Stream Stream} and by {@link Comparator} itself. See each method below for
* be found as static methods in our new {@link Comparators} class. See each method below for
* further instructions. Whenever possible, you should change any references of type {@code * further instructions. Whenever possible, you should change any references of type {@code
* Ordering} to be of type {@code Comparator} instead. However, at this time we have no plan to * Ordering} to be of type {@code Comparator} instead. However, at this time we have no plan to
* <i>deprecate</i> this class. * <i>deprecate</i> this class.
@ -393,8 +392,6 @@ public abstract class Ordering<T> implements Comparator<T> {
* <p>Note that {@code ordering.lexicographical().reverse()} is not equivalent to {@code * <p>Note that {@code ordering.lexicographical().reverse()} is not equivalent to {@code
* ordering.reverse().lexicographical()} (consider how each would order {@code [1]} and {@code [1, * ordering.reverse().lexicographical()} (consider how each would order {@code [1]} and {@code [1,
* 1]}). * 1]}).
*
* <p><b>Java 8 users:</b> Use {@link Comparators#lexicographical(Comparator)} instead.
*/ */
// type parameter <S> lets us avoid the extra <String> in statements like: // type parameter <S> lets us avoid the extra <String> in statements like:
// Ordering<Iterable<String>> o = // Ordering<Iterable<String>> o =
@ -698,7 +695,7 @@ public abstract class Ordering<T> implements Comparator<T> {
* only when the resulting list may need further modification, or may contain {@code null}. The * only when the resulting list may need further modification, or may contain {@code null}. The
* input is not modified. The returned list has random access. * input is not modified. The returned list has random access.
* *
* <p>Unlike {@link Sets#newTreeSet(Iterable)}, this method does not discard elements that are * <p>Unlike {@link java.util.Sets#newTreeSet(Iterable)}, this method does not discard elements that are
* duplicates according to the comparator. The sort performed is <i>stable</i>, meaning that such * duplicates according to the comparator. The sort performed is <i>stable</i>, meaning that such
* elements will appear in the returned list in the same order they appeared in {@code elements}. * elements will appear in the returned list in the same order they appeared in {@code elements}.
* *
@ -719,7 +716,7 @@ public abstract class Ordering<T> implements Comparator<T> {
* Returns an <b>immutable</b> list containing {@code elements} sorted by this ordering. The input * Returns an <b>immutable</b> list containing {@code elements} sorted by this ordering. The input
* is not modified. * is not modified.
* *
* <p>Unlike {@link Sets#newTreeSet(Iterable)}, this method does not discard elements that are * <p>Unlike {@link java.util.Sets#newTreeSet(Iterable)}, this method does not discard elements that are
* duplicates according to the comparator. The sort performed is <i>stable</i>, meaning that such * duplicates according to the comparator. The sort performed is <i>stable</i>, meaning that such
* elements will appear in the returned list in the same order they appeared in {@code elements}. * elements will appear in the returned list in the same order they appeared in {@code elements}.
* *
@ -739,7 +736,7 @@ public abstract class Ordering<T> implements Comparator<T> {
* equal to the element that preceded it, according to this ordering. Note that this is always * equal to the element that preceded it, according to this ordering. Note that this is always
* true when the iterable has fewer than two elements. * true when the iterable has fewer than two elements.
* *
* <p><b>Java 8 users:</b> Use the equivalent {@link Comparators#isInOrder(Iterable, Comparator)} * <p><b>Java 8 users:</b> Use the equivalent {@link java.util.Comparators#isInOrder(Iterable, Comparator)}
* instead, since the rest of {@code Ordering} is mostly obsolete (as explained in the class * instead, since the rest of {@code Ordering} is mostly obsolete (as explained in the class
* documentation). * documentation).
*/ */
@ -763,7 +760,7 @@ public abstract class Ordering<T> implements Comparator<T> {
* greater than the element that preceded it, according to this ordering. Note that this is always * greater than the element that preceded it, according to this ordering. Note that this is always
* true when the iterable has fewer than two elements. * true when the iterable has fewer than two elements.
* *
* <p><b>Java 8 users:</b> Use the equivalent {@link Comparators#isInStrictOrder(Iterable, * <p><b>Java 8 users:</b> Use the equivalent {@link java.util.Comparators#isInStrictOrder(Iterable,
* Comparator)} instead, since the rest of {@code Ordering} is mostly obsolete (as explained in * Comparator)} instead, since the rest of {@code Ordering} is mostly obsolete (as explained in
* the class documentation). * the class documentation).
*/ */

View file

@ -30,4 +30,10 @@ public class TinyMultiMap<K, V> extends AbstractMultiMap<K, V> {
protected Map<K, Collection<V>> newMap() { protected Map<K, Collection<V>> newMap() {
return TinyMap.builder(); return TinyMap.builder();
} }
@SuppressWarnings("unchecked")
@Override
public Map<K, Collection<V>> asMap() {
return ((TinyMap.Builder<K, Collection<V>>) map).build();
}
} }

View file

@ -1,13 +1,16 @@
package org.xbib.datastructures.tiny; package org.xbib.datastructures.tiny;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import java.util.Collection;
import java.util.Map;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.xbib.datastructures.common.MultiMap; import org.xbib.datastructures.common.MultiMap;
public class TinyMultiMapTest { public class TinyMultiMapTest {
@Test @Test
public void testMultiMap() { public void testMultiMapPut() {
MultiMap<String, String> multiMap = new TinyMultiMap<>(); MultiMap<String, String> multiMap = new TinyMultiMap<>();
multiMap.put("a", "a"); multiMap.put("a", "a");
multiMap.put("a", "b"); multiMap.put("a", "b");
@ -17,4 +20,18 @@ public class TinyMultiMapTest {
multiMap.put("b", "f"); multiMap.put("b", "f");
assertEquals("{a=[a, b, c], b=[d, e, f]}", multiMap.asMap().toString()); assertEquals("{a=[a, b, c], b=[d, e, f]}", multiMap.asMap().toString());
} }
@Test
public void testMultiMapValuesAreCollections() {
MultiMap<String, String> multiMap = new TinyMultiMap<>();
multiMap.put("a", "a");
multiMap.put("a", "b");
multiMap.put("a", "c");
multiMap.put("b", "d");
multiMap.put("b", "e");
multiMap.put("b", "f");
Map<String, Collection<String>> map = multiMap.asMap();
assertInstanceOf(Collection.class, map.get("a"));
assertInstanceOf(Collection.class, map.get("b"));
}
} }

View file

@ -1,3 +1,3 @@
group = org.xbib group = org.xbib
name = datastructures name = datastructures
version = 5.0.6 version = 5.0.7

View file

@ -15,7 +15,6 @@ pluginManagement {
dependencyResolutionManagement { dependencyResolutionManagement {
versionCatalogs { versionCatalogs {
libs { libs {
version('gradle', '8.4')
version('gradle', '8.5') version('gradle', '8.5')
library('chronicle-core', 'net.openhft', 'chronicle-core').version('2.21ea14') library('chronicle-core', 'net.openhft', 'chronicle-core').version('2.21ea14')
library('affinity', 'net.openhft', 'affinity').version('3.21ea0') library('affinity', 'net.openhft', 'affinity').version('3.21ea0')
@ -23,7 +22,7 @@ dependencyResolutionManagement {
library('orgjson', 'org.json', 'json').version('20210307') library('orgjson', 'org.json', 'json').version('20210307')
} }
testLibs { testLibs {
version('junit', '5.10.0') version('junit', '5.10.2')
version('jackson', '2.15.2') version('jackson', '2.15.2')
library('junit-jupiter-api', 'org.junit.jupiter', 'junit-jupiter-api').versionRef('junit') library('junit-jupiter-api', 'org.junit.jupiter', 'junit-jupiter-api').versionRef('junit')
library('junit-jupiter-params', 'org.junit.jupiter', 'junit-jupiter-params').versionRef('junit') library('junit-jupiter-params', 'org.junit.jupiter', 'junit-jupiter-params').versionRef('junit')
@ -64,7 +63,7 @@ include 'datastructures-json-minimal'
include 'datastructures-json-noggit' include 'datastructures-json-noggit'
include 'datastructures-json-simple' include 'datastructures-json-simple'
include 'datastructures-json-tiny' include 'datastructures-json-tiny'
include 'datastructures-multi' //include 'datastructures-multi'
include 'datastructures-queue-tape' include 'datastructures-queue-tape'
include 'datastructures-raml' include 'datastructures-raml'
include 'datastructures-tiny' include 'datastructures-tiny'