diff --git a/base/src/main/java/de/staropensource/sosengine/base/Engine.java b/base/src/main/java/de/staropensource/sosengine/base/Engine.java index e1620e6..fef581b 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/Engine.java +++ b/base/src/main/java/de/staropensource/sosengine/base/Engine.java @@ -123,42 +123,43 @@ public final class Engine implements SubsystemMainClass { @SuppressWarnings("ExtractMethodRecommender") private void populateCrashContent() { // Issuer - Map crashContentIssuer = new LinkedHashMap<>(); + Map<@NotNull String, @NotNull String> crashContentIssuer = new LinkedHashMap<>(); crashContentIssuer.put("Code part", "%issuer_code_part%"); crashContentIssuer.put("Classpath", "%issuer_path%"); crashContentIssuer.put("Additional information", "%issuer_info%"); crashContentIssuer.put("Message", "%issuer_message%"); // Engine -> Dependencies - Map crashContentEngineDependencies = new LinkedHashMap<>(); + Map<@NotNull String, @NotNull String> crashContentEngineDependencies = new LinkedHashMap<>(); crashContentEngineDependencies.put("Lombok", "%engine_dependency_lombok%"); crashContentEngineDependencies.put("Jetbrains Annotations", "%engine_dependency_jetbrains_annotations%"); crashContentEngineDependencies.put("Jansi", "%engine_dependency_jansi%"); crashContentEngineDependencies.put("Reflections", "%engine_dependencies_reflections%"); crashContentEngineDependencies.put("SLF4J", "%engine_dependencies_slf4j%"); + crashContentEngineDependencies.put("LWJGL", "%engine_dependencies_lwjgl%"); // Engine -> Plugins - Map crashContentEnginePlugins = new LinkedHashMap<>(); + Map<@NotNull String, @NotNull String> crashContentEnginePlugins = new LinkedHashMap<>(); crashContentEnginePlugins.put("Shadow", "%engine_plugin_shadow%"); crashContentEnginePlugins.put("Lombok", "%engine_plugin_lombok%"); // Engine -> * - Map crashContentEngine = new LinkedHashMap<>(); + Map<@NotNull String, @NotNull Object> crashContentEngine = new LinkedHashMap<>(); crashContentEngine.put("Version", "%engine_version%"); crashContentEngine.put("Dependencies", crashContentEngineDependencies); crashContentEngine.put("Plugins", crashContentEnginePlugins); // JVM -> Implementation - Map crashContentJvmImplementation = new LinkedHashMap<>(); + Map<@NotNull String, @NotNull String> crashContentJvmImplementation = new LinkedHashMap<>(); crashContentJvmImplementation.put("Name", "%jvm_implementation_name%"); crashContentJvmImplementation.put("Version", "%jvm_implementation_version%"); crashContentJvmImplementation.put("Vendor", "%jvm_implementation_vendor%"); // JVM -> * - Map crashContentJvm = new LinkedHashMap<>(); + Map<@NotNull String, @NotNull Object> crashContentJvm = new LinkedHashMap<>(); crashContentJvm.put("Java Version", "%jvm_java%"); crashContentJvm.put("Implementation", crashContentJvmImplementation); crashContentJvm.put("Arguments", "%jvm_arguments%"); // Operating system - Map crashContentOS = new LinkedHashMap<>(); + Map<@NotNull String, @NotNull String> crashContentOS = new LinkedHashMap<>(); crashContentOS.put("Time", "%time_hour%:%time_minute%:%time_second% (%time_zone%, UNIX Epoch: %time_epoch%)"); crashContentOS.put("Date", "%date_day%.%date_month%.%date_year%"); 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 ff9a02f..b5ec0cf 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/EngineConfiguration.java +++ b/base/src/main/java/de/staropensource/sosengine/base/EngineConfiguration.java @@ -64,6 +64,7 @@ public final class EngineConfiguration implements SubsystemConfiguration { * @return property group * @since 1-alpha0 */ + @NotNull @Getter private static final String group = "sosengine.base."; @@ -215,7 +216,7 @@ public final class EngineConfiguration implements SubsystemConfiguration { } /** {@inheritDoc} */ - public void loadConfiguration(Properties properties) { + public void loadConfiguration(@NotNull Properties properties) { // Define variables PropertyParser parser = new PropertyParser(properties); diff --git a/base/src/main/java/de/staropensource/sosengine/base/classes/LoggerImpl.java b/base/src/main/java/de/staropensource/sosengine/base/classes/LoggerImpl.java index 793ad34..4be5e3e 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/classes/LoggerImpl.java +++ b/base/src/main/java/de/staropensource/sosengine/base/classes/LoggerImpl.java @@ -40,6 +40,7 @@ public interface LoggerImpl { * @return new log message * @since 1-alpha0 */ + @NotNull String prePlaceholder(@NotNull LogLevel level, @NotNull LogIssuer logIssuer, @NotNull String message); /** @@ -51,6 +52,7 @@ public interface LoggerImpl { * @return new log message * @since 1-alpha0 */ + @NotNull String postPlaceholder(@NotNull LogLevel level, @NotNull LogIssuer logIssuer, @NotNull String message); /** diff --git a/base/src/main/java/de/staropensource/sosengine/base/classes/SubsystemConfiguration.java b/base/src/main/java/de/staropensource/sosengine/base/classes/SubsystemConfiguration.java index cf29504..86220fe 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/classes/SubsystemConfiguration.java +++ b/base/src/main/java/de/staropensource/sosengine/base/classes/SubsystemConfiguration.java @@ -28,7 +28,7 @@ import java.util.Properties; * * @since 1-alpha0 */ -@SuppressWarnings({ "unused", "JavadocDeclaration", "JavadocBlankLines" }) +@SuppressWarnings({ "unused" }) public interface SubsystemConfiguration { /** * Instance. @@ -42,6 +42,7 @@ public interface SubsystemConfiguration { * * @since 1-alpha0 */ + @NotNull String group = "sosengine."; /** @@ -52,7 +53,7 @@ public interface SubsystemConfiguration { * @see SubsystemConfiguration#loadDefaultConfiguration() * @since 1-alpha0 */ - void loadConfiguration(Properties properties); + void loadConfiguration(@NotNull Properties properties); /** * Loads the subsystem configuration from the system properties. diff --git a/base/src/main/java/de/staropensource/sosengine/base/classes/helpers/EventHelper.java b/base/src/main/java/de/staropensource/sosengine/base/classes/helpers/EventHelper.java index cfca209..4f02a88 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/classes/helpers/EventHelper.java +++ b/base/src/main/java/de/staropensource/sosengine/base/classes/helpers/EventHelper.java @@ -27,6 +27,7 @@ import de.staropensource.sosengine.base.types.LogIssuer; import de.staropensource.sosengine.base.utility.ListFormatter; import lombok.Getter; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.reflections.Reflections; import org.reflections.scanners.Scanners; import org.reflections.util.ClasspathHelper; @@ -55,7 +56,7 @@ public class EventHelper { * @param clazz event class * @since 1-alpha0 */ - public static void logCall(Class clazz, Object ... arguments) { + public static void logCall(@NotNull Class clazz, @NotNull Object ... arguments) { if (EngineConfiguration.getInstance().isDebugEvents()) if (arguments.length == 0) Logger.diag(new LogIssuer(clazz), "Event " + clazz.getName() + " called"); @@ -71,7 +72,7 @@ public class EventHelper { * @since 1-alpha0 */ @NotNull - public static LinkedList getAnnotatedMethods(Class clazz) { + public static LinkedList getAnnotatedMethods(@NotNull Class clazz) { LinkedList methods = new LinkedList<>(); Reflections reflections = new Reflections( @@ -79,7 +80,7 @@ public class EventHelper { .setUrls(ClasspathHelper.forJavaClassPath()) .setScanners(Scanners.MethodsAnnotated) ); - Set annotatedMethods = reflections.getMethodsAnnotatedWith(EventListener.class); + Set<@NotNull Method> annotatedMethods = reflections.getMethodsAnnotatedWith(EventListener.class); for (Method method : annotatedMethods) if (method.getAnnotation(EventListener.class).event() == clazz) @@ -97,7 +98,7 @@ public class EventHelper { * @param clazz event class * @since 1-alpha0 */ - public static void invokeAnnotatedMethods(Class clazz) { + public static void invokeAnnotatedMethods(@NotNull Class clazz) { logCall(clazz); for (Method method : getAnnotatedMethods(clazz)) { diff --git a/base/src/main/java/de/staropensource/sosengine/base/data/info/JvmInformation.java b/base/src/main/java/de/staropensource/sosengine/base/data/info/JvmInformation.java index eb2095c..3cacede 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/data/info/JvmInformation.java +++ b/base/src/main/java/de/staropensource/sosengine/base/data/info/JvmInformation.java @@ -19,6 +19,8 @@ package de.staropensource.sosengine.base.data.info; +import org.jetbrains.annotations.NotNull; + import java.lang.management.ManagementFactory; import java.util.List; @@ -59,6 +61,7 @@ public final class JvmInformation { * @return the JVM implementation name * @since 1-alpha0 */ + @NotNull public static String getImplementationName() { return ManagementFactory.getRuntimeMXBean().getVmName(); } @@ -69,6 +72,7 @@ public final class JvmInformation { * @return the JVM implementation version * @since 1-alpha0 */ + @NotNull public static String getImplementationVersion() { return ManagementFactory.getRuntimeMXBean().getVmVersion(); } @@ -79,6 +83,7 @@ public final class JvmInformation { * @return the JVM implementation vendor * @since 1-alpha0 */ + @NotNull public static String getImplementationVendor() { return ManagementFactory.getRuntimeMXBean().getVmVendor(); } @@ -99,7 +104,8 @@ public final class JvmInformation { * @return the JVM arguments * @since 1-alpha0 */ - public static List getArguments() { + @NotNull + public static List<@NotNull String> getArguments() { return ManagementFactory.getRuntimeMXBean().getInputArguments(); } } diff --git a/base/src/main/java/de/staropensource/sosengine/base/logging/CrashHandler.java b/base/src/main/java/de/staropensource/sosengine/base/logging/CrashHandler.java index e2f5516..7f39afe 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/logging/CrashHandler.java +++ b/base/src/main/java/de/staropensource/sosengine/base/logging/CrashHandler.java @@ -69,6 +69,7 @@ public final class CrashHandler { * @param crashTemplate new crash template * @since 1-alpha0 */ + @NotNull @Getter @Setter private static String crashTemplate = """ @@ -94,8 +95,9 @@ public final class CrashHandler { * @return crash content * @since 1-alpha0 */ + @NotNull @Getter - private static final LinkedHashMap crashContent = new LinkedHashMap<>(); + private static final LinkedHashMap<@NotNull Object, @NotNull Object> crashContent = new LinkedHashMap<>(); /** * Constructor. @@ -123,7 +125,7 @@ public final class CrashHandler { base = Logger.getLoggerImplementation().prePlaceholder(LogLevel.CRASH, logIssuer, base); // Create list of temporary placeholders - List temporaryPlaceholders = new ArrayList<>(); + List<@NotNull Placeholder> temporaryPlaceholders = new ArrayList<>(); temporaryPlaceholders.add(new IssuerMessage(message)); // log_message is out of order to allow for placeholder usage // issuer_* diff --git a/base/src/main/java/de/staropensource/sosengine/base/logging/DefaultLoggerImpl.java b/base/src/main/java/de/staropensource/sosengine/base/logging/DefaultLoggerImpl.java index 374f254..1d28ce8 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/logging/DefaultLoggerImpl.java +++ b/base/src/main/java/de/staropensource/sosengine/base/logging/DefaultLoggerImpl.java @@ -45,6 +45,7 @@ public class DefaultLoggerImpl implements LoggerImpl { public DefaultLoggerImpl() {} /** {@inheritDoc} */ + @NotNull @Override public String prePlaceholder(@NotNull LogLevel level, @NotNull LogIssuer logIssuer, @NotNull String message) { // No modifications necessary @@ -52,6 +53,7 @@ public class DefaultLoggerImpl implements LoggerImpl { } /** {@inheritDoc} */ + @NotNull @Override public String postPlaceholder(@NotNull LogLevel level, @NotNull LogIssuer logIssuer, @NotNull String message) { // No modifications necessary diff --git a/base/src/main/java/de/staropensource/sosengine/base/logging/Logger.java b/base/src/main/java/de/staropensource/sosengine/base/logging/Logger.java index 3b731cf..3cb7fed 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/logging/Logger.java +++ b/base/src/main/java/de/staropensource/sosengine/base/logging/Logger.java @@ -101,7 +101,7 @@ public final class Logger { base = loggerImplementation.prePlaceholder(level, logIssuer, base); // Create list of temporary placeholders - List temporaryPlaceholders = new ArrayList<>(); + List<@NotNull Placeholder> temporaryPlaceholders = new ArrayList<>(); temporaryPlaceholders.add(new LogMessage(message)); // log_message is out of order to allow for placeholder usage temporaryPlaceholders.add(new LogColorPrimary(level)); diff --git a/base/src/main/java/de/staropensource/sosengine/base/utility/Miscellaneous.java b/base/src/main/java/de/staropensource/sosengine/base/utility/Miscellaneous.java index 05e8de5..3ba1fe7 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/utility/Miscellaneous.java +++ b/base/src/main/java/de/staropensource/sosengine/base/utility/Miscellaneous.java @@ -20,6 +20,7 @@ package de.staropensource.sosengine.base.utility; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.lang.ref.WeakReference; import java.util.Map; @@ -75,7 +76,7 @@ public final class Miscellaneous { * @see Runnable * @since 1-alpha0 */ - public static long measureExecutionTime(Runnable runnable) { + public static long measureExecutionTime(@NotNull Runnable runnable) { long initTime = System.currentTimeMillis(); runnable.run(); return System.currentTimeMillis() - initTime; @@ -88,7 +89,7 @@ public final class Miscellaneous { * @param value value to search for * @since 1-alpha0 */ - public static Set getMapValue(Map map, Object value) { + public static Set getMapValue(@NotNull Map map, @Nullable Object value) { return map.entrySet().stream().filter(entry -> Objects.equals(entry.getValue(), value)).map(Map.Entry::getKey).collect(Collectors.toSet()); } } diff --git a/base/src/main/java/de/staropensource/sosengine/base/utility/PlaceholderEngine.java b/base/src/main/java/de/staropensource/sosengine/base/utility/PlaceholderEngine.java index 45a991b..62aacbd 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/utility/PlaceholderEngine.java +++ b/base/src/main/java/de/staropensource/sosengine/base/utility/PlaceholderEngine.java @@ -66,7 +66,7 @@ public final class PlaceholderEngine { @SuppressWarnings("FieldMayBeFinal") @Getter @NotNull - private List placeholders = new ArrayList<>(); + private List<@NotNull Placeholder> placeholders = new ArrayList<>(); /** * Constructor. @@ -127,7 +127,7 @@ public final class PlaceholderEngine { * @since 1-alpha0 */ @NotNull - public String process(@NotNull String text, List temporaryPlaceholders) { + public String process(@NotNull String text, List<@NotNull Placeholder> temporaryPlaceholders) { // Process temporary placeholders for (Placeholder temporaryPlaceholder : temporaryPlaceholders) if (text.contains("%" + temporaryPlaceholder.getName() + "%")) diff --git a/base/src/main/java/de/staropensource/sosengine/base/utility/StackTraceParser.java b/base/src/main/java/de/staropensource/sosengine/base/utility/StackTraceParser.java index 1a6ddec..c430cff 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/utility/StackTraceParser.java +++ b/base/src/main/java/de/staropensource/sosengine/base/utility/StackTraceParser.java @@ -63,6 +63,7 @@ public class StackTraceParser { * @return the stack trace header * @since 1-alpha0 */ + @NotNull public String getHeader() { if (throwable.getMessage() == null) return "Caused by: " + throwable.getClass().getName(); @@ -76,6 +77,7 @@ public class StackTraceParser { * @return the stack trace * @since 1-alpha0 */ + @NotNull public String getStackTrace() { StringBuilder output = new StringBuilder(); diff --git a/base/src/test/java/de/staropensource/sosengine/base/srctests/EngineConfigurationTest.java b/base/src/test/java/de/staropensource/sosengine/base/srctests/EngineConfigurationTest.java index 52e8826..f6a67dd 100644 --- a/base/src/test/java/de/staropensource/sosengine/base/srctests/EngineConfigurationTest.java +++ b/base/src/test/java/de/staropensource/sosengine/base/srctests/EngineConfigurationTest.java @@ -3,6 +3,7 @@ package de.staropensource.sosengine.base.srctests; import de.staropensource.sosengine.base.EngineConfiguration; import de.staropensource.sosengine.base.types.LogLevel; import de.staropensource.sosengine.unittests.UnitLogger; +import org.jetbrains.annotations.NotNull; import org.joor.Reflect; import org.junit.jupiter.api.*; @@ -49,8 +50,8 @@ class EngineConfigurationTest { void testLoadConfiguration() { logger.testCall("testLoadConfiguration"); - Map settings = new HashMap<>(); - Map defaultValues = new HashMap<>(); + Map<@NotNull String, @NotNull Object[]> settings = new HashMap<>(); + Map<@NotNull String, @NotNull Object> defaultValues = new HashMap<>(); settings.put("debug", new Object[]{ "true", Boolean.TRUE }); settings.put("debugShortcodeConverter", new Object[]{ "true", Boolean.TRUE }); diff --git a/base/src/test/java/de/staropensource/sosengine/base/srctests/utility/PlaceholderEngineTest.java b/base/src/test/java/de/staropensource/sosengine/base/srctests/utility/PlaceholderEngineTest.java index da160ec..a8207e8 100644 --- a/base/src/test/java/de/staropensource/sosengine/base/srctests/utility/PlaceholderEngineTest.java +++ b/base/src/test/java/de/staropensource/sosengine/base/srctests/utility/PlaceholderEngineTest.java @@ -37,7 +37,7 @@ class PlaceholderEngineTest { void testProcess(String text, String expected) { logger.testCall("testProcess", text, expected); - List placeholders = new ArrayList<>(); + List<@NotNull Placeholder> placeholders = new ArrayList<>(); placeholders.add(new Placeholder() { @Override public @NotNull String getName() { diff --git a/slf4j-compat/src/main/java/de/staropensource/sosengine/slf4j_compat/CompatibilityLoggerFactory.java b/slf4j-compat/src/main/java/de/staropensource/sosengine/slf4j_compat/CompatibilityLoggerFactory.java index 7b8721c..5a9ade6 100644 --- a/slf4j-compat/src/main/java/de/staropensource/sosengine/slf4j_compat/CompatibilityLoggerFactory.java +++ b/slf4j-compat/src/main/java/de/staropensource/sosengine/slf4j_compat/CompatibilityLoggerFactory.java @@ -19,6 +19,7 @@ package de.staropensource.sosengine.slf4j_compat; +import org.jetbrains.annotations.NotNull; import org.slf4j.ILoggerFactory; import org.slf4j.Logger; @@ -30,7 +31,7 @@ import java.util.concurrent.ConcurrentMap; */ @SuppressWarnings({ "unused", "JavadocBlankLines" }) public class CompatibilityLoggerFactory implements ILoggerFactory { - ConcurrentMap loggerMap; + ConcurrentMap<@NotNull String, @NotNull Logger> loggerMap; public CompatibilityLoggerFactory() { loggerMap = new ConcurrentHashMap<>();