From 03d53fc997d67efebcf094f4556881b28f3b4e3b Mon Sep 17 00:00:00 2001 From: JeremyStarTM Date: Sun, 18 Aug 2024 19:47:41 +0200 Subject: [PATCH] Fix Javadoc issues --- .../base/classes/SubsystemClass.java | 6 +- .../types/DependencySubsystemVector.java | 31 ++++++++++ .../QuietLoggerImplementation.java | 7 +++ .../base/types/DependencyVector.java | 7 ++- .../sosengine/testapp/Main.java | 59 +++++++++++++++++++ 5 files changed, 106 insertions(+), 4 deletions(-) diff --git a/base/src/main/java/de/staropensource/sosengine/base/classes/SubsystemClass.java b/base/src/main/java/de/staropensource/sosengine/base/classes/SubsystemClass.java index 261e50d..e26a249 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/classes/SubsystemClass.java +++ b/base/src/main/java/de/staropensource/sosengine/base/classes/SubsystemClass.java @@ -22,7 +22,6 @@ package de.staropensource.sosengine.base.classes; import de.staropensource.sosengine.base.Engine; import de.staropensource.sosengine.base.annotations.EngineSubsystem; import de.staropensource.sosengine.base.annotations.EventListener; -import de.staropensource.sosengine.base.exceptions.versioning.InvalidVersionStringException; import de.staropensource.sosengine.base.internal.events.InternalEngineShutdownEvent; import de.staropensource.sosengine.base.logging.LoggerInstance; import de.staropensource.sosengine.base.types.DependencyVector; @@ -71,10 +70,11 @@ public abstract class SubsystemClass { * Used for dependency resolution during startup. * * @return matching {@link DependencyVector} for the subsystem + * @throws IllegalStateException when building the DependencyVector fails, see {@link DependencyVector.Builder#build()} * @see DependencyVector - * @since v1-alpha1 + * @since v1-alpha4 */ - public abstract @NotNull DependencyVector getDependencyVector() throws InvalidVersionStringException; + public abstract @NotNull DependencyVector getDependencyVector() throws IllegalStateException; /** * Called on engine shutdown. diff --git a/base/src/main/java/de/staropensource/sosengine/base/internal/types/DependencySubsystemVector.java b/base/src/main/java/de/staropensource/sosengine/base/internal/types/DependencySubsystemVector.java index 85195aa..d401285 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/internal/types/DependencySubsystemVector.java +++ b/base/src/main/java/de/staropensource/sosengine/base/internal/types/DependencySubsystemVector.java @@ -83,6 +83,13 @@ public final class DependencySubsystemVector extends DependencyVector { * @since v1-alpha4 */ public static final class Builder extends DependencyVector.Builder { + /** + * Constructs this class. + * + * @since v1-alpha4 + */ + public Builder() {} + /** * Contains the {@link SubsystemClass} to associate. * @@ -129,5 +136,29 @@ public final class DependencySubsystemVector extends DependencyVector { if (mainClass == null) throw new IllegalStateException("The main class is unset"); } + + /** + * Returns the {@link SubsystemClass} to associate. + * + * @return {@link SubsystemClass} to associcate + * @see DependencySubsystemVector#mainClass + * @since v1-alpha4 + */ + public @Nullable SubsystemClass getMainClass() { + return mainClass; + } + + /** + * Sets the {@link SubsystemClass} to associate. + * + * @param mainClass new {@link SubsystemClass} to associate + * @return builder instance + * @see DependencySubsystemVector#mainClass + * @since v1-alpha4 + */ + public @NotNull DependencyVector.Builder setIdentifier(@Nullable SubsystemClass mainClass) { + this.mainClass = mainClass; + return this; + } } } diff --git a/base/src/main/java/de/staropensource/sosengine/base/logging/implementation/QuietLoggerImplementation.java b/base/src/main/java/de/staropensource/sosengine/base/logging/implementation/QuietLoggerImplementation.java index e88a4f0..54aa5e0 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/logging/implementation/QuietLoggerImplementation.java +++ b/base/src/main/java/de/staropensource/sosengine/base/logging/implementation/QuietLoggerImplementation.java @@ -31,6 +31,13 @@ import org.jetbrains.annotations.Nullable; * @since v1-alpha4 */ public class QuietLoggerImplementation implements LoggerImplementation { + /** + * Constructs this class. + * + * @since v1-alpha4 + */ + public QuietLoggerImplementation() {} + /** {@inheritDoc} */ @Override public @Nullable String prePlaceholder(@NotNull LogLevel level, @NotNull Class issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message, @NotNull String format) { diff --git a/base/src/main/java/de/staropensource/sosengine/base/types/DependencyVector.java b/base/src/main/java/de/staropensource/sosengine/base/types/DependencyVector.java index a674e03..61dc5d5 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/types/DependencyVector.java +++ b/base/src/main/java/de/staropensource/sosengine/base/types/DependencyVector.java @@ -174,7 +174,7 @@ public class DependencyVector { * Builds a new {@link DependencyVector} instance. * * @return new {@link DependencyVector} - * @throws IllegalStateException if the identifier, versioning system or version is unset + * @throws IllegalStateException when the identifier, versioning system or version is unset or the version string is invalid * @since v1-alpha4 */ public @NotNull DependencyVector build() throws IllegalStateException { @@ -285,6 +285,7 @@ public class DependencyVector { * Sets the identifier of the new vector. * * @param identifier new identifier + * @return builder instance * @see DependencyVector#identifier * @since v1-alpha4 */ @@ -297,6 +298,7 @@ public class DependencyVector { * Sets the versioning system the new vector should use. * * @param versioningSystem versioning system to use + * @return builder instance * @see DependencyVector#versioningSystem * @since v1-alpha4 */ @@ -309,6 +311,7 @@ public class DependencyVector { * Sets the version of the new vector. * * @param version vector version + * @return builder instance * @see DependencyVector#version * @since v1-alpha4 */ @@ -321,6 +324,7 @@ public class DependencyVector { * Sets a set of all identifiers and their versions the new vector should depend on. * * @param dependencies dependencies + * @return builder instance * @see DependencyVector#dependencies * @since v1-alpha4 */ @@ -333,6 +337,7 @@ public class DependencyVector { * Sets a set of all identifiers and their versions the new vector should provide. * * @param provides provided vectors + * @return builder instance * @see DependencyVector#provides * @since v1-alpha4 */ diff --git a/testapp/src/main/java/de/staropensource/sosengine/testapp/Main.java b/testapp/src/main/java/de/staropensource/sosengine/testapp/Main.java index a41cf14..f32c5cb 100644 --- a/testapp/src/main/java/de/staropensource/sosengine/testapp/Main.java +++ b/testapp/src/main/java/de/staropensource/sosengine/testapp/Main.java @@ -21,9 +21,12 @@ package de.staropensource.sosengine.testapp; import de.staropensource.sosengine.base.Engine; import de.staropensource.sosengine.base.annotations.EventListener; +import de.staropensource.sosengine.base.data.versioning.OneNumberVersioningSystem; import de.staropensource.sosengine.base.events.ThrowableCatchEvent; import de.staropensource.sosengine.base.logging.LoggerInstance; +import de.staropensource.sosengine.base.types.DependencyVector; import de.staropensource.sosengine.base.types.vectors.Vec2i; +import de.staropensource.sosengine.base.utility.DependencyResolver; import de.staropensource.sosengine.base.utility.Miscellaneous; import de.staropensource.sosengine.base.utility.parser.StackTraceParser; import de.staropensource.sosengine.graphics.GraphicsSubsystem; @@ -38,7 +41,9 @@ import lombok.SneakyThrows; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.HashSet; import java.util.LinkedHashMap; +import java.util.Set; /** * The main class of the sos!engine development application. @@ -124,6 +129,60 @@ public final class Main { // Say hello to the world! logger.info("Hello world!"); + // DependencyResolver test + DependencyResolver resolver = new DependencyResolver(); + + Set<@NotNull String> depsT1 = new HashSet<>(); + Set<@NotNull String> provT1 = new HashSet<>(); + Set<@NotNull String> depsT2 = new HashSet<>(); + Set<@NotNull String> provT2 = new HashSet<>(); + Set<@NotNull String> depsT3 = new HashSet<>(); + Set<@NotNull String> provT3 = new HashSet<>(); + Set<@NotNull String> depsT4 = new HashSet<>(); + Set<@NotNull String> provT4 = new HashSet<>(); + + depsT2.add("test1=5"); + provT3.add("test5=11"); + depsT4.add("test3>100<10"); + + resolver.addVectors(new DependencyVector[]{ + new DependencyVector.Builder() + .setIdentifier("test1") + .setVersioningSystem(OneNumberVersioningSystem.class) + .setVersion("5") + .setDependencies(depsT1) + .setProvides(provT1) + .build(), + new DependencyVector.Builder() + .setIdentifier("test2") + .setVersioningSystem(OneNumberVersioningSystem.class) + .setVersion("1") + .setDependencies(depsT2) + .setProvides(provT2) + .build(), + new DependencyVector.Builder() + .setIdentifier("test3") + .setVersioningSystem(OneNumberVersioningSystem.class) + .setVersion("106") + .setDependencies(depsT3) + .setProvides(provT3) + .build(), + new DependencyVector.Builder() + .setIdentifier("test4") + .setVersioningSystem(OneNumberVersioningSystem.class) + .setVersion("69") + .setDependencies(depsT4) + .setProvides(provT4) + .build() + }); + + try { + resolver.resolve(); + } catch (Exception exception) { + logger.crash("Test resolution failed", exception); + } + logger.warn("Test resolution succeeded"); + // Choose Graphics API to use if (!GraphicsSubsystem.getInstance().setGraphicsApi()) logger.crash("No Graphics API is compatible");