From 4695a86c3d7dac51bd751d8b6b0f96247bd62e8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Va=C5=BEan?= Date: Tue, 11 Apr 2023 08:07:54 +0000 Subject: [PATCH] Adjusted configuration and docs for separate adapter library --- README.md | 2 +- pom.xml | 55 +------------------ scripts/configure.py | 11 +--- .../prefs/AbstractReactivePreferences.java | 13 ++--- .../hookless/prefs/ReactivePreferences.java | 9 ++- .../ReactivePreferencesFactoryWrapper.java | 2 - .../prefs/ReactivePreferencesWrapper.java | 2 - src/main/java/module-info.java | 34 +++--------- 8 files changed, 24 insertions(+), 104 deletions(-) diff --git a/README.md b/README.md index 890d5b2..a5f7a31 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Experimental. [Stagean](https://stagean.machinezoo.com/) is used to track progre ## Documentation -There is no javadoc yet. See [source code](src/main/java/com/machinezoo/hookless) for available APIs. +There is no javadoc yet. See [source code](src/main/java/com/machinezoo/hookless/prefs) for available APIs. ## Feedback diff --git a/pom.xml b/pom.xml index db48908..9380a72 100644 --- a/pom.xml +++ b/pom.xml @@ -50,64 +50,15 @@ 1.3.0 - com.machinezoo.noexception - noexception - 1.9.0 - - - com.machinezoo.noexception - noexception-slf4j - 1.0.1 - - - it.unimi.dsi - fastutil - 8.5.6 + com.machinezoo.hookless + hookless + 0.16.0 com.google.guava guava 31.0.1-jre - - io.micrometer - micrometer-core - 1.6.4 - - - io.opentracing - opentracing-util - 0.33.0 - - - org.junit.jupiter - junit-jupiter - 5.8.2 - test - - - org.hamcrest - hamcrest - 2.2 - test - - - org.awaitility - awaitility - 4.0.3 - test - - - org.junit-pioneer - junit-pioneer - 0.9.0 - - - com.github.valfirst - slf4j-test - 2.3.0 - test - diff --git a/scripts/configure.py b/scripts/configure.py index e620f8a..b341f8b 100644 --- a/scripts/configure.py +++ b/scripts/configure.py @@ -17,17 +17,8 @@ def has_website(self): return False def dependencies(self): yield from super().dependencies() - yield self.use_noexception() - yield self.use_noexception_slf4j() - yield self.use_fastutil() + yield self.use_hookless() yield self.use_guava() - yield self.use('io.micrometer:micrometer-core:1.6.4') - yield self.use('io.opentracing:opentracing-util:0.33.0') - yield self.use_junit() - yield self.use_hamcrest() - yield self.use('org.awaitility:awaitility:4.0.3', 'test') - yield self.use('org.junit-pioneer:junit-pioneer:0.9.0') - yield self.use_slf4j_test() def javadoc_links(self): yield from super().javadoc_links() diff --git a/src/main/java/com/machinezoo/hookless/prefs/AbstractReactivePreferences.java b/src/main/java/com/machinezoo/hookless/prefs/AbstractReactivePreferences.java index b75247f..d199ffd 100644 --- a/src/main/java/com/machinezoo/hookless/prefs/AbstractReactivePreferences.java +++ b/src/main/java/com/machinezoo/hookless/prefs/AbstractReactivePreferences.java @@ -22,7 +22,6 @@ * Reactive version of {@link AbstractPreferences}. */ @StubDocs -@NoTests public abstract class AbstractReactivePreferences extends ReactivePreferences { /* * First we define linking from children to parents. @@ -258,12 +257,12 @@ public String get(String key, String def) { @Override public boolean getBoolean(String key, boolean def) { switch (get(key, "").toLowerCase()) { - case "true": - return true; - case "false": - return false; - default: - return def; + case "true": + return true; + case "false": + return false; + default: + return def; } } @Override diff --git a/src/main/java/com/machinezoo/hookless/prefs/ReactivePreferences.java b/src/main/java/com/machinezoo/hookless/prefs/ReactivePreferences.java index 184c47a..03c052b 100644 --- a/src/main/java/com/machinezoo/hookless/prefs/ReactivePreferences.java +++ b/src/main/java/com/machinezoo/hookless/prefs/ReactivePreferences.java @@ -32,7 +32,6 @@ * Reactive version of {@link Preferences}. */ @StubDocs -@NoTests @DraftApi("configurable wrap(), perhaps require strong consistency, export") public abstract class ReactivePreferences { public abstract String name(); @@ -112,10 +111,10 @@ private static String packagePath(Class clazz) { if (clazz.isArray()) throw new IllegalArgumentException("No preferences node for arrays."); String name = clazz.getName(); - int dot = name.lastIndexOf('.'); - if (dot < 0) - return ""; - return name.substring(0, dot).replace('.', '/'); + int dot = name.lastIndexOf('.'); + if (dot < 0) + return ""; + return name.substring(0, dot).replace('.', '/'); } public static ReactivePreferences systemNodeForPackage(Class clazz) { return systemRoot().node(ReactivePreferences.packagePath(clazz)); diff --git a/src/main/java/com/machinezoo/hookless/prefs/ReactivePreferencesFactoryWrapper.java b/src/main/java/com/machinezoo/hookless/prefs/ReactivePreferencesFactoryWrapper.java index 7a7d012..7e96cd5 100644 --- a/src/main/java/com/machinezoo/hookless/prefs/ReactivePreferencesFactoryWrapper.java +++ b/src/main/java/com/machinezoo/hookless/prefs/ReactivePreferencesFactoryWrapper.java @@ -4,9 +4,7 @@ import java.util.function.Supplier; import java.util.prefs.*; import com.google.common.base.*; -import com.machinezoo.stagean.*; -@NoTests class ReactivePreferencesFactoryWrapper implements ReactivePreferencesFactory { /* * Make the wrappers lazy, so that we don't initialize systemRoot unnecessarily. diff --git a/src/main/java/com/machinezoo/hookless/prefs/ReactivePreferencesWrapper.java b/src/main/java/com/machinezoo/hookless/prefs/ReactivePreferencesWrapper.java index 0ed13bd..e3f1766 100644 --- a/src/main/java/com/machinezoo/hookless/prefs/ReactivePreferencesWrapper.java +++ b/src/main/java/com/machinezoo/hookless/prefs/ReactivePreferencesWrapper.java @@ -8,14 +8,12 @@ import com.machinezoo.hookless.*; import com.machinezoo.hookless.util.*; import com.machinezoo.noexception.throwing.*; -import com.machinezoo.stagean.*; /* * This is a wrapper around Preferences, but we in fact assume behavior of AbstractPreferences as currently implemented. * Most importantly, we assume that events are executed asynchronously on separate thread as is done in AbstractPreferences. * This implementation will still work with inline invocation of listeners as long as no lock is held by Preferences during invocation. */ -@NoTests class ReactivePreferencesWrapper extends AbstractReactivePreferences { /* * Read-only methods operating on the node tree are easy to define. Let's get that done first. diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index ea5368a..33f0047 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -1,38 +1,22 @@ // Part of Hookless: https://hookless.machinezoo.com +import com.machinezoo.stagean.*; + /** - * Hookless is a reactive programming library for Java based on invalidate-then-refresh pattern and implemented via thread-local context object. - * See the website for more information. - *

- * The main package {@link com.machinezoo.hookless} contains reactive primitives and other core reactive classes. - * Other packages provide reactive wrappers and reactive alternatives to various JRE classes. - * - * @see Hookless website + * Reactive versions of classes from {@link java.util.prefs}. + * See {@link com.machinezoo.hookless.prefs} package. */ -module com.machinezoo.hookless { - exports com.machinezoo.hookless; - exports com.machinezoo.hookless.util; - exports com.machinezoo.hookless.time; - exports com.machinezoo.hookless.noexception; +@StubDocs +@NoTests +@DraftApi +module com.machinezoo.hookless.prefs { exports com.machinezoo.hookless.prefs; + requires com.machinezoo.hookless; /* * Preferences should be moved to separate library along with this dependency. */ requires transitive java.prefs; requires com.machinezoo.stagean; - /* - * This dependency should be downgraded to non-transitive once exception handlers are moved to separate library. - */ - requires transitive com.machinezoo.noexception; - requires com.machinezoo.noexception.slf4j; - /* - * SLF4J is pulled in transitively via noexception, but the transitive dependency will be removed in future versions of noexception. - */ - requires org.slf4j; requires com.google.common; - requires io.opentracing.api; - requires io.opentracing.util; - requires it.unimi.dsi.fastutil; - requires micrometer.core; /* * Default ReactivePreferencesFactory can be configured via SPI just like PreferencesFactory. */