From 54b7b9a69548ed3cab866d506d17fafb3532e250 Mon Sep 17 00:00:00 2001 From: JeremyStarTM Date: Fri, 20 Sep 2024 17:10:33 +0200 Subject: [PATCH] Remove code duplication (returns in conf classes) --- .../sosengine/base/EngineConfiguration.java | 39 +++++++++---------- .../base/implementable/Configuration.java | 2 +- .../glfw/GlfwSubsystemConfiguration.java | 15 ++++--- 3 files changed, 27 insertions(+), 29 deletions(-) diff --git a/base/src/main/java/de/staropensource/sosengine/base/EngineConfiguration.java b/base/src/main/java/de/staropensource/sosengine/base/EngineConfiguration.java index 747b9fe58..18f516240 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/EngineConfiguration.java +++ b/base/src/main/java/de/staropensource/sosengine/base/EngineConfiguration.java @@ -67,16 +67,15 @@ public final class EngineConfiguration extends Configuration { private static EngineConfiguration instance; /** - * Contains the group in which setting overrides must begin with.. + * Contains prefix properties must begin with. * * @since v1-alpha0 * -- GETTER -- - * Returns the group in which setting overrides must begin with. + * Returns prefix properties must begin with. * * @return property group * @since v1-alpha0 */ - @Getter private final @NotNull String group = "sosengine.base."; /** @@ -391,26 +390,26 @@ public final class EngineConfiguration extends Configuration { /** {@inheritDoc} */ @Override public @Nullable Object getSetting(@NotNull String setting) { - switch (setting) { - case "debug" -> { return debug; } - case "debugEvents" -> { return debugEvents; } - case "debugShortcodeConverter" -> { return debugShortcodeConverter; } + return switch (setting) { + case "debug" -> debug; + case "debugEvents" -> debugEvents; + case "debugShortcodeConverter" -> debugShortcodeConverter; - case "errorShortcodeConverter" -> { return errorShortcodeConverter; } + case "errorShortcodeConverter" -> errorShortcodeConverter; - case "optimizeLogging" -> { return optimizeLogging; } - case "optimizeEvents" -> { return optimizeEvents; } - case "optimizeSubsystemInitialization" -> { return optimizeSubsystemInitialization; } + case "optimizeLogging" -> optimizeLogging; + case "optimizeEvents" -> optimizeEvents; + case "optimizeSubsystemInitialization" -> optimizeSubsystemInitialization; - case "loggerLevel" -> { return loggerLevel; } - case "loggerTemplate" -> { return loggerTemplate; } - case "loggerPollingSpeed" -> { return loggerPollingSpeed; } - case "loggerForceStandardOutput" -> { return loggerForceStandardOutput; } - case "loggerEnableNewlineSupport" -> { return loggerEnableNewlineSupport; } - case "loggerImmediateShutdown" -> { return loggerImmediateShutdown; } + case "loggerLevel" -> loggerLevel; + case "loggerTemplate" -> loggerTemplate; + case "loggerPollingSpeed" -> loggerPollingSpeed; + case "loggerForceStandardOutput" -> loggerForceStandardOutput; + case "loggerEnableNewlineSupport" -> loggerEnableNewlineSupport; + case "loggerImmediateShutdown" -> loggerImmediateShutdown; - case "hideFullTypePath" -> { return hideFullTypePath; } - default -> { return null; } - } + case "hideFullTypePath" -> hideFullTypePath; + default -> null; + }; } } diff --git a/base/src/main/java/de/staropensource/sosengine/base/implementable/Configuration.java b/base/src/main/java/de/staropensource/sosengine/base/implementable/Configuration.java index 72cf68cf3..2b6b8f7ec 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/implementable/Configuration.java +++ b/base/src/main/java/de/staropensource/sosengine/base/implementable/Configuration.java @@ -100,7 +100,7 @@ public abstract class Configuration { } /** - * Returns the group in which setting overrides must begin with. + * Returns prefix properties must begin with. * * @return property group * @since v1-alpha2 diff --git a/windowing/glfw/src/main/java/de/staropensource/sosengine/windowing/glfw/GlfwSubsystemConfiguration.java b/windowing/glfw/src/main/java/de/staropensource/sosengine/windowing/glfw/GlfwSubsystemConfiguration.java index 9dde55433..ee765105a 100644 --- a/windowing/glfw/src/main/java/de/staropensource/sosengine/windowing/glfw/GlfwSubsystemConfiguration.java +++ b/windowing/glfw/src/main/java/de/staropensource/sosengine/windowing/glfw/GlfwSubsystemConfiguration.java @@ -48,16 +48,15 @@ public final class GlfwSubsystemConfiguration extends Configuration { private static GlfwSubsystemConfiguration instance; /** - * Defines the group in which setting overrides must begin with. + * Defines prefix properties must begin with. * * @since v1-alpha0 * -- GETTER -- - * Returns the group in which setting overrides must begin with. + * Returns prefix properties must begin with. * * @return property group * @since v1-alpha0 */ - @Getter private final @NotNull String group = "sosengine.windowing.glfw."; /** @@ -136,10 +135,10 @@ public final class GlfwSubsystemConfiguration extends Configuration { /** {@inheritDoc} */ @Override public @Nullable Object getSetting(@NotNull String setting) { - switch (setting) { - case "platform" -> { return platform; } - case "disableLibdecor" -> { return disableLibdecor; } - default -> { return null; } - } + return switch (setting) { + case "platform" -> platform; + case "disableLibdecor" -> disableLibdecor; + default -> null; + }; } }