forked from StarOpenSource/Engine
MASSIVE CODE CHANGE
tl;dr I changed many Javadoc comments, some code, removed dumb or unused stuff and revamped the entire logging infrastructure by yeeting out LogIssuer and CodePart and much, much more
This commit is contained in:
parent
5be690fd38
commit
f383261ed9
239 changed files with 2867 additions and 2497 deletions
|
@ -20,50 +20,46 @@
|
|||
package de.staropensource.sosengine.ansi;
|
||||
|
||||
import de.staropensource.sosengine.base.EngineConfiguration;
|
||||
import de.staropensource.sosengine.base.classes.LoggerImpl;
|
||||
import de.staropensource.sosengine.base.classes.LoggerImplementation;
|
||||
import de.staropensource.sosengine.base.logging.Logger;
|
||||
import de.staropensource.sosengine.base.types.logging.LogIssuer;
|
||||
import de.staropensource.sosengine.base.types.logging.LogLevel;
|
||||
import org.fusesource.jansi.Ansi;
|
||||
import org.fusesource.jansi.AnsiConsole;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Parses and prints colored log output using the Jansi library.
|
||||
* Prints colored log output using the Jansi library.
|
||||
*
|
||||
* @see Logger
|
||||
* @see LoggerImpl
|
||||
* @since v1-alpha0
|
||||
* @see LoggerImplementation
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public class AnsiLoggerImpl implements LoggerImpl {
|
||||
public class AnsiLoggerImplementation implements LoggerImplementation {
|
||||
/**
|
||||
* Constructs this class.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
public AnsiLoggerImpl() {}
|
||||
public AnsiLoggerImplementation() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String prePlaceholder(@NotNull LogLevel level, @NotNull LogIssuer logIssuer, @NotNull String message) {
|
||||
// No modifications necessary
|
||||
return message;
|
||||
public @NotNull String prePlaceholder(@NotNull LogLevel level, @NotNull Class<?> issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message, @NotNull String format) {
|
||||
return format; // No modifications necessary
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String postPlaceholder(@NotNull LogLevel level, @NotNull LogIssuer logIssuer, @NotNull String format) {
|
||||
// No modifications necessary
|
||||
return format;
|
||||
public @NotNull String postPlaceholder(@NotNull LogLevel level, @NotNull Class<?> issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message, @NotNull String format) {
|
||||
return format; // No modifications necessary
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@SuppressWarnings({ "resource" }) // Using try-with-resources will cause issues here
|
||||
@Override
|
||||
public void print(@NotNull LogLevel level, @NotNull LogIssuer logIssuer, @NotNull String format) {
|
||||
public void print(@NotNull LogLevel level, @NotNull Class<?> issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message, @NotNull String format) {
|
||||
// Convert to Ansi
|
||||
Ansi output = new AnsiShortcodeConverter(format, true).getAnsi();
|
||||
|
|
@ -28,7 +28,7 @@ import org.jetbrains.annotations.NotNull;
|
|||
* Converts shortcodes such as {@code <bold>} or {@code <blink>} into a usable {@link Ansi} escape sequence.
|
||||
*
|
||||
* @see ShortcodeParserSkeleton
|
||||
* @since v1-alpha0
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public final class AnsiShortcodeConverter extends ShortcodeParserSkeleton {
|
||||
|
@ -38,7 +38,7 @@ public final class AnsiShortcodeConverter extends ShortcodeParserSkeleton {
|
|||
* @param string string to convert
|
||||
* @param ignoreInvalidEscapes will ignore invalid escapes and print treat them like regular text
|
||||
* @throws ParserException when parsing failed
|
||||
* @since v1-alpha0
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
public AnsiShortcodeConverter(@NotNull String string, boolean ignoreInvalidEscapes) throws ParserException {
|
||||
super(string, ignoreInvalidEscapes);
|
||||
|
@ -48,10 +48,9 @@ public final class AnsiShortcodeConverter extends ShortcodeParserSkeleton {
|
|||
* Returns the parsed string as an {@link Ansi} sequence.
|
||||
*
|
||||
* @return {@link Ansi} sequence
|
||||
* @since v1-alpha0
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
@NotNull
|
||||
public Ansi getAnsi() {
|
||||
public @NotNull Ansi getAnsi() {
|
||||
Ansi ansi = Ansi.ansi();
|
||||
|
||||
for (String component : components)
|
||||
|
|
|
@ -20,71 +20,63 @@
|
|||
package de.staropensource.sosengine.ansi;
|
||||
|
||||
import de.staropensource.sosengine.base.annotations.EngineSubsystem;
|
||||
import de.staropensource.sosengine.base.classes.SubsystemMainClass;
|
||||
import de.staropensource.sosengine.base.data.info.EngineInformation;
|
||||
import de.staropensource.sosengine.base.classes.SubsystemClass;
|
||||
import de.staropensource.sosengine.base.data.information.EngineInformation;
|
||||
import de.staropensource.sosengine.base.data.versioning.StarOpenSourceVersioningSystem;
|
||||
import de.staropensource.sosengine.base.logging.Logger;
|
||||
import de.staropensource.sosengine.base.logging.LoggerInstance;
|
||||
import de.staropensource.sosengine.base.types.CodePart;
|
||||
import de.staropensource.sosengine.base.types.DependencyVector;
|
||||
import de.staropensource.sosengine.base.types.logging.LogIssuer;
|
||||
import lombok.Getter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Main object for the ANSI Compatibility subsystem.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
@SuppressWarnings({ "unused", "JavadocDeclaration", "JavadocBlankLines" })
|
||||
@SuppressWarnings({ "unused", "JavadocDeclaration" })
|
||||
@EngineSubsystem
|
||||
public final class AnsiSubsystem implements SubsystemMainClass {
|
||||
public final class AnsiSubsystem extends SubsystemClass {
|
||||
/**
|
||||
* Contains the class instance.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*
|
||||
* @since v1-alpha2
|
||||
* -- GETTER --
|
||||
* Returns the class instance.
|
||||
*
|
||||
* @return class instance unless the subsystem is uninitialized
|
||||
* @since v1-alpha0
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
@Getter
|
||||
private static AnsiSubsystem instance = null;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
private final LoggerInstance logger = new LoggerInstance(new LogIssuer(getClass(), CodePart.ENGINE));
|
||||
|
||||
/**
|
||||
* Constructs this subsystem.
|
||||
*
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
public AnsiSubsystem() {
|
||||
// Check if subsystem has already initialized
|
||||
if (instance == null)
|
||||
instance = this;
|
||||
else {
|
||||
instance.logger.crash("The subsystem tried to initialize twice");
|
||||
}
|
||||
else
|
||||
logger.crash("Only one instance of this class is allowed, use getInstance() instead of creating a new instance");
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
public @NotNull String getName() {
|
||||
return "ansi";
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void initializeSubsystem() {
|
||||
Logger.setLoggerImplementation(new AnsiLoggerImpl());
|
||||
Logger.setLoggerImplementation(new AnsiLoggerImplementation());
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public DependencyVector getDependencyVector() {
|
||||
public @NotNull DependencyVector getDependencyVector() {
|
||||
return new DependencyVector("ansi", StarOpenSourceVersioningSystem.class, EngineInformation.getVersioningString());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Defines the ANSI subsystem, allowing the engine to
|
||||
* The ANSI subsystem, allowing the engine to
|
||||
* use ANSI escape codes using the Jansi library.
|
||||
*
|
||||
* @since v1-alpha2
|
||||
|
|
|
@ -20,9 +20,9 @@
|
|||
package de.staropensource.sosengine.base;
|
||||
|
||||
import de.staropensource.sosengine.base.annotations.EngineSubsystem;
|
||||
import de.staropensource.sosengine.base.classes.SubsystemMainClass;
|
||||
import de.staropensource.sosengine.base.classes.SubsystemClass;
|
||||
import de.staropensource.sosengine.base.classes.helpers.EventHelper;
|
||||
import de.staropensource.sosengine.base.data.info.EngineInformation;
|
||||
import de.staropensource.sosengine.base.data.information.EngineInformation;
|
||||
import de.staropensource.sosengine.base.data.versioning.StarOpenSourceVersioningSystem;
|
||||
import de.staropensource.sosengine.base.events.*;
|
||||
import de.staropensource.sosengine.base.exceptions.dependency.UnmetDependenciesException;
|
||||
|
@ -31,10 +31,8 @@ import de.staropensource.sosengine.base.internal.types.DependencySubsystemVector
|
|||
import de.staropensource.sosengine.base.logging.CrashHandler;
|
||||
import de.staropensource.sosengine.base.logging.Logger;
|
||||
import de.staropensource.sosengine.base.logging.LoggerInstance;
|
||||
import de.staropensource.sosengine.base.types.CodePart;
|
||||
import de.staropensource.sosengine.base.types.DependencyVector;
|
||||
import de.staropensource.sosengine.base.types.immutable.ImmutableLinkedList;
|
||||
import de.staropensource.sosengine.base.types.logging.LogIssuer;
|
||||
import de.staropensource.sosengine.base.utility.DependencyResolver;
|
||||
import de.staropensource.sosengine.base.utility.Miscellaneous;
|
||||
import de.staropensource.sosengine.base.utility.PlaceholderEngine;
|
||||
|
@ -49,24 +47,22 @@ import org.reflections.util.ConfigurationBuilder;
|
|||
import java.util.*;
|
||||
|
||||
/**
|
||||
* sos!engine management object.<br/>
|
||||
* It is responsible for the base engine initialization.
|
||||
* Main class of the sos!engine.
|
||||
*
|
||||
* @see EngineConfiguration
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@SuppressWarnings({ "unused", "JavadocDeclaration", "JavadocBlankLines" })
|
||||
@SuppressWarnings({ "unused", "JavadocDeclaration" })
|
||||
@EngineSubsystem
|
||||
public final class Engine implements SubsystemMainClass {
|
||||
public final class Engine extends SubsystemClass {
|
||||
/**
|
||||
* Contains the class instance.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*
|
||||
* -- GETTER --
|
||||
* Returns the class instance.
|
||||
*
|
||||
* @return class instance unless the engine is uninitialized
|
||||
* @return class instance unless {@link Engine} is uninitialized
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@Getter
|
||||
|
@ -76,7 +72,6 @@ public final class Engine implements SubsystemMainClass {
|
|||
* Contains the thread group of the engine.
|
||||
*
|
||||
* @since v1-alpha2
|
||||
*
|
||||
* -- GETTER --
|
||||
* Returns the thread group of the engine.
|
||||
*
|
||||
|
@ -87,19 +82,18 @@ public final class Engine implements SubsystemMainClass {
|
|||
private static final ThreadGroup threadGroup = new ThreadGroup("sos!engine");
|
||||
|
||||
/**
|
||||
* Logger instance.
|
||||
* Contains the {@link LoggerInstance} for this instance.
|
||||
*
|
||||
* @see LoggerInstance
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
private LoggerInstance logger;
|
||||
private static LoggerInstance logger;
|
||||
|
||||
/**
|
||||
* Contains a list of all registered subsystems.
|
||||
* The list is sorted after initialization order.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*
|
||||
* -- GETTER --
|
||||
* Returns a list of all registered subsystems.
|
||||
* The list is sorted after initialization order.
|
||||
|
@ -107,19 +101,17 @@ public final class Engine implements SubsystemMainClass {
|
|||
* @return subsystem list
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
@NotNull
|
||||
@Getter
|
||||
private ImmutableLinkedList<@NotNull DependencySubsystemVector> subsystems = new ImmutableLinkedList<>();
|
||||
private @NotNull ImmutableLinkedList<@NotNull DependencySubsystemVector> subsystems = new ImmutableLinkedList<>();
|
||||
|
||||
/**
|
||||
* Indicates if the engine is shutting down.
|
||||
* Contains if the engine is shutting down.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*
|
||||
* -- GETTER --
|
||||
* Returns if the engine is shutting down.
|
||||
*
|
||||
* @return if the engine is shutting down
|
||||
* @return shutdown status
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
@Getter
|
||||
|
@ -138,18 +130,18 @@ public final class Engine implements SubsystemMainClass {
|
|||
return;
|
||||
|
||||
long initTime = Miscellaneous.measureExecutionTime(() -> {
|
||||
// Initialize variables
|
||||
logger = new LoggerInstance(new LogIssuer(getClass(), CodePart.ENGINE));
|
||||
|
||||
// Initialize EngineConfiguration and load it
|
||||
// Initialize engine configuration
|
||||
new EngineConfiguration();
|
||||
EngineConfiguration.getInstance().loadConfiguration();
|
||||
|
||||
initializeClasses(); // Initialize classes
|
||||
populateCrashContent(); // Populate crash content
|
||||
precomputeEventListeners(); // Precompute event listeners
|
||||
cacheEvents(); // Cache event listeners
|
||||
startThreads(); // Start threads
|
||||
|
||||
// Set the logger instance
|
||||
logger = new LoggerInstance.Builder().setClazz(getClass()).setOrigin("ENGINE").setMetadata(EngineInformation.getVersioningCodename()).build();
|
||||
|
||||
// Perform automatic subsystem initialization
|
||||
if (EngineConfiguration.getInstance().isOptimizeSubsystemInitialization()) {
|
||||
collectSubsystems(); // Collect subsystems
|
||||
|
@ -172,14 +164,13 @@ public final class Engine implements SubsystemMainClass {
|
|||
* @since v1-alpha0
|
||||
*/
|
||||
private void initializeClasses() {
|
||||
// Sorted in rough order of dependence
|
||||
new PlaceholderEngine();
|
||||
|
||||
EngineInformation.updateVariables();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method populates the Crash Handler's content with the default set of content.
|
||||
* This method populates {@link CrashHandler#crashContent} with content.
|
||||
*
|
||||
* @see CrashHandler#getCrashContent()
|
||||
* @since v1-alpha0
|
||||
|
@ -188,10 +179,10 @@ public final class Engine implements SubsystemMainClass {
|
|||
private void populateCrashContent() {
|
||||
// Issuer
|
||||
Map<@NotNull String, @NotNull String> crashContentIssuer = new LinkedHashMap<>();
|
||||
crashContentIssuer.put("Code part", "%issuer_code_part%");
|
||||
crashContentIssuer.put("Code part", "%issuer_origin%");
|
||||
crashContentIssuer.put("Classpath", "%issuer_path%");
|
||||
crashContentIssuer.put("Additional information", "%issuer_info%");
|
||||
crashContentIssuer.put("Message", "%issuer_message%");
|
||||
crashContentIssuer.put("Additional information", "%issuer_metadata%");
|
||||
crashContentIssuer.put("Message", "%crash_message%");
|
||||
|
||||
// Engine -> Dependencies -> base
|
||||
Map<@NotNull String, @NotNull String> crashContentEngineDependenciesBase = new LinkedHashMap<>();
|
||||
|
@ -241,20 +232,20 @@ public final class Engine implements SubsystemMainClass {
|
|||
}
|
||||
|
||||
/**
|
||||
* Precomputes all base engine events.
|
||||
* Caches all base engine events.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
private void precomputeEventListeners() {
|
||||
private void cacheEvents() {
|
||||
// Internal events
|
||||
EventHelper.precomputeEventListeners(InternalEngineShutdownEvent.class);
|
||||
EventHelper.cacheEvent(InternalEngineShutdownEvent.class);
|
||||
|
||||
// General events
|
||||
EventHelper.precomputeEventListeners(EngineCrashEvent.class);
|
||||
EventHelper.precomputeEventListeners(EngineShutdownEvent.class);
|
||||
EventHelper.precomputeEventListeners(EngineSoftCrashEvent.class);
|
||||
EventHelper.precomputeEventListeners(LogEvent.class);
|
||||
EventHelper.precomputeEventListeners(ThrowableCatchEvent.class);
|
||||
EventHelper.cacheEvent(EngineCrashEvent.class);
|
||||
EventHelper.cacheEvent(EngineShutdownEvent.class);
|
||||
EventHelper.cacheEvent(EngineSoftCrashEvent.class);
|
||||
EventHelper.cacheEvent(LogEvent.class);
|
||||
EventHelper.cacheEvent(ThrowableCatchEvent.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -280,13 +271,13 @@ public final class Engine implements SubsystemMainClass {
|
|||
try {
|
||||
// Create new instance
|
||||
Object initializedClassRaw = clazz.getDeclaredConstructor().newInstance();
|
||||
SubsystemMainClass initializedClass = null;
|
||||
SubsystemClass initializedClass = null;
|
||||
|
||||
// Check if class implements SubsystemMainClass
|
||||
if (initializedClassRaw instanceof SubsystemMainClass subsystemInstance)
|
||||
if (initializedClassRaw instanceof SubsystemClass subsystemInstance)
|
||||
initializedClass = subsystemInstance;
|
||||
else
|
||||
logger.crash("Failed to initialize subsystem " + clazz.getName() + ": Does not implement " + SubsystemMainClass.class.getName());
|
||||
logger.crash("Failed to initialize subsystem " + clazz.getName() + ": Does not implement " + SubsystemClass.class.getName());
|
||||
|
||||
//noinspection DataFlowIssue // the crash call will prevent a NullPointerException
|
||||
subsystemsMutable.add(new DependencySubsystemVector(initializedClass.getDependencyVector(), initializedClass));
|
||||
|
@ -362,7 +353,7 @@ public final class Engine implements SubsystemMainClass {
|
|||
}
|
||||
|
||||
/**
|
||||
* Shuts the engine and JVM down.
|
||||
* Shuts the engine down.
|
||||
*
|
||||
* @param exitCode code to exit with, from 0-255
|
||||
* @since v1-alpha0
|
||||
|
@ -396,20 +387,18 @@ public final class Engine implements SubsystemMainClass {
|
|||
}
|
||||
|
||||
/**
|
||||
* Shuts the engine and JVM down.
|
||||
* Shuts the engine down.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public void shutdown() {
|
||||
shutdown(0);
|
||||
if (instance != null)
|
||||
instance.shutdown(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@NotNull
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public String getName() {
|
||||
public @NotNull String getName() {
|
||||
return "base";
|
||||
}
|
||||
|
||||
|
@ -423,9 +412,8 @@ public final class Engine implements SubsystemMainClass {
|
|||
* @see DependencyVector
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
@NotNull
|
||||
@Override
|
||||
public DependencyVector getDependencyVector() {
|
||||
public @NotNull DependencyVector getDependencyVector() {
|
||||
return new DependencyVector("engine", StarOpenSourceVersioningSystem.class, EngineInformation.getVersioningString());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,14 +20,12 @@
|
|||
package de.staropensource.sosengine.base;
|
||||
|
||||
import de.staropensource.sosengine.base.classes.ShortcodeParserSkeleton;
|
||||
import de.staropensource.sosengine.base.classes.SubsystemConfiguration;
|
||||
import de.staropensource.sosengine.base.classes.Configuration;
|
||||
import de.staropensource.sosengine.base.classes.helpers.EventHelper;
|
||||
import de.staropensource.sosengine.base.logging.CrashHandler;
|
||||
import de.staropensource.sosengine.base.logging.Logger;
|
||||
import de.staropensource.sosengine.base.types.CodePart;
|
||||
import de.staropensource.sosengine.base.types.logging.LogIssuer;
|
||||
import de.staropensource.sosengine.base.types.logging.LogLevel;
|
||||
import de.staropensource.sosengine.base.types.vectors.Vec2;
|
||||
import de.staropensource.sosengine.base.types.vectors.Vec2f;
|
||||
import de.staropensource.sosengine.base.utility.parser.PropertyParser;
|
||||
import lombok.Getter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -42,7 +40,7 @@ import java.util.Properties;
|
|||
* responsible for loading them into memory from {@link Properties} objects.
|
||||
* <p>
|
||||
* Now you might ask why we didn't go with the string-based approach.
|
||||
* The answer is simple: It's a maintenance and documentation burden.
|
||||
* The answer is simple: It's a maintenance burden.
|
||||
* Having various settings strings scattered across many classes will cause
|
||||
* trouble at some point, which will cause some strings to be undocumented
|
||||
* or have an inconsistent naming scheme. Containing settings as variables in
|
||||
|
@ -50,14 +48,13 @@ import java.util.Properties;
|
|||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@SuppressWarnings({ "unused", "JavadocDeclaration", "JavadocBlankLines" })
|
||||
@SuppressWarnings({ "unused", "JavadocDeclaration" })
|
||||
@Getter
|
||||
public final class EngineConfiguration implements SubsystemConfiguration {
|
||||
public final class EngineConfiguration extends Configuration {
|
||||
/**
|
||||
* Contains the class instance.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*
|
||||
* -- GETTER --
|
||||
* Returns the class instance.
|
||||
*
|
||||
|
@ -68,26 +65,23 @@ public final class EngineConfiguration implements SubsystemConfiguration {
|
|||
private static EngineConfiguration instance;
|
||||
|
||||
/**
|
||||
* Defines the group every property must start with to be recognized as a subsystem configuration setting.
|
||||
* Contains the group in which setting overrides must begin with..
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*
|
||||
* -- GETTER --
|
||||
* Returns the group that every property must start with to be recognized as a subsystem configuration setting.
|
||||
* Returns the group in which setting overrides must begin with.
|
||||
*
|
||||
* @return property group
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@NotNull
|
||||
@Getter
|
||||
private static final String group = "sosengine.base.";
|
||||
private final @NotNull String group = "sosengine.base.";
|
||||
|
||||
/**
|
||||
* If enabled, allows for unintentional behaviour and excess logging.<br/>
|
||||
* If enabled, allows for unintentional behaviour and excess logging.
|
||||
* Unless you want to debug or work on a sensitive part of the engine, don't enable this!
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*
|
||||
* -- GETTER --
|
||||
* Gets the value for {@link #debug}.
|
||||
*
|
||||
|
@ -102,7 +96,6 @@ public final class EngineConfiguration implements SubsystemConfiguration {
|
|||
*
|
||||
* @see EventHelper#logCall(Class, Object...)
|
||||
* @since v1-alpha0
|
||||
*
|
||||
* -- GETTER --
|
||||
* Gets the value for {@link #debugEvents}.
|
||||
*
|
||||
|
@ -118,7 +111,6 @@ public final class EngineConfiguration implements SubsystemConfiguration {
|
|||
*
|
||||
* @see ShortcodeParserSkeleton
|
||||
* @since v1-alpha0
|
||||
*
|
||||
* -- GETTER --
|
||||
* Gets the value for {@link #debugShortcodeConverter}.
|
||||
*
|
||||
|
@ -135,7 +127,6 @@ public final class EngineConfiguration implements SubsystemConfiguration {
|
|||
* @see ShortcodeParserSkeleton
|
||||
* @see #loggerLevel
|
||||
* @since v1-alpha0
|
||||
*
|
||||
* -- GETTER --
|
||||
* Gets the value for {@link #errorShortcodeConverter}.
|
||||
*
|
||||
|
@ -152,7 +143,6 @@ public final class EngineConfiguration implements SubsystemConfiguration {
|
|||
* @see #loggerPollingSpeed
|
||||
* @see Thread
|
||||
* @since v1-alpha0
|
||||
*
|
||||
* -- GETTER --
|
||||
* Gets the value for {@link #optimizeLogging}.
|
||||
*
|
||||
|
@ -168,7 +158,6 @@ public final class EngineConfiguration implements SubsystemConfiguration {
|
|||
*
|
||||
* @see VirtualThread
|
||||
* @since v1-alpha0
|
||||
*
|
||||
* -- GETTER --
|
||||
* Gets the value for {@link #optimizeEvents}.
|
||||
*
|
||||
|
@ -188,7 +177,6 @@ public final class EngineConfiguration implements SubsystemConfiguration {
|
|||
*
|
||||
* @see Engine
|
||||
* @since v1-alpha2
|
||||
*
|
||||
* -- GETTER --
|
||||
* Gets the value for {@link #optimizeSubsystemInitialization}.
|
||||
*
|
||||
|
@ -199,11 +187,10 @@ public final class EngineConfiguration implements SubsystemConfiguration {
|
|||
private boolean optimizeSubsystemInitialization;
|
||||
|
||||
/**
|
||||
* Determines which logger levels are allowed by setting the minimum logger level.
|
||||
* Contains which logger levels are allowed by setting the minimum logger level.
|
||||
*
|
||||
* @see Logger
|
||||
* @since v1-alpha0
|
||||
*
|
||||
* -- GETTER --
|
||||
* Gets the value for {@link #loggerLevel}.
|
||||
*
|
||||
|
@ -218,7 +205,6 @@ public final class EngineConfiguration implements SubsystemConfiguration {
|
|||
*
|
||||
* @see Logger
|
||||
* @since v1-alpha0
|
||||
*
|
||||
* -- GETTER --
|
||||
* Gets the value for {@link #loggerTemplate}
|
||||
*
|
||||
|
@ -229,12 +215,11 @@ public final class EngineConfiguration implements SubsystemConfiguration {
|
|||
private String loggerTemplate;
|
||||
|
||||
/**
|
||||
* If enabled, the JVM will immediately shutdown on an engine crash. This will prevent shutdown hooks from executing.<br/>
|
||||
* If enabled, the JVM will immediately shutdown on an engine crash. This will prevent shutdown hooks from executing.
|
||||
* Note: This will also prevent Jansi and potentially other libraries from removing temporary native libraries at shutdown.
|
||||
*
|
||||
* @see CrashHandler
|
||||
* @since v1-alpha0
|
||||
*
|
||||
* -- GETTER --
|
||||
* Gets the value for {@link #loggerImmediateShutdown}.
|
||||
*
|
||||
|
@ -249,7 +234,6 @@ public final class EngineConfiguration implements SubsystemConfiguration {
|
|||
* instead of <a href="https://www.man7.org/linux/man-pages/man3/stderr.3.html">the standard error</a> for logging {@code ERROR} and {@code CRASH}.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*
|
||||
* -- GETTER --
|
||||
* Gets the value for {@link #loggerForceStandardOutput}.
|
||||
*
|
||||
|
@ -260,12 +244,11 @@ public final class EngineConfiguration implements SubsystemConfiguration {
|
|||
private boolean loggerForceStandardOutput;
|
||||
|
||||
/**
|
||||
* Determines how fast the logging thread will poll for queued messages.
|
||||
* Contains how fast the logging thread will poll for queued messages.
|
||||
* Only applies if {@code optimizeLogging} is turned on.
|
||||
*
|
||||
* @see #optimizeLogging
|
||||
* @since v1-alpha1
|
||||
*
|
||||
* -- GETTER --
|
||||
* Gets the value for {@link #loggerForceStandardOutput}.
|
||||
*
|
||||
|
@ -278,13 +261,12 @@ public final class EngineConfiguration implements SubsystemConfiguration {
|
|||
/**
|
||||
* Will truncate the path of types when using their {@code toString} method.
|
||||
* <p>
|
||||
* Here's an example: Lets say that you have a {@link Vec2} and to convert it
|
||||
* to a String, which you can do with {@link Vec2#toString()}. With this flag disabled
|
||||
* Here's an example: Lets say that you have a {@link Vec2f} and to convert it
|
||||
* to a String, which you can do with {@link Vec2f#toString()}. With this flag disabled
|
||||
* it would return {@code de.staropensource.sosengine.base.types.vectors.Vec2(x=64 y=64)},
|
||||
* with it however it would be {@code Vec2(x=64 y=64)}, which is much smaller.
|
||||
*
|
||||
* @since v1-alpha2
|
||||
*
|
||||
* -- GETTER --
|
||||
* Gets the value for {@link #hideFullTypePath}.
|
||||
*
|
||||
|
@ -301,31 +283,21 @@ public final class EngineConfiguration implements SubsystemConfiguration {
|
|||
* @since v1-alpha0
|
||||
*/
|
||||
public EngineConfiguration() {
|
||||
super("ENGINE"); // TODO Wait for flexible constructor bodies (JEP 482) to be implemented into the JVM as a stable feature. We don't want to use preview features in production code.
|
||||
|
||||
// Only allow one instance
|
||||
if (instance == null)
|
||||
instance = this;
|
||||
else
|
||||
Logger.crash(new LogIssuer(getClass(), CodePart.ENGINE), "Tried initializing " + getClass().getName() + " twice");
|
||||
logger.crash("Only one instance of this class is allowed, use getInstance() instead of creating a new instance");
|
||||
|
||||
// Load default configuration
|
||||
loadDefaultConfiguration();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public synchronized void loadConfiguration(@NotNull Properties properties) {
|
||||
// Define variables
|
||||
PropertyParser parser = new PropertyParser(properties);
|
||||
|
||||
// Loop through all properties
|
||||
for (String property : properties.stringPropertyNames()) {
|
||||
// Check if property name starts with group
|
||||
if (!property.startsWith(group))
|
||||
continue;
|
||||
|
||||
// Skip to important stuff
|
||||
property = property.substring(group.length());
|
||||
|
||||
// Overwrite matching settings
|
||||
@Override
|
||||
protected void matchProperty(@NotNull PropertyParser parser, @NotNull String property) {
|
||||
try {
|
||||
switch (property) {
|
||||
case "debug" -> debug = parser.getBoolean(group + property);
|
||||
|
@ -355,6 +327,9 @@ public final class EngineConfiguration implements SubsystemConfiguration {
|
|||
} catch (NullPointerException ignored) {}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void processSettings(@NotNull PropertyParser parser) {
|
||||
// Disable all debugging switches if 'debug' is disabled
|
||||
if (!debug) {
|
||||
debugEvents = false;
|
||||
|
@ -363,12 +338,8 @@ public final class EngineConfiguration implements SubsystemConfiguration {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public synchronized void loadConfiguration() {
|
||||
loadConfiguration(System.getProperties());
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public synchronized void loadDefaultConfiguration() {
|
||||
@Override
|
||||
public void loadDefaultConfiguration() {
|
||||
debug = false;
|
||||
debugEvents = false;
|
||||
debugShortcodeConverter = false;
|
||||
|
@ -389,8 +360,8 @@ public final class EngineConfiguration implements SubsystemConfiguration {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Nullable
|
||||
public Object getSetting(@NotNull String setting) {
|
||||
@Override
|
||||
public @Nullable Object getSetting(@NotNull String setting) {
|
||||
switch (setting) {
|
||||
case "debug" -> { return debug; }
|
||||
case "debugEvents" -> { return debugEvents; }
|
||||
|
|
|
@ -19,16 +19,15 @@
|
|||
|
||||
package de.staropensource.sosengine.base.annotations;
|
||||
|
||||
import de.staropensource.sosengine.base.classes.SubsystemMainClass;
|
||||
import de.staropensource.sosengine.base.classes.SubsystemClass;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* This annotation marks a class as a subsystem main class.
|
||||
* <p>
|
||||
* Make sure your subsystem implements {@link SubsystemMainClass}.
|
||||
* Marks a class as a subsystem main class.
|
||||
* Make sure your subsystem implements {@link SubsystemClass}.
|
||||
*
|
||||
* @see SubsystemMainClass
|
||||
* @see SubsystemClass
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
|
|
|
@ -26,7 +26,8 @@ import org.jetbrains.annotations.NotNull;
|
|||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* This annotation allows methods to listen on certain events.
|
||||
* Marks a method as an event listener, allowing it
|
||||
* to respond to an events when it is emitted.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
|
@ -36,18 +37,20 @@ import java.lang.annotation.*;
|
|||
@Documented
|
||||
public @interface EventListener {
|
||||
/**
|
||||
* The event to listen for.
|
||||
* Specifies the event to listen for.
|
||||
*
|
||||
* @return the event the method listens for
|
||||
* @return event to listen on
|
||||
* @see Event
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@NotNull
|
||||
Class<? extends Event> event();
|
||||
@NotNull Class<? extends Event> event();
|
||||
|
||||
/**
|
||||
* The priority of the event.
|
||||
* Specifies the priority of the event.
|
||||
*
|
||||
* @return the event priority
|
||||
* @return event priority
|
||||
* @see EventPriority
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@NotNull
|
||||
EventPriority priority() default EventPriority.DEFAULT;
|
||||
@NotNull EventPriority priority() default EventPriority.DEFAULT;
|
||||
}
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* Contains annotations that are used by the engine
|
||||
* to dynamically invoke methods or register classes.
|
||||
* Annotations used by the sos!engine to access
|
||||
* classes and methods using reflection.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,146 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||
* Licensed under the GNU Affero General Public License v3
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.staropensource.sosengine.base.classes;
|
||||
|
||||
import de.staropensource.sosengine.base.logging.LoggerInstance;
|
||||
import de.staropensource.sosengine.base.utility.parser.PropertyParser;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* Interface for implementing configuration classes.
|
||||
* <p>
|
||||
* Configuration classes use {@link Properties} objects to modify
|
||||
* their settings as they can be supplied to the JVM's arguments
|
||||
* and can be written to and read from during runtime.
|
||||
*
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public abstract class Configuration {
|
||||
/**
|
||||
* Contains the {@link LoggerInstance} for this instance.
|
||||
*
|
||||
* @see LoggerInstance
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
protected final @NotNull LoggerInstance logger;
|
||||
|
||||
/**
|
||||
* Constructs this class.
|
||||
*
|
||||
* @param origin see {@link LoggerInstance.Builder#setOrigin(String)}
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
public Configuration(@NotNull String origin) {
|
||||
// Set logger instance
|
||||
logger = new LoggerInstance.Builder().setClazz(getClass()).setOrigin(origin).build();
|
||||
|
||||
// Load default configuration
|
||||
loadDefaultConfiguration();
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads all settings from the specified {@link Properties} object.
|
||||
* Unless you want to override settings, consider invoking {@link #loadDefaultConfiguration()} first.
|
||||
*
|
||||
* @param properties {@link Properties} to read from
|
||||
* @see #loadDefaultConfiguration()
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
public void loadConfiguration(@NotNull Properties properties) {
|
||||
PropertyParser parser = new PropertyParser(properties);
|
||||
|
||||
// Loop through all properties
|
||||
for (String property : properties.stringPropertyNames()) {
|
||||
// Check if property name starts with group
|
||||
if (!property.startsWith(getGroup()))
|
||||
continue;
|
||||
|
||||
// Remove group
|
||||
property = property.substring(getGroup().length());
|
||||
|
||||
// Overwrite matching settings
|
||||
try {
|
||||
matchProperty(parser, property);
|
||||
} catch (NullPointerException ignored) {}
|
||||
}
|
||||
|
||||
processSettings(parser);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads all settings from the system properties.
|
||||
* Useful if you want to allow the user to modify settings at startup.
|
||||
*
|
||||
* @see #loadConfiguration(Properties)
|
||||
* @see System#getProperties()
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
public void loadConfiguration() {
|
||||
loadConfiguration(System.getProperties());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the group in which setting overrides must begin with.
|
||||
*
|
||||
* @return property group
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
public abstract @NotNull String getGroup();
|
||||
|
||||
/**
|
||||
* Loads the default subsystem configuration.
|
||||
*
|
||||
* @see #loadConfiguration()
|
||||
* @see #loadConfiguration(Properties)
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public abstract void loadDefaultConfiguration();
|
||||
|
||||
/**
|
||||
* Matches the given {@code property} against all settings.
|
||||
* If a match has been found, the setting will be overwritten with the property's value.
|
||||
*
|
||||
* @param parser matching {@link PropertyParser}
|
||||
* @param property property to match
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
protected abstract void matchProperty(@NotNull PropertyParser parser, @NotNull String property);
|
||||
|
||||
/**
|
||||
* Allows the implementor to process all settings and potentially
|
||||
* modify them before {@link #loadConfiguration(Properties)} returns.
|
||||
*
|
||||
* @param parser matching {@link PropertyParser}
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
protected abstract void processSettings(@NotNull PropertyParser parser);
|
||||
|
||||
/**
|
||||
* Returns a configuration setting.
|
||||
*
|
||||
* @param setting setting name
|
||||
* @return setting's value or {@code null} if not found
|
||||
*/
|
||||
public abstract @Nullable Object getSetting(@NotNull String setting);
|
||||
}
|
|
@ -19,15 +19,18 @@
|
|||
|
||||
package de.staropensource.sosengine.base.classes;
|
||||
|
||||
import de.staropensource.sosengine.base.classes.helpers.EventHelper;
|
||||
|
||||
/**
|
||||
* Represents an event.
|
||||
*
|
||||
* @see EventHelper
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public interface Event {
|
||||
/**
|
||||
* Calls the event and notifies all annotated methods.
|
||||
* Emits the event and calls all event listeners.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
|
|
|
@ -1,67 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||
* Licensed under the GNU Affero General Public License v3
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.staropensource.sosengine.base.classes;
|
||||
|
||||
import de.staropensource.sosengine.base.types.logging.LogIssuer;
|
||||
import de.staropensource.sosengine.base.types.logging.LogLevel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Interface for implementing custom logger implementations, called by {@link de.staropensource.sosengine.base.logging.Logger}.
|
||||
*
|
||||
* @see de.staropensource.sosengine.base.logging.Logger
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public interface LoggerImpl {
|
||||
/**
|
||||
* Run before placeholders are replaced.
|
||||
*
|
||||
* @param level log level
|
||||
* @param logIssuer log issuer
|
||||
* @param message log message
|
||||
* @return new log message
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@NotNull
|
||||
String prePlaceholder(@NotNull LogLevel level, @NotNull LogIssuer logIssuer, @NotNull String message);
|
||||
|
||||
/**
|
||||
* Run after placeholders are replaced.
|
||||
*
|
||||
* @param level log level
|
||||
* @param logIssuer log issuer
|
||||
* @param format log format
|
||||
* @return new log format
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@NotNull
|
||||
String postPlaceholder(@NotNull LogLevel level, @NotNull LogIssuer logIssuer, @NotNull String format);
|
||||
|
||||
/**
|
||||
* Responsible for printing the finalized log message.
|
||||
*
|
||||
* @param level log level
|
||||
* @param logIssuer log issuer
|
||||
* @param format finalized log format
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
void print(@NotNull LogLevel level, @NotNull LogIssuer logIssuer, @NotNull String format);
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||
* Licensed under the GNU Affero General Public License v3
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.staropensource.sosengine.base.classes;
|
||||
|
||||
import de.staropensource.sosengine.base.logging.Logger;
|
||||
import de.staropensource.sosengine.base.types.logging.LogLevel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Interface for implementing custom logger implementations.
|
||||
*
|
||||
* @see Logger#setLoggerImplementation(LoggerImplementation)
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public interface LoggerImplementation {
|
||||
/**
|
||||
* Invoked before anything is done with the log message.
|
||||
*
|
||||
* @param level level
|
||||
* @param issuerClass issuer class
|
||||
* @param issuerOrigin issuer origin
|
||||
* @param issuerMetadata issuer metadata
|
||||
* @param message raw message
|
||||
* @param format unmodified log format
|
||||
* @return new log message, return {@code null} for no change
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
@Nullable String prePlaceholder(@NotNull LogLevel level, @NotNull Class<?> issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message, @NotNull String format);
|
||||
|
||||
/**
|
||||
* Invoked after placeholders have been processed and replaced.
|
||||
*
|
||||
* @param level level
|
||||
* @param issuerClass issuer class
|
||||
* @param issuerOrigin issuer origin
|
||||
* @param issuerMetadata issuer metadata
|
||||
* @param message raw message
|
||||
* @param format unmodified log format
|
||||
* @return new log format
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
@NotNull String postPlaceholder(@NotNull LogLevel level, @NotNull Class<?> issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message, @NotNull String format);
|
||||
|
||||
/**
|
||||
* Prints the log message.
|
||||
*
|
||||
* @param level level
|
||||
* @param issuerClass issuer class
|
||||
* @param issuerOrigin issuer origin
|
||||
* @param issuerMetadata issuer metadata
|
||||
* @param message raw message
|
||||
* @param format unmodified log format
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
void print(@NotNull LogLevel level, @NotNull Class<?> issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message, @NotNull String format);
|
||||
}
|
|
@ -31,12 +31,11 @@ import org.jetbrains.annotations.NotNull;
|
|||
@SuppressWarnings({ "unused" })
|
||||
public interface Placeholder {
|
||||
/**
|
||||
* Replaces the placeholder with it's appropriate content.
|
||||
* Replaces the placeholder with content.
|
||||
*
|
||||
* @param text text to process
|
||||
* @return the processed text
|
||||
* @since v1-alpha0
|
||||
* @return processed text
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
@NotNull
|
||||
String replace(@NotNull String text);
|
||||
@NotNull String replace(@NotNull String text);
|
||||
}
|
||||
|
|
|
@ -22,8 +22,6 @@ package de.staropensource.sosengine.base.classes;
|
|||
import de.staropensource.sosengine.base.EngineConfiguration;
|
||||
import de.staropensource.sosengine.base.exceptions.ParserException;
|
||||
import de.staropensource.sosengine.base.logging.LoggerInstance;
|
||||
import de.staropensource.sosengine.base.types.CodePart;
|
||||
import de.staropensource.sosengine.base.types.logging.LogIssuer;
|
||||
import lombok.Getter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
@ -31,7 +29,11 @@ import java.util.LinkedList;
|
|||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* The base skeleton for implementing a shortcode parser.
|
||||
* Base class for implementing a shortcode converter.
|
||||
* <p>
|
||||
* This class parses a string and converts it into a list of
|
||||
* components, which can then be in turn be converted to something
|
||||
* else, for example, ANSI escape codes.
|
||||
* <p>
|
||||
* The following shortcodes are available and can be used:
|
||||
* <ul>
|
||||
|
@ -42,61 +44,58 @@ import java.util.Locale;
|
|||
* <li>italic</li>
|
||||
* <li>strikethrough</li>
|
||||
* <li>underline</li>
|
||||
* <li>blink</li>
|
||||
* <li>negative</li>
|
||||
* </ul>
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
@SuppressWarnings({ "unused", "JavadocDeclaration", "JavadocBlankLines" })
|
||||
@SuppressWarnings({ "unused", "JavadocDeclaration" })
|
||||
public abstract class ShortcodeParserSkeleton {
|
||||
/**
|
||||
* Logger instance.
|
||||
* Contains the {@link LoggerInstance} for this instance.
|
||||
*
|
||||
* @see LoggerInstance
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
protected final LoggerInstance logger = new LoggerInstance(new LogIssuer(getClass(), CodePart.ENGINE));
|
||||
protected final @NotNull LoggerInstance logger;
|
||||
|
||||
/**
|
||||
* A list of components the parsed string is made out of.
|
||||
* Contains a list of components the parsed text is made out of.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*
|
||||
* -- GETTER --
|
||||
* Returns a list of components the parsed string is made out of.
|
||||
* Returns a list of components the parsed text is made out of.
|
||||
*
|
||||
* @return component list of the parsed string
|
||||
* @return component list
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
@NotNull
|
||||
@Getter
|
||||
protected final LinkedList<String> components;
|
||||
protected final @NotNull LinkedList<String> components;
|
||||
|
||||
/**
|
||||
* Constructs this class.
|
||||
*
|
||||
* @param string string to parse
|
||||
* @param ignoreInvalidEscapes will ignore invalid escapes and print treat them like regular text
|
||||
* @throws ParserException when parsing failed
|
||||
* @since v1-alpha1
|
||||
* @param ignoreInvalidEscapes if {@code true}, will ignore and treat invalid escapes as text
|
||||
* @throws ParserException on error
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
public ShortcodeParserSkeleton(@NotNull String string, boolean ignoreInvalidEscapes) throws ParserException {
|
||||
logger = new LoggerInstance.Builder().setClazz(getClass()).setOrigin("ENGINE").build();
|
||||
components = parse(string, ignoreInvalidEscapes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses an input string and spits out all of it's components.
|
||||
* Parses the input string and returns a list
|
||||
* of components the text is made out of.
|
||||
*
|
||||
* @param string string to parse
|
||||
* @param ignoreInvalidEscapes will ignore invalid escapes and print treat them like regular text
|
||||
* @param ignoreInvalidEscapes if {@code true}, will ignore and treat invalid escapes as text
|
||||
* @return list of components
|
||||
* @throws ParserException when parsing failed
|
||||
* @throws ParserException on error
|
||||
* @see EngineConfiguration#errorShortcodeConverter
|
||||
* @since v1-alpha1
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
@NotNull
|
||||
protected LinkedList<@NotNull String> parse(@NotNull String string, boolean ignoreInvalidEscapes) throws ParserException {
|
||||
protected @NotNull LinkedList<@NotNull String> parse(@NotNull String string, boolean ignoreInvalidEscapes) throws ParserException {
|
||||
LinkedList<String> components = new LinkedList<>(); // List of components
|
||||
boolean tagActive = false; // Indicates that a tag is being parsed
|
||||
boolean escape = false; // Indicates whether the last character was a \ character
|
||||
|
@ -276,18 +275,17 @@ public abstract class ShortcodeParserSkeleton {
|
|||
}
|
||||
|
||||
/**
|
||||
* Checks the supplied color tag and returns if it's valid.
|
||||
* Returns if the specified color is valid
|
||||
*
|
||||
* @return {@code true} if valid, {@code false} otherwise
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
private boolean isValidColor(@NotNull String color) {
|
||||
switch (color.toLowerCase(Locale.ROOT)) {
|
||||
case "black", "white", "red", "green", "blue", "yellow", "magenta", "cyan" -> {
|
||||
return true;
|
||||
}
|
||||
default -> {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return switch (color.toLowerCase(Locale.ROOT)) {
|
||||
case "black", "white", "red",
|
||||
"green", "blue", "yellow",
|
||||
"magenta", "cyan" -> true;
|
||||
default -> false;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,53 +28,60 @@ import de.staropensource.sosengine.base.types.DependencyVector;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* The interface for engine subsystem main classes.
|
||||
* Interface for building subsystem main classes.
|
||||
*
|
||||
* @see EngineSubsystem
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public interface SubsystemMainClass {
|
||||
public abstract class SubsystemClass {
|
||||
/**
|
||||
* Logger instance.
|
||||
* Constructs this class.
|
||||
*
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
public SubsystemClass() {}
|
||||
|
||||
/**
|
||||
* Contains the {@link LoggerInstance} for this instance.
|
||||
*
|
||||
* @see LoggerInstance
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
LoggerInstance logger = null;
|
||||
public final LoggerInstance logger = new LoggerInstance.Builder().setClazz(getClass()).setOrigin("ENGINE").build();
|
||||
|
||||
/**
|
||||
* Returns the name of this subsystem.
|
||||
* Returns the name of the subsystem.
|
||||
*
|
||||
* @return subsystem name
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
@NotNull
|
||||
String getName();
|
||||
public abstract @NotNull String getName();
|
||||
|
||||
/**
|
||||
* Initializes this subsystem.
|
||||
* Initializes the subsystem.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
void initializeSubsystem();
|
||||
public abstract void initializeSubsystem();
|
||||
|
||||
/**
|
||||
* Returns the {@link DependencyVector} for this subsystem.
|
||||
* Returns a matching {@link DependencyVector}.
|
||||
* Used for dependency resolution during startup.
|
||||
*
|
||||
* @return {@link DependencyVector} for this subsystem
|
||||
* @since v1-alpha1
|
||||
* @return matching {@link DependencyVector} for the subsystem
|
||||
* @see DependencyVector
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
@NotNull
|
||||
DependencyVector getDependencyVector();
|
||||
public abstract @NotNull DependencyVector getDependencyVector();
|
||||
|
||||
/**
|
||||
* Called when the engine shuts down.
|
||||
* Called on engine shutdown.
|
||||
*
|
||||
* @see Engine#shutdown()
|
||||
* @see Engine#shutdown(int)
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@EventListener(event = InternalEngineShutdownEvent.class)
|
||||
static void shutdown() {}
|
||||
protected static void shutdownSubsystem() {}
|
||||
}
|
|
@ -1,83 +0,0 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine Contributors
|
||||
* Licensed under the GNU Affero General Public License v3
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.staropensource.sosengine.base.classes;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* Base class for subsystem configurations.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public interface SubsystemConfiguration {
|
||||
/**
|
||||
* Contains the class instance.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
SubsystemConfiguration instance = null;
|
||||
|
||||
/**
|
||||
* Defines the group every property must start with to be recognized as a subsystem configuration setting.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@NotNull
|
||||
String group = "sosengine.";
|
||||
|
||||
/**
|
||||
* Loads the subsystem configuration from the specified {@link Properties}.<br/>
|
||||
* Unless you want to allow configuration overriding, resetting the configuration using {@code loadDefaultConfiguration()} is advised.
|
||||
*
|
||||
* @param properties {@link Properties} object
|
||||
* @see SubsystemConfiguration#loadDefaultConfiguration()
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
void loadConfiguration(@NotNull Properties properties);
|
||||
|
||||
/**
|
||||
* Loads the subsystem configuration from the system properties.
|
||||
*
|
||||
* @see SubsystemConfiguration#loadConfiguration(Properties)
|
||||
* @see System#getProperties()
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
void loadConfiguration();
|
||||
|
||||
/**
|
||||
* Loads the default subsystem configuration.
|
||||
*
|
||||
* @see SubsystemConfiguration#loadConfiguration()
|
||||
* @see SubsystemConfiguration#loadConfiguration(Properties)
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
void loadDefaultConfiguration();
|
||||
|
||||
/**
|
||||
* Returns a configuration setting.
|
||||
*
|
||||
* @param setting setting name
|
||||
* @return setting's value or {@code null} if not found
|
||||
*/
|
||||
Object getSetting(@NotNull String setting);
|
||||
}
|
|
@ -24,27 +24,26 @@ import org.jetbrains.annotations.NotNull;
|
|||
import org.jetbrains.annotations.Range;
|
||||
|
||||
/**
|
||||
* An interface used for implementing different versioning systems.
|
||||
* Interface for building a versioning system (parser).
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public interface VersioningSystem {
|
||||
/**
|
||||
* Returns the name of this versioning system.
|
||||
* Returns the name of the versioning system.
|
||||
*
|
||||
* @return name of this versioning system
|
||||
* @return versioning system name
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
@NotNull
|
||||
String getName();
|
||||
@NotNull String getName();
|
||||
|
||||
/**
|
||||
* Compares a version with another version.
|
||||
* Compares a {@link VersioningSystem} with another.
|
||||
*
|
||||
* @param version the version to compare against
|
||||
* @param version {@link VersioningSystem} to compare against
|
||||
* @return smaller = {@code 0}, equal = {@code 1}, bigger = {@code 2}
|
||||
* @throws IncompatibleVersioningSystemException when this versioning system does not support comparing with another versioning system
|
||||
* @throws IncompatibleVersioningSystemException incompatible with the supplied versioning system
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
@Range(from = 0, to = 2)
|
||||
|
|
|
@ -28,12 +28,9 @@ import de.staropensource.sosengine.base.exceptions.reflection.InstanceMethodFrom
|
|||
import de.staropensource.sosengine.base.exceptions.reflection.InvalidMethodSignature;
|
||||
import de.staropensource.sosengine.base.exceptions.reflection.NoAccessException;
|
||||
import de.staropensource.sosengine.base.exceptions.reflection.StaticInitializerException;
|
||||
import de.staropensource.sosengine.base.logging.Logger;
|
||||
import de.staropensource.sosengine.base.logging.LoggerInstance;
|
||||
import de.staropensource.sosengine.base.reflection.Reflect;
|
||||
import de.staropensource.sosengine.base.reflection.ReflectionMethod;
|
||||
import de.staropensource.sosengine.base.types.CodePart;
|
||||
import de.staropensource.sosengine.base.types.logging.LogIssuer;
|
||||
import de.staropensource.sosengine.base.utility.ListFormatter;
|
||||
import lombok.Getter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -51,7 +48,7 @@ import java.util.LinkedList;
|
|||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Represents an event.
|
||||
* Simplifies event logging and calling.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
|
@ -59,48 +56,58 @@ import java.util.Set;
|
|||
@SuppressWarnings({ "unused" })
|
||||
public final class EventHelper {
|
||||
/**
|
||||
* Contains all cached event listeners.
|
||||
* Holds all cached events.
|
||||
* Should not be modified manually.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
private static final HashMap<@NotNull Class<? extends Event>, LinkedList<@NotNull ReflectionMethod>> cachedEventListeners = new HashMap<>();
|
||||
private static final @NotNull HashMap<@NotNull Class<? extends Event>, LinkedList<@NotNull ReflectionMethod>> cachedEventListeners = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Contains the {@link LoggerInstance} for this instance.
|
||||
*
|
||||
* @see LoggerInstance
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
private static final @NotNull LoggerInstance logger = new LoggerInstance.Builder().setClazz(EventHelper.class).setOrigin("ENGINE").build();
|
||||
|
||||
/**
|
||||
* Constructs this class.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public EventHelper() {}
|
||||
|
||||
/**
|
||||
* Logs the event call.
|
||||
* Logs an event call.
|
||||
*
|
||||
* @param clazz event class
|
||||
* @param event event class
|
||||
* @param arguments arguments passed to event listeners
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public static void logCall(@NotNull Class<? extends Event> clazz, @NotNull Object ... arguments) {
|
||||
public static void logCall(@NotNull Class<? extends Event> event, @NotNull Object ... arguments) {
|
||||
// Print event call if event debugging is enabled
|
||||
if (EngineConfiguration.getInstance().isDebugEvents())
|
||||
if (arguments.length == 0)
|
||||
Logger.diag(new LogIssuer(clazz), "Event " + clazz.getName() + " emitted");
|
||||
logger.diag("Event " + event.getName() + " was emitted");
|
||||
else
|
||||
Logger.diag(new LogIssuer(clazz), "Event " + clazz.getName() + " emitted, passing arguments " + ListFormatter.formatArray(arguments));
|
||||
logger.diag("Event " + event.getName() + " was emitted, passing arguments " + ListFormatter.formatArray(arguments));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all event listeners.
|
||||
* Returns all {@link EventListener}s listening on some event.
|
||||
* The classpath will be scanned for listeners, unless cached results exist and {@code !forceScanning}.
|
||||
*
|
||||
* @param clazz event class
|
||||
* @param forceScanning forces the method to ignore cached event listeners, not recommended
|
||||
* @return list of annotated methods
|
||||
* @param event event class
|
||||
* @param forceScanning forces scanning the classpath for listeners. not recommended due to a huge performance penalty
|
||||
* @return list of event listeners
|
||||
* @see #cacheEvent(Class)
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@NotNull
|
||||
public static LinkedList<ReflectionMethod> getAnnotatedMethods(@NotNull Class<? extends Event> clazz, boolean forceScanning) {
|
||||
public static @NotNull LinkedList<ReflectionMethod> getAnnotatedMethods(@NotNull Class<? extends Event> event, boolean forceScanning) {
|
||||
LinkedList<ReflectionMethod> methods = new LinkedList<>();
|
||||
|
||||
if (forceScanning || !cachedEventListeners.containsKey(clazz)) {
|
||||
// Scan entire classpath through Reflections library
|
||||
// (enforced or not cached)
|
||||
if (forceScanning || !cachedEventListeners.containsKey(event)) {
|
||||
Reflections reflections = new Reflections(
|
||||
new ConfigurationBuilder()
|
||||
.setUrls(ClasspathHelper.forJavaClassPath())
|
||||
|
@ -112,38 +119,38 @@ public final class EventHelper {
|
|||
|
||||
// Sort event listeners not listening for this event out
|
||||
for (Method method : annotatedMethods)
|
||||
if (method.getAnnotation(EventListener.class).event() == clazz)
|
||||
if (method.getAnnotation(EventListener.class).event() == event)
|
||||
methods.add(Reflect.reflectOn(method));
|
||||
|
||||
// Sort 'methods' linked list after event priority
|
||||
methods.sort(Comparator.comparing(method -> method.getAnnotation(EventListener.class).priority()));
|
||||
} else
|
||||
// 'forcedScanning' is false and matching event listeners are cached
|
||||
methods = cachedEventListeners.get(clazz);
|
||||
// Event listeners are cached and !forceScanning, return cached results
|
||||
methods = cachedEventListeners.get(event);
|
||||
|
||||
return methods;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all matching event listeners.
|
||||
* Returns all {@link EventListener}s listening on some event.
|
||||
* The classpath will be scanned for listeners, unless cached results exist.
|
||||
*
|
||||
* @param clazz event class
|
||||
* @return list of annotated methods
|
||||
* @param event event class
|
||||
* @return list of event listeners
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@NotNull
|
||||
public static LinkedList<ReflectionMethod> getAnnotatedMethods(@NotNull Class<? extends Event> clazz) {
|
||||
return getAnnotatedMethods(clazz, false);
|
||||
public static @NotNull LinkedList<ReflectionMethod> getAnnotatedMethods(@NotNull Class<? extends Event> event) {
|
||||
return getAnnotatedMethods(event, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes all matching event listeners without any arguments.
|
||||
* Invokes all event listeners.
|
||||
*
|
||||
* @param event event class
|
||||
* @param arguments arguments to pass to event listeners
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public static void invokeAnnotatedMethods(@NotNull Class<? extends Event> event, Object... arguments) {
|
||||
LoggerInstance logger = new LoggerInstance(new LogIssuer(EventHelper.class, event.getName(), CodePart.ENGINE));
|
||||
if (event != LogEvent.class)
|
||||
logCall(event);
|
||||
|
||||
|
@ -177,36 +184,35 @@ public final class EventHelper {
|
|||
}
|
||||
|
||||
/**
|
||||
* Caches all event listeners listening on some event.
|
||||
* Will recompute all event listeners if the specified event is already cached.
|
||||
* (Re-)Caches all event listeners for some {@link Event}.
|
||||
*
|
||||
* @param clazz event listeners to (p)recompute, set to {@code null} to recompute all cached events
|
||||
* @param event event to (re-)cache. Set to {@code null} to recompute all cached events
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public static synchronized void precomputeEventListeners(@Nullable Class<? extends Event> clazz) {
|
||||
if (clazz == null)
|
||||
for (Class<? extends Event> event : cachedEventListeners.keySet())
|
||||
precomputeEventListeners(event);
|
||||
public static synchronized void cacheEvent(@Nullable Class<? extends Event> event) {
|
||||
if (event == null)
|
||||
for (Class<? extends Event> cachedEvent : cachedEventListeners.keySet())
|
||||
cacheEvent(cachedEvent);
|
||||
else {
|
||||
LinkedList<@NotNull ReflectionMethod> annotatedMethods = getAnnotatedMethods(clazz);
|
||||
LinkedList<@NotNull ReflectionMethod> annotatedMethods = getAnnotatedMethods(event);
|
||||
|
||||
if (cachedEventListeners.containsKey(clazz))
|
||||
cachedEventListeners.replace(clazz, annotatedMethods);
|
||||
if (cachedEventListeners.containsKey(event))
|
||||
cachedEventListeners.replace(event, annotatedMethods);
|
||||
else
|
||||
cachedEventListeners.put(clazz, annotatedMethods);
|
||||
cachedEventListeners.put(event, annotatedMethods);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes events from the event listener cache.
|
||||
* Removes an event from the event listener cache.
|
||||
*
|
||||
* @param clazz event class to remove cached event listeners for or {@code null} to remove all cached event listeners
|
||||
* @param event event to uncache. Set to {@code null} to clear the entire cache
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public static synchronized void removePrecomputedEventListeners(@Nullable Class<? extends Event> clazz) {
|
||||
if (clazz == null)
|
||||
public static synchronized void uncacheEvent(@Nullable Class<? extends Event> event) {
|
||||
if (event == null)
|
||||
cachedEventListeners.clear();
|
||||
else
|
||||
cachedEventListeners.remove(clazz);
|
||||
cachedEventListeners.remove(event);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,9 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* Contains various interfaces and abstract classes.
|
||||
* Interfaces and abstract classes which can be used for implementing classes.
|
||||
* <p>
|
||||
* These are not to be confused with data types. See {@link de.staropensource.sosengine.base.types}.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
|
|
|
@ -17,16 +17,15 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.staropensource.sosengine.base.data.info;
|
||||
package de.staropensource.sosengine.base.data.information;
|
||||
|
||||
import de.staropensource.sosengine.base.Engine;
|
||||
import de.staropensource.sosengine.base.logging.LoggerInstance;
|
||||
import de.staropensource.sosengine.base.types.CodePart;
|
||||
import de.staropensource.sosengine.base.types.VersionType;
|
||||
import de.staropensource.sosengine.base.types.logging.LogIssuer;
|
||||
import de.staropensource.sosengine.base.utility.parser.PropertyParser;
|
||||
import de.staropensource.sosengine.base.utility.parser.StackTraceParser;
|
||||
import lombok.Getter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
@ -38,17 +37,39 @@ import java.util.GregorianCalendar;
|
|||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* Provides build information about the sos!engine.
|
||||
*/
|
||||
@SuppressWarnings({ "unused", "JavadocDeclaration", "JavadocBlankLines" })
|
||||
public final class EngineInformation {
|
||||
/**
|
||||
* Provides the engine's version.
|
||||
* Provides build information about the engine.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@SuppressWarnings({ "unused", "JavadocDeclaration" })
|
||||
public final class EngineInformation {
|
||||
/**
|
||||
* Contains the {@link LoggerInstance} for this instance.
|
||||
*
|
||||
* @see LoggerInstance
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
private static final @NotNull LoggerInstance logger = new LoggerInstance.Builder().setClazz(EngineInformation.class).setOrigin("ENGINE").build();
|
||||
|
||||
/**
|
||||
* Contains the engine's version codename.
|
||||
*
|
||||
* @since v1-alpha2
|
||||
* -- GETTER --
|
||||
* Provides the engine's version.
|
||||
* Returns the engine's version codename.
|
||||
*
|
||||
* @return engine version codename
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
@Getter
|
||||
private static String versioningCodename;
|
||||
|
||||
/**
|
||||
* Contains the engine's version.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
* -- GETTER --
|
||||
* Returns the engine's version.
|
||||
*
|
||||
* @return engine version
|
||||
* @since v1-alpha0
|
||||
|
@ -57,12 +78,11 @@ public final class EngineInformation {
|
|||
private static int versioningVersion;
|
||||
|
||||
/**
|
||||
* Provides the engine's version type.
|
||||
* Contains the engine's version type.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*
|
||||
* -- GETTER --
|
||||
* Provides the engine's version type.
|
||||
* Returns the engine's version type.
|
||||
*
|
||||
* @return engine version type
|
||||
* @since v1-alpha0
|
||||
|
@ -71,12 +91,11 @@ public final class EngineInformation {
|
|||
private static VersionType versioningType;
|
||||
|
||||
/**
|
||||
* Provides the engine's type release.
|
||||
* Contains the engine's typerelease.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*
|
||||
* -- GETTER --
|
||||
* Provides the engine's type release.
|
||||
* Returns the engine's typerelease.
|
||||
*
|
||||
* @return engine typerelease
|
||||
* @since v1-alpha0
|
||||
|
@ -85,14 +104,15 @@ public final class EngineInformation {
|
|||
private static int versioningTyperelease;
|
||||
|
||||
/**
|
||||
* Provides the engine's fork identifier.<br/>
|
||||
* Likely empty. If not, it must be prefixed with a dash.
|
||||
* Contains the engine's fork identifier.
|
||||
* <p>
|
||||
* Likely empty. If not, prefixed with a dash.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*
|
||||
* -- GETTER --
|
||||
* Provides the engine's fork identifier.<br/>
|
||||
* Likely empty. If not, it must be prefixed with a dash.
|
||||
* Returns the engine's fork identifier.
|
||||
* <p>
|
||||
* Likely empty. If not, prefixed with a dash.
|
||||
*
|
||||
* @return engine fork identifier
|
||||
* @since v1-alpha0
|
||||
|
@ -101,12 +121,11 @@ public final class EngineInformation {
|
|||
private static String versioningFork;
|
||||
|
||||
/**
|
||||
* Provides the engine's full version string.
|
||||
* Contains the engine's full version string.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*
|
||||
* -- GETTER --
|
||||
* Provides the engine's full version string.
|
||||
* Returns the engine's full version string.
|
||||
*
|
||||
* @return engine version string
|
||||
* @since v1-alpha1
|
||||
|
@ -116,26 +135,24 @@ public final class EngineInformation {
|
|||
|
||||
|
||||
/**
|
||||
* Provides the {@code dirty} value (i.e. if the source tree has been modified).
|
||||
* Contains the {@code dirty} value (i.e. if the source tree has been modified).
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*
|
||||
* -- GETTER --
|
||||
* Provides the {@code dirty} value (i.e. if the source tree has been modified).
|
||||
* Returns the {@code dirty} value (i.e. if the source tree has been modified).
|
||||
*
|
||||
* @return git dirty value
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
@Getter
|
||||
private static Boolean gitDirty;
|
||||
private static boolean gitDirty;
|
||||
|
||||
/**
|
||||
* Provides the branch the engine was built on.
|
||||
* Contains the branch the engine was built on.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*
|
||||
* -- GETTER --
|
||||
* Provides the branch the engine was built on.
|
||||
* Returns the branch the engine was built on.
|
||||
*
|
||||
* @return git branch
|
||||
* @since v1-alpha1
|
||||
|
@ -144,12 +161,11 @@ public final class EngineInformation {
|
|||
private static String gitBranch;
|
||||
|
||||
/**
|
||||
* Provides the commit count.
|
||||
* Contains the commit count.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*
|
||||
* -- GETTER --
|
||||
* Provides the commit count.
|
||||
* Returns the commit count.
|
||||
*
|
||||
* @return git commit count
|
||||
* @since v1-alpha1
|
||||
|
@ -158,12 +174,11 @@ public final class EngineInformation {
|
|||
private static int gitCommitCount;
|
||||
|
||||
/**
|
||||
* Provides the commit identifier (short form).
|
||||
* Contains the commit identifier (short form).
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*
|
||||
* -- GETTER --
|
||||
* Provides the commit identifier (short form).
|
||||
* Returns the commit identifier (short form).
|
||||
*
|
||||
* @return git long commit id
|
||||
* @since v1-alpha1
|
||||
|
@ -172,12 +187,11 @@ public final class EngineInformation {
|
|||
private static String gitCommitIdentifierShort;
|
||||
|
||||
/**
|
||||
* Provides the commit identifier (long form).
|
||||
* Contains the commit identifier (long form).
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*
|
||||
* -- GETTER --
|
||||
* Provides the commit identifier (long form).
|
||||
* Returns the commit identifier (long form).
|
||||
*
|
||||
* @return git long commit id
|
||||
* @since v1-alpha1
|
||||
|
@ -186,12 +200,11 @@ public final class EngineInformation {
|
|||
private static String gitCommitIdentifierLong;
|
||||
|
||||
/**
|
||||
* Provides the commit header.
|
||||
* Contains the commit header.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*
|
||||
* -- GETTER --
|
||||
* Provides the commit header.
|
||||
* Returns the commit header.
|
||||
*
|
||||
* @return git commit header
|
||||
* @since v1-alpha1
|
||||
|
@ -200,12 +213,11 @@ public final class EngineInformation {
|
|||
private static String gitCommitHeader;
|
||||
|
||||
/**
|
||||
* Provides the commit time.
|
||||
* Contains the commit time.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*
|
||||
* -- GETTER --
|
||||
* Provides the commit time.
|
||||
* Returns the commit time.
|
||||
*
|
||||
* @return git commit time
|
||||
* @since v1-alpha1
|
||||
|
@ -214,12 +226,11 @@ public final class EngineInformation {
|
|||
private static ZonedDateTime gitCommitTime;
|
||||
|
||||
/**
|
||||
* Provides the commiter's name.
|
||||
* Contains the commiter's name.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*
|
||||
* -- GETTER --
|
||||
* Provides the commiter's name.
|
||||
* Returns the commiter's name.
|
||||
*
|
||||
* @return git committer name
|
||||
* @since v1-alpha1
|
||||
|
@ -228,12 +239,11 @@ public final class EngineInformation {
|
|||
private static String gitCommitterName;
|
||||
|
||||
/**
|
||||
* Provides the commiter's email.
|
||||
* Contains the commiter's email.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*
|
||||
* -- GETTER --
|
||||
* Provides the commiter's email.
|
||||
* Returns the commiter's email.
|
||||
*
|
||||
* @return git committer email
|
||||
* @since v1-alpha1
|
||||
|
@ -243,12 +253,11 @@ public final class EngineInformation {
|
|||
|
||||
|
||||
/**
|
||||
* Provides the version of the dependency {@code Jansi}.
|
||||
* Contains the version of the dependency {@code Jansi}.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*
|
||||
* -- GETTER --
|
||||
* Provides the version of the dependency {@code Jansi}.
|
||||
* Returns the version of the dependency {@code Jansi}.
|
||||
*
|
||||
* @return Jansi dependency version
|
||||
* @since v1-alpha0
|
||||
|
@ -257,12 +266,11 @@ public final class EngineInformation {
|
|||
private static String dependencyJansi;
|
||||
|
||||
/**
|
||||
* Provides the version of the dependency {@code Reflections}.
|
||||
* Contains the version of the dependency {@code Reflections}.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*
|
||||
* -- GETTER --
|
||||
* Provides the version of the dependency {@code Reflections}.
|
||||
* Returns the version of the dependency {@code Reflections}.
|
||||
*
|
||||
* @return Reflections dependency version
|
||||
* @since v1-alpha0
|
||||
|
@ -271,12 +279,11 @@ public final class EngineInformation {
|
|||
private static String dependencyReflections;
|
||||
|
||||
/**
|
||||
* Provides the version of the dependency {@code SLF4J}.
|
||||
* Contains the version of the dependency {@code SLF4J}.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*
|
||||
* -- GETTER --
|
||||
* Provides the version of the dependency {@code SLF4J}.
|
||||
* Returns the version of the dependency {@code SLF4J}.
|
||||
*
|
||||
* @return SLF4J dependency version
|
||||
* @since v1-alpha0
|
||||
|
@ -285,12 +292,11 @@ public final class EngineInformation {
|
|||
private static String dependencySlf4j;
|
||||
|
||||
/**
|
||||
* Provides the version of the dependency {@code LWJGL}.
|
||||
* Contains the version of the dependency {@code LWJGL}.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*
|
||||
* -- GETTER --
|
||||
* Provides the version of the dependency {@code LWJGL}.
|
||||
* Returns the version of the dependency {@code LWJGL}.
|
||||
*
|
||||
* @return LWJGL dependency version
|
||||
* @since v1-alpha0
|
||||
|
@ -307,12 +313,13 @@ public final class EngineInformation {
|
|||
|
||||
/**
|
||||
* Updates all variables.
|
||||
* <p>
|
||||
* This method does not need to be invoked, as the information provided by this
|
||||
* class is static (does not change) and is already populated at engine startup.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
public static synchronized void updateVariables() {
|
||||
LoggerInstance logger = new LoggerInstance(new LogIssuer(EngineInformation.class, CodePart.ENGINE));
|
||||
|
||||
// Load properties from bundled gradle.properties
|
||||
Properties gradleProperties = new Properties();
|
||||
InputStream gradleStream = EngineInformation.class.getClassLoader().getResourceAsStream("gradle.properties");
|
||||
|
@ -370,6 +377,7 @@ public final class EngineInformation {
|
|||
PropertyParser gitParser = new PropertyParser(gitProperties);
|
||||
|
||||
// Apply properties to fields
|
||||
versioningCodename = gradleParser.getString("versioningCodename");
|
||||
versioningVersion = gradleParser.getInteger("versioningVersion", true);
|
||||
versioningType = VersionType.valueOf(gradleParser.getString("versioningType").toUpperCase());
|
||||
versioningTyperelease = gradleParser.getInteger("versioningTyperelease", true);
|
|
@ -17,11 +17,9 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.staropensource.sosengine.base.data.info;
|
||||
package de.staropensource.sosengine.base.data.information;
|
||||
|
||||
import de.staropensource.sosengine.base.logging.Logger;
|
||||
import de.staropensource.sosengine.base.types.CodePart;
|
||||
import de.staropensource.sosengine.base.types.logging.LogIssuer;
|
||||
import de.staropensource.sosengine.base.logging.LoggerInstance;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
|
@ -30,9 +28,19 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* Provides information about the running Java Virtual Machine.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public final class JvmInformation {
|
||||
/**
|
||||
* Contains the {@link LoggerInstance} for this instance.
|
||||
*
|
||||
* @see LoggerInstance
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
private static final @NotNull LoggerInstance logger = new LoggerInstance.Builder().setClazz(JvmInformation.class).setOrigin("ENGINE").build();
|
||||
|
||||
/**
|
||||
* Constructs this class.
|
||||
*
|
||||
|
@ -43,8 +51,8 @@ public final class JvmInformation {
|
|||
/**
|
||||
* Returns the Java version this JVM implements.
|
||||
*
|
||||
* @return the Java version
|
||||
* @throws NumberFormatException if the version could not be converted into an int
|
||||
* @return Java version
|
||||
* @throws NumberFormatException on integer conversion failure
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public static int getJavaVersion() throws NumberFormatException {
|
||||
|
@ -60,7 +68,7 @@ public final class JvmInformation {
|
|||
try {
|
||||
return Integer.parseInt(version);
|
||||
} catch (NumberFormatException exception) {
|
||||
Logger.crash(new LogIssuer(JvmInformation.class, CodePart.ENGINE), "Could not parse Java version: Integer conversion failed for string \"" + version + "\"", exception, true);
|
||||
logger.crash("Could not parse Java version: Integer conversion failed for string \"" + version + "\"", exception, true);
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
|
@ -68,33 +76,30 @@ public final class JvmInformation {
|
|||
/**
|
||||
* Returns the JVM implementation name.
|
||||
*
|
||||
* @return the JVM implementation name
|
||||
* @return implementation name
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@NotNull
|
||||
public static String getImplementationName() {
|
||||
public static @NotNull String getImplementationName() {
|
||||
return ManagementFactory.getRuntimeMXBean().getVmName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the JVM implementation version.
|
||||
*
|
||||
* @return the JVM implementation version
|
||||
* @return implementation version
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@NotNull
|
||||
public static String getImplementationVersion() {
|
||||
public static @NotNull String getImplementationVersion() {
|
||||
return ManagementFactory.getRuntimeMXBean().getVmVersion();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the JVM implementation vendor.
|
||||
*
|
||||
* @return the JVM implementation vendor
|
||||
* @return implementation vendor
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@NotNull
|
||||
public static String getImplementationVendor() {
|
||||
public static @NotNull String getImplementationVendor() {
|
||||
return ManagementFactory.getRuntimeMXBean().getVmVendor();
|
||||
}
|
||||
|
||||
|
@ -109,20 +114,18 @@ public final class JvmInformation {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the arguments passed to the JVM (not to the running program).
|
||||
* Returns all arguments passed to the JVM.
|
||||
* This excludes all arguments passed to the application.
|
||||
*
|
||||
* @return the JVM arguments
|
||||
* @return JVM arguments
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@NotNull
|
||||
public static List<@NotNull String> getArguments() {
|
||||
public static @NotNull List<@NotNull String> getArguments() {
|
||||
return ManagementFactory.getRuntimeMXBean().getInputArguments();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the total amount of memory used the running application AND JVM.
|
||||
* <p>
|
||||
* Note: This is an estimate.
|
||||
* Returns the <b>estimated</b> total amount of memory used the running application and JVM.
|
||||
*
|
||||
* @return estimated total amount of used memory
|
||||
* @since v1-alpha1
|
||||
|
@ -132,19 +135,19 @@ public final class JvmInformation {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum amount of memory usable by the running application.
|
||||
* Returns the maximum amount of memory which can be used by the running application.
|
||||
*
|
||||
* @return maximum amount of usable memory
|
||||
* @return maximum amount of memory usable in bytes
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
public static long getMemoryMax() {
|
||||
public static long getMemoryLimit() {
|
||||
return Runtime.getRuntime().maxMemory();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the amount of free memory available to the running application.
|
||||
*
|
||||
* @return amount of free memory
|
||||
* @return amount of free memory in bytes
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
public static long getMemoryFree() {
|
||||
|
@ -154,37 +157,37 @@ public final class JvmInformation {
|
|||
/**
|
||||
* Returns the amount of memory used by the running application.
|
||||
*
|
||||
* @return amount of used memory
|
||||
* @return amount of used memory in bytes
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
public static long getMemoryUsed() {
|
||||
return getMemoryMax() - getMemoryFree();
|
||||
return getMemoryLimit() - getMemoryFree();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the memory usage of the heap.
|
||||
* Returns the size of <a href="https://en.wikipedia.org/wiki/Heap_(programming)">heap memory</a>.
|
||||
*
|
||||
* @return heap usage
|
||||
* @return heap memory size
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
public static MemoryUsage getMemoryHeap() {
|
||||
public static @NotNull MemoryUsage getMemoryHeap() {
|
||||
return ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the memory usage of the stack.
|
||||
* Returns size of <a href="https://en.wikipedia.org/wiki/Stack-based_memory_allocation">stack memory</a>.
|
||||
*
|
||||
* @return stack usage
|
||||
* @return stack memory size
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
public static MemoryUsage getMemoryStack() {
|
||||
public static @NotNull MemoryUsage getMemoryStack() {
|
||||
return ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the amount of processors used by the JVM.
|
||||
* Returns the amount of processors available to the JVM.
|
||||
* <p>
|
||||
* Note: The amount of processors used may change rapidly.
|
||||
* Note: The amount of available processors may change rapidly.
|
||||
* If your application scales resources based on the output of
|
||||
* this method, consider checking it's output often and scaling
|
||||
* resources accordingly.
|
|
@ -18,8 +18,8 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* Provides various classes that can be used to retrieve information about the engine or JVM.
|
||||
* Classes which can be used to retrieve information about the execution environment.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
package de.staropensource.sosengine.base.data.info;
|
||||
package de.staropensource.sosengine.base.data.information;
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* Contains various packages with tiny classes that provide or process information.
|
||||
* Classes which provide or process information.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
|
|
|
@ -32,65 +32,60 @@ import org.jetbrains.annotations.Range;
|
|||
*
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
@SuppressWarnings({ "unused", "JavadocDeclaration", "JavadocBlankLines" })
|
||||
@SuppressWarnings({ "unused", "JavadocDeclaration" })
|
||||
@Getter
|
||||
public final class FourNumberVersioningSystem implements VersioningSystem {
|
||||
/**
|
||||
* Contains the 1. number vector.
|
||||
* Contains the first number vector.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*
|
||||
* -- GETTER --
|
||||
* Returns the 1. number vector.
|
||||
* Returns the first number vector.
|
||||
*
|
||||
* @return 1. number vector
|
||||
* @return first number vector
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
private final int number1;
|
||||
|
||||
/**
|
||||
* Contains the 2. number vector.
|
||||
* Contains the second number vector.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*
|
||||
* -- GETTER --
|
||||
* Returns the 2. number vector.
|
||||
* Returns the second number vector.
|
||||
*
|
||||
* @return 2. number vector
|
||||
* @return second number vector
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
private final int number2;
|
||||
|
||||
/**
|
||||
* Contains the 3. number vector.
|
||||
* Contains the third number vector.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*
|
||||
* -- GETTER --
|
||||
* Returns the 3. number vector.
|
||||
* Returns the third number vector.
|
||||
*
|
||||
* @return 3. number vector
|
||||
* @return third number vector
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
private final int number3;
|
||||
|
||||
/**
|
||||
* Contains the 4. number vector.
|
||||
* Contains the fourth number vector.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*
|
||||
* -- GETTER --
|
||||
* Returns the 4. number vector.
|
||||
* Returns the fourth number vector.
|
||||
*
|
||||
* @return 4. number vector
|
||||
* @return fourth number vector
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
private final int number4;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
public @NotNull String getName() {
|
||||
return "n4";
|
||||
}
|
||||
|
||||
|
|
|
@ -27,18 +27,17 @@ import org.jetbrains.annotations.NotNull;
|
|||
import org.jetbrains.annotations.Range;
|
||||
|
||||
/**
|
||||
* Represents a two-numbered versioning system, where an application or work is versioning by two arbitrary numbers.
|
||||
* Represents a one-numbered versioning system, where an application or work is versioned by one arbitrary number.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
@SuppressWarnings({ "unused", "JavadocDeclaration", "JavadocBlankLines" })
|
||||
@SuppressWarnings({ "unused", "JavadocDeclaration" })
|
||||
@Getter
|
||||
public final class OneNumberVersioningSystem implements VersioningSystem {
|
||||
/**
|
||||
* Contains the number vector.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*
|
||||
* -- GETTER --
|
||||
* Returns the number vector.
|
||||
*
|
||||
|
@ -48,9 +47,8 @@ public final class OneNumberVersioningSystem implements VersioningSystem {
|
|||
private final int number;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
public @NotNull String getName() {
|
||||
return "n1";
|
||||
}
|
||||
|
||||
|
@ -80,7 +78,6 @@ public final class OneNumberVersioningSystem implements VersioningSystem {
|
|||
return 2;
|
||||
|
||||
return 1;
|
||||
|
||||
} else
|
||||
throw new IncompatibleVersioningSystemException(this, versionInterface);
|
||||
}
|
||||
|
|
|
@ -33,83 +33,78 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Represents the semantic versioning system (version 2.0.0), where an application or work is versioning by a MAJOR version, a MINOR version, a PATCH version and optionally, a pre-release vector and a build number.
|
||||
* Represents the semantic versioning system (version 2.0.0), where an application
|
||||
* or work is versioning by a {@code MAJOR} version, {@code MINOR} version,
|
||||
* {@code PATCH} version and optionally, a pre-release vector and a build number.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
@SuppressWarnings({ "unused", "JavadocDeclaration", "JavadocBlankLines" })
|
||||
@SuppressWarnings({ "unused", "JavadocDeclaration" })
|
||||
@Getter
|
||||
public final class SemanticVersioningSystem implements VersioningSystem {
|
||||
/**
|
||||
* Contains the MAJOR vector.
|
||||
* Contains the {@code MAJOR} vector.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*
|
||||
* -- GETTER --
|
||||
* Returns the MAJOR vector.
|
||||
* Returns the {@code MAJOR} vector.
|
||||
*
|
||||
* @return MAJOR vector
|
||||
* @return {@code MAJOR} vector
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
private final int major;
|
||||
|
||||
/**
|
||||
* Contains the MINOR vector.
|
||||
* Contains the {@code MINOR} vector.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*
|
||||
* -- GETTER --
|
||||
* Returns the MINOR vector.
|
||||
* Returns the {@code MINOR} vector.
|
||||
*
|
||||
* @return MINOR vector
|
||||
* @return {@code MINOR} vector
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
private final int minor;
|
||||
|
||||
/**
|
||||
* Contains the PATCH vector.
|
||||
* Contains the {@code PATCH} vector.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*
|
||||
* -- GETTER --
|
||||
* Returns the PATCH vector.
|
||||
* Returns the {@code PATCH} vector.
|
||||
*
|
||||
* @return PATCH vector
|
||||
* @return {@code PATCH} vector
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
private final int patch;
|
||||
|
||||
/**
|
||||
* Contains the PRERELEASE vector.
|
||||
* Contains the {@code PRERELEASE} vector.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*
|
||||
* -- GETTER --
|
||||
* Returns the PRERELEASE vector.
|
||||
* Returns the {@code PRERELEASE} vector.
|
||||
*
|
||||
* @return PRERELEASE vector
|
||||
* @return {@code PRERELEASE} vector
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
@Nullable
|
||||
private final String prerelease;
|
||||
private final @Nullable String prerelease;
|
||||
|
||||
/**
|
||||
* Contains the BUILD vector.
|
||||
* Contains the {@code BUILD} vector.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*
|
||||
* -- GETTER --
|
||||
* Returns the BUILD vector.
|
||||
* Returns the {@code BUILD} vector.
|
||||
*
|
||||
* @return BUILD vector
|
||||
* @return {@code BUILD} vector
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
private final int build;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
public @NotNull String getName() {
|
||||
return "Semantic";
|
||||
}
|
||||
|
||||
|
|
|
@ -33,71 +33,68 @@ import java.util.List;
|
|||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Represents the StarOpenSource versioning system (version 2), where an application or work is versioning by a VERSION vector, a TYPE version type, a TYPERELEASE vector and optionally, a fork vector and a companion vector.
|
||||
* Represents the StarOpenSource versioning system (version 2), where an application
|
||||
* or work is versioning by a {@code VERSION} vector, {@code TYPE} version type,
|
||||
* {@code TYPERELEASE} vector and optionally, a {@code FORK} vector and
|
||||
* {@code COMPANION} vector.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
@SuppressWarnings({ "unused", "JavadocDeclaration", "JavadocBlankLines" })
|
||||
@SuppressWarnings({ "unused", "JavadocDeclaration" })
|
||||
@Getter
|
||||
public final class StarOpenSourceVersioningSystem implements VersioningSystem {
|
||||
/**
|
||||
* Contains the VERSION vector.
|
||||
* Contains the {@code VERSION} vector.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*
|
||||
* -- GETTER --
|
||||
* Returns the VERSION vector.
|
||||
* Returns the {@code VERSION} vector.
|
||||
*
|
||||
* @return VERSION vector
|
||||
* @return {@code VERSION} vector
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
private final int version;
|
||||
|
||||
/**
|
||||
* Contains the TYPE vector.
|
||||
* Contains the {@code TYPE} vector.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*
|
||||
* -- GETTER --
|
||||
* Returns the TYPE vector.
|
||||
* Returns the {@code TYPE} vector.
|
||||
*
|
||||
* @return TYPE vector
|
||||
* @return {@code TYPE} vector
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
private final VersionType type;
|
||||
|
||||
/**
|
||||
* Contains the TYPERELEASE vector.
|
||||
* Contains the {@code TYPERELEASE} vector.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*
|
||||
* -- GETTER --
|
||||
* Returns the TYPERELEASE vector.
|
||||
* Returns the {@code TYPERELEASE}- vector.
|
||||
*
|
||||
* @return TYPERELEASE vector
|
||||
* @return {@code TYPERELEASE} vector
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
private final int typerelease;
|
||||
|
||||
/**
|
||||
* Contains the COMPANION vector.
|
||||
* Contains the {@code COMPANION} vector.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*
|
||||
* -- GETTER --
|
||||
* Returns the COMPANION vector.
|
||||
* Returns the {@code COMPANION} vector.
|
||||
*
|
||||
* @return COMPANION vector
|
||||
* @return {@code COMPANION} vector
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
@Nullable
|
||||
private final String companion;
|
||||
private final @Nullable String companion;
|
||||
|
||||
/**
|
||||
* Contains the FORK vector.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*
|
||||
* -- GETTER --
|
||||
* Returns the FORK vector.
|
||||
*
|
||||
|
@ -107,9 +104,8 @@ public final class StarOpenSourceVersioningSystem implements VersioningSystem {
|
|||
private final String fork;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
public @NotNull String getName() {
|
||||
return "StarOpenSource";
|
||||
}
|
||||
|
||||
|
|
|
@ -32,52 +32,48 @@ import org.jetbrains.annotations.Range;
|
|||
*
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
@SuppressWarnings({ "unused", "JavadocDeclaration", "JavadocBlankLines" })
|
||||
@SuppressWarnings({ "unused", "JavadocDeclaration" })
|
||||
@Getter
|
||||
public final class ThreeNumberVersioningSystem implements VersioningSystem {
|
||||
/**
|
||||
* Contains the 1. number vector.
|
||||
* Contains the first number vector.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*
|
||||
* -- GETTER --
|
||||
* Returns the 1. number vector.
|
||||
* Returns the first number vector.
|
||||
*
|
||||
* @return 1. number vector
|
||||
* @return first number vector
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
private final int number1;
|
||||
|
||||
/**
|
||||
* Contains the 2. number vector.
|
||||
* Contains the second number vector.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*
|
||||
* -- GETTER --
|
||||
* Returns the 2. number vector.
|
||||
* Returns the second number vector.
|
||||
*
|
||||
* @return 2. number vector
|
||||
* @return second number vector
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
private final int number2;
|
||||
|
||||
/**
|
||||
* Contains the 3. number vector.
|
||||
* Contains the third number vector.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*
|
||||
* -- GETTER --
|
||||
* Returns the 3. number vector.
|
||||
* Returns the third number vector.
|
||||
*
|
||||
* @return 3. number vector
|
||||
* @return third number vector
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
private final int number3;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
public @NotNull String getName() {
|
||||
return "n3";
|
||||
}
|
||||
|
||||
|
|
|
@ -32,39 +32,36 @@ import org.jetbrains.annotations.Range;
|
|||
*
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
@SuppressWarnings({ "unused", "JavadocDeclaration", "JavadocBlankLines" })
|
||||
@SuppressWarnings({ "unused", "JavadocDeclaration" })
|
||||
@Getter
|
||||
public final class TwoNumberVersioningSystem implements VersioningSystem {
|
||||
/**
|
||||
* Contains the 1. number vector.
|
||||
* Contains the first number vector.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*
|
||||
* -- GETTER --
|
||||
* Returns the 1. number vector.
|
||||
* Returns the first number vector.
|
||||
*
|
||||
* @return 1. number vector
|
||||
* @return first number vector
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
private final int number1;
|
||||
|
||||
/**
|
||||
* Contains the 2. number vector.
|
||||
* Contains the second number vector.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*
|
||||
* -- GETTER --
|
||||
* Returns the 2. number vector.
|
||||
* Returns the second number vector.
|
||||
*
|
||||
* @return 2. number vector
|
||||
* @return second number vector
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
private final int number2;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
public @NotNull String getName() {
|
||||
return "n2";
|
||||
}
|
||||
|
||||
|
@ -81,7 +78,7 @@ public final class TwoNumberVersioningSystem implements VersioningSystem {
|
|||
// Escape separator or throw error if invalid
|
||||
switch (separator) {
|
||||
case "." -> separator = "\\.";
|
||||
case null -> throw new InvalidVersionStringException(this, versionString, "No matching separator could be found. Required are either one dot ('.') or hyphen ('-').");
|
||||
case null -> throw new InvalidVersionStringException(this, versionString, "No matching separator could be found. Required are either one dot ('.') or hyphen ('-')");
|
||||
default -> {}
|
||||
}
|
||||
|
||||
|
@ -93,7 +90,7 @@ public final class TwoNumberVersioningSystem implements VersioningSystem {
|
|||
this.number1 = Integer.parseUnsignedInt(versionStringSplit[0]);
|
||||
this.number2 = Integer.parseUnsignedInt(versionStringSplit[1]);
|
||||
} catch (NumberFormatException exception) {
|
||||
throw new InvalidVersionStringException(this, versionString, "Failed converting one of the vectors to an integer.", exception);
|
||||
throw new InvalidVersionStringException(this, versionString, "Failed converting one of the vectors to an integer", exception);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* Contains built-in versioning systems that
|
||||
* Built-in versioning systems which
|
||||
* can be used to represent versions of some work.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
|
|
|
@ -23,14 +23,16 @@ import de.staropensource.sosengine.base.classes.Event;
|
|||
import de.staropensource.sosengine.base.classes.helpers.EventHelper;
|
||||
|
||||
/**
|
||||
* Called in the event of an engine crash, just before the JVM exists.
|
||||
* Called in the event of an engine crash.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public final class EngineCrashEvent implements Event {
|
||||
/**
|
||||
* Constructs this class.
|
||||
* Constructs this event.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public EngineCrashEvent() {}
|
||||
|
||||
|
|
|
@ -23,13 +23,15 @@ import de.staropensource.sosengine.base.classes.Event;
|
|||
import de.staropensource.sosengine.base.classes.helpers.EventHelper;
|
||||
|
||||
/**
|
||||
* Called when the engine and JVM are about to shutdown.
|
||||
* Called when the engine is about to shutdown.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public final class EngineShutdownEvent implements Event {
|
||||
/**
|
||||
* Constructs this class.
|
||||
* Constructs this event.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public EngineShutdownEvent() {}
|
||||
|
||||
|
|
|
@ -21,17 +21,22 @@ package de.staropensource.sosengine.base.events;
|
|||
|
||||
import de.staropensource.sosengine.base.classes.Event;
|
||||
import de.staropensource.sosengine.base.classes.helpers.EventHelper;
|
||||
import de.staropensource.sosengine.base.logging.Logger;
|
||||
|
||||
/**
|
||||
* Called in the event of a soft engine crash
|
||||
* ie. a crash which was declared as handled.
|
||||
* ie. when a crash report is thrown but marked
|
||||
* as handled.
|
||||
*
|
||||
* @see Logger#crash(Class, String, String, String, Throwable, boolean)
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public final class EngineSoftCrashEvent implements Event {
|
||||
/**
|
||||
* Constructs this class.
|
||||
* Constructs this event.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public EngineSoftCrashEvent() {}
|
||||
|
||||
|
|
|
@ -21,9 +21,9 @@ package de.staropensource.sosengine.base.events;
|
|||
|
||||
import de.staropensource.sosengine.base.classes.Event;
|
||||
import de.staropensource.sosengine.base.classes.helpers.EventHelper;
|
||||
import de.staropensource.sosengine.base.types.logging.LogIssuer;
|
||||
import de.staropensource.sosengine.base.types.logging.LogLevel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Called before a new log message is printed.
|
||||
|
@ -33,28 +33,32 @@ import org.jetbrains.annotations.NotNull;
|
|||
@SuppressWarnings({ "unused" })
|
||||
public final class LogEvent implements Event {
|
||||
/**
|
||||
* Constructs this class.
|
||||
* Constructs this event.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public LogEvent() {}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @deprecated use the {@code callEvent} method with arguments
|
||||
* @see LogEvent#callEvent(LogLevel, LogIssuer, String)
|
||||
* @see #callEvent(LogLevel, Class, String, String, String)
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public void callEvent() {}
|
||||
|
||||
/**
|
||||
* Calls the event and notifies all annotated methods.
|
||||
* Emits the event and calls all event listeners.
|
||||
*
|
||||
* @param level log level
|
||||
* @param logIssuer log issuer
|
||||
* @param message log message
|
||||
* @param level level
|
||||
* @param issuerClass issuer class
|
||||
* @param issuerOrigin issuer origin
|
||||
* @param issuerMetadata issuer metadata
|
||||
* @param message message
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public void callEvent(@NotNull LogLevel level, @NotNull LogIssuer logIssuer, @NotNull String message) {
|
||||
EventHelper.invokeAnnotatedMethods(getClass(), level, logIssuer, message);
|
||||
public void callEvent(@NotNull LogLevel level, @NotNull Class<?> issuerClass, @NotNull String issuerOrigin, @Nullable String issuerMetadata, @NotNull String message) {
|
||||
EventHelper.invokeAnnotatedMethods(getClass(), level, issuerClass, issuerOrigin, issuerMetadata, message);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,14 +25,16 @@ import de.staropensource.sosengine.base.utility.Miscellaneous;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when an exception is caught.
|
||||
* Called when an exception is caught by {@link Miscellaneous#executeSafely(Runnable, String)}.
|
||||
*
|
||||
* @see Miscellaneous#executeSafely(Runnable, String)
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public final class ThrowableCatchEvent implements Event {
|
||||
/**
|
||||
* Constructs this class.
|
||||
* Constructs this event.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public ThrowableCatchEvent() {}
|
||||
|
||||
|
@ -46,7 +48,7 @@ public final class ThrowableCatchEvent implements Event {
|
|||
public void callEvent() {}
|
||||
|
||||
/**
|
||||
* Calls the event and notifies all annotated methods.
|
||||
* Emits the event and calls all event listeners.
|
||||
*
|
||||
* @param throwable caught throwable
|
||||
* @param identifier an identifier given to the runnable
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* Contains events. There's nothing more to say.
|
||||
* Events. There's nothing more to say.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
|
|
|
@ -27,6 +27,12 @@ import org.jetbrains.annotations.NotNull;
|
|||
* @since v1-alpha2
|
||||
*/
|
||||
public class ParserException extends RuntimeException {
|
||||
/**
|
||||
* Constructs this exception.
|
||||
*
|
||||
* @param message parsing error
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
public ParserException(@NotNull String message) {
|
||||
super(message);
|
||||
}
|
||||
|
|
|
@ -22,15 +22,21 @@ package de.staropensource.sosengine.base.exceptions;
|
|||
import de.staropensource.sosengine.base.types.Tristate;
|
||||
|
||||
/**
|
||||
* Thrown when converting a {@link Tristate} into a boolean fails.
|
||||
* Thrown when converting a {@link Tristate} into a {@link Boolean} fails.
|
||||
* <p>
|
||||
* This exception inherits {@link RuntimeException} on purpose, as sometimes
|
||||
* you expect or have already validated the {@link Tristate} not being {@link Tristate#UNSET}.
|
||||
* This exception inherits {@link RuntimeException} on purpose,
|
||||
* as sometimes you may sure/have already validated that the
|
||||
* {@link Tristate} is not {@link Tristate#UNSET}.
|
||||
*
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
public class TristateConversionException extends RuntimeException {
|
||||
/**
|
||||
* Constructs this exception.
|
||||
*
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
public TristateConversionException() {
|
||||
super("Can't convert Tristate.UNSET into a boolean");
|
||||
super("Tristate.UNSET cannot be converted into a boolean");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,27 +23,24 @@ import lombok.Getter;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents an exception caused by some throwable.
|
||||
* Basic wrapper for every throwable there is.
|
||||
* Thrown when a method invokes another method and it throws an unhandled {@link Throwable}.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
@SuppressWarnings({ "unused", "JavadocDeclaration", "JavadocBlankLines" })
|
||||
@SuppressWarnings({ "unused", "JavadocDeclaration" })
|
||||
@Getter
|
||||
public class UnexpectedThrowableException extends Exception {
|
||||
/**
|
||||
* Contains the throwable supplied to the constructor.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*
|
||||
* -- GETTER --
|
||||
* Returns the throwable supplied by the constructor.
|
||||
*
|
||||
* @return throwable
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
@NotNull
|
||||
Throwable throwable;
|
||||
private final @NotNull Throwable throwable;
|
||||
|
||||
/**
|
||||
* Constructs this exception.
|
||||
|
|
|
@ -19,15 +19,16 @@
|
|||
|
||||
package de.staropensource.sosengine.base.exceptions.dependency;
|
||||
|
||||
import de.staropensource.sosengine.base.utility.DependencyResolver;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents an exception caused by a dependency cycle.
|
||||
* Thrown when the {@link DependencyResolver} detects a dependency cycle.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public class DependencyCycleException extends Exception {
|
||||
public class DependencyCycleException extends RuntimeException {
|
||||
/**
|
||||
* Constructs this exception.
|
||||
*
|
||||
|
|
|
@ -20,45 +20,45 @@
|
|||
package de.staropensource.sosengine.base.exceptions.dependency;
|
||||
|
||||
import de.staropensource.sosengine.base.types.DependencyVector;
|
||||
import de.staropensource.sosengine.base.utility.DependencyResolver;
|
||||
import lombok.Getter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Represents an exception caused by unmet dependencies.
|
||||
* Thrown when the {@link DependencyResolver} cannot resolve one
|
||||
* or more {@link DependencyVector}s due to unmet dependencies.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
@SuppressWarnings({ "unused", "JavadocDeclaration", "JavadocBlankLines" })
|
||||
@SuppressWarnings({ "unused", "JavadocDeclaration" })
|
||||
@Getter
|
||||
public class UnmetDependenciesException extends Exception {
|
||||
/**
|
||||
* Contains the unmet dependencies list supplied to the constructor.
|
||||
* <p>
|
||||
* The key contains the {@link DependencyVector} that has unmet dependencies,
|
||||
* while the value contains the error string ie. which dependency is unmet and why.
|
||||
* The key contains the {@link DependencyVector} that
|
||||
* has unmet dependencies, while the value contains the error.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*
|
||||
* -- GETTER --
|
||||
* Returns the unmet dependencies list supplied to the constructor.
|
||||
* <p>
|
||||
* The key contains the {@link DependencyVector} that has unmet dependencies,
|
||||
* while the value contains the error string ie. which dependency is unmet and why.
|
||||
* The key contains the {@link DependencyVector} that
|
||||
* has unmet dependencies, while the value contains the error.
|
||||
*
|
||||
* @return unmet dependencies list
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
@NotNull
|
||||
private final Map<@NotNull DependencyVector, @NotNull String> unmetDependencies;
|
||||
private final @NotNull Map<@NotNull DependencyVector, @NotNull String> unmetDependencies;
|
||||
|
||||
/**
|
||||
* Constructs this exception.
|
||||
*
|
||||
* @param unmetDependencies map of unmet dependencies
|
||||
* @param unmetDependencies map of all unmet dependencies
|
||||
* @see #unmetDependencies
|
||||
* @since v1-alpha1
|
||||
* @see UnmetDependenciesException#unmetDependencies
|
||||
*/
|
||||
public UnmetDependenciesException(@NotNull Map<@NotNull DependencyVector, @NotNull String> unmetDependencies) {
|
||||
this.unmetDependencies = unmetDependencies;
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* Contains exceptions related to dependency resolving.
|
||||
* Exceptions related to dependency resolving.
|
||||
*
|
||||
* @see de.staropensource.sosengine.base.utility.DependencyResolver
|
||||
* @since v1-alpha1
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* Contains exceptions thrown by the engine.
|
||||
* Exceptions thrown by the engine, subsystems and applications.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
|
|
|
@ -24,7 +24,7 @@ import de.staropensource.sosengine.base.utility.ListFormatter;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Thrown when the method called does not apply to the class type.
|
||||
* Thrown when the invoked method does not apply to the type of the class.
|
||||
*
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
|
@ -40,4 +40,15 @@ public class IncompatibleTypeException extends RuntimeException {
|
|||
public IncompatibleTypeException(@NotNull String methodName, @NotNull ClassType requiredClassType, @NotNull ClassType[] compatibleTypes) {
|
||||
super("The method ReflectionClass#" + methodName + " only applies to type(s) " + ListFormatter.formatArray(compatibleTypes) + ", not " + requiredClassType.name());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs this exception.
|
||||
*
|
||||
* @param methodName name of the method that failed
|
||||
* @param requiredClassType class type received by the method
|
||||
* @param compatibleType class type the method is compatible with
|
||||
*/
|
||||
public IncompatibleTypeException(@NotNull String methodName, @NotNull ClassType requiredClassType, @NotNull ClassType compatibleType) {
|
||||
super("The method ReflectionClass#" + methodName + " only applies to type(s) " + ListFormatter.formatArray(new ClassType[]{ compatibleType }) + ", not " + requiredClassType.name());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ package de.staropensource.sosengine.base.exceptions.reflection;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Thrown when trying to call a non-static method from a static context.
|
||||
* Thrown when trying to call an instance (non-static) method from a static context.
|
||||
*
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
|
|
|
@ -21,7 +21,18 @@ package de.staropensource.sosengine.base.exceptions.reflection;
|
|||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Thrown when a method could not be found due to an invalid method signature.
|
||||
*
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public class InvalidMethodSignature extends Exception {
|
||||
/**
|
||||
* Constructs this exception.
|
||||
*
|
||||
* @param methodName method name
|
||||
*/
|
||||
public InvalidMethodSignature(@NotNull String methodName) {
|
||||
super("Method " + methodName + " has a different method signature");
|
||||
}
|
||||
|
|
|
@ -22,12 +22,19 @@ package de.staropensource.sosengine.base.exceptions.reflection;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Thrown if access to some class, method or field is denied.
|
||||
* Thrown if access to some class, method or field has been denied.
|
||||
*
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public class NoAccessException extends Exception {
|
||||
/**
|
||||
* Constructs this exception.
|
||||
*
|
||||
* @param type {@code class}, {@code method} or {@code field}
|
||||
* @param name class, method or field name
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
public NoAccessException(@NotNull String type, @NotNull String name) {
|
||||
super("Access to " + type + " " + name + " has been denied");
|
||||
}
|
||||
|
|
|
@ -23,26 +23,24 @@ import lombok.Getter;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Thrown when an exception occurs
|
||||
* while executing a static initializer.
|
||||
* Thrown when an exception is thrown by a static initializer.
|
||||
*
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
@Getter
|
||||
@SuppressWarnings({ "unused", "JavadocDeclaration", "JavadocBlankLines" })
|
||||
@SuppressWarnings({ "unused", "JavadocDeclaration" })
|
||||
public class StaticInitializerException extends Exception {
|
||||
/**
|
||||
* Contains the throwable supplied to the constructor.
|
||||
* Contains the throwable thrown by the static initializer.
|
||||
*
|
||||
* @since v1-alpha2
|
||||
*
|
||||
* -- GETTER --
|
||||
* Returns the throwable supplied to the constructor.
|
||||
* Returns the throwable thrown by the static initializer.
|
||||
*
|
||||
* @return throwable thrown by the static initializer
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
private final Throwable throwable;
|
||||
private final @NotNull Throwable throwable;
|
||||
|
||||
/**
|
||||
* Constructs this exception.
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* Contains exceptions used during reflection.
|
||||
* Exceptions related to reflection.
|
||||
*
|
||||
* @see de.staropensource.sosengine.base.reflection.Reflect
|
||||
* @see de.staropensource.sosengine.base.reflection
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
package de.staropensource.sosengine.base.exceptions.reflection;
|
||||
|
|
|
@ -22,7 +22,8 @@ package de.staropensource.sosengine.base.exceptions.versioning;
|
|||
import de.staropensource.sosengine.base.classes.VersioningSystem;
|
||||
|
||||
/**
|
||||
* Represents an exception caused by supplying an invalid or unexpected versioning system.
|
||||
* Thrown when trying to compare a {@link VersioningSystem} against another
|
||||
* {@link VersioningSystem}, which it does not support.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
|
|
|
@ -26,26 +26,29 @@ import org.jetbrains.annotations.Nullable;
|
|||
|
||||
|
||||
/**
|
||||
* Represents an exception caused by an invalid version string.
|
||||
* Thrown when an invalid version string is supplied
|
||||
* to an implementation of {@link VersioningSystem}.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
@Getter
|
||||
@SuppressWarnings({ "unused", "JavadocDeclaration", "JavadocBlankLines" })
|
||||
@SuppressWarnings({ "unused", "JavadocDeclaration" })
|
||||
public class InvalidVersionStringException extends Exception {
|
||||
/**
|
||||
* Contains the throwable supplied to the constructor.
|
||||
*
|
||||
* @see #InvalidVersionStringException(VersioningSystem, String, Throwable)
|
||||
* @see #InvalidVersionStringException(VersioningSystem, String, String, Throwable)
|
||||
* @since v1-alpha1
|
||||
*
|
||||
* -- GETTER --
|
||||
* Returns the throwable supplied by the constructor.
|
||||
*
|
||||
* @return throwable
|
||||
* @see #InvalidVersionStringException(VersioningSystem, String, Throwable)
|
||||
* @see #InvalidVersionStringException(VersioningSystem, String, String, Throwable)
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
@Nullable
|
||||
private final Throwable throwable;
|
||||
private final @Nullable Throwable throwable;
|
||||
|
||||
/**
|
||||
* Constructs this exception.
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* Contains exceptions thrown by {@link de.staropensource.sosengine.base.classes.VersioningSystem}s.
|
||||
* Exceptions thrown by implementations of {@link de.staropensource.sosengine.base.classes.VersioningSystem}s.
|
||||
*
|
||||
* @see de.staropensource.sosengine.base.classes.VersioningSystem
|
||||
* @since v1-alpha1
|
||||
|
|
|
@ -23,17 +23,20 @@ import de.staropensource.sosengine.base.classes.Event;
|
|||
import de.staropensource.sosengine.base.classes.helpers.EventHelper;
|
||||
|
||||
/**
|
||||
* Called when the engine and JVM are about to shutdown, after {@link de.staropensource.sosengine.base.events.EngineShutdownEvent}.
|
||||
* Called when the engine is about to shutdown, after {@link de.staropensource.sosengine.base.events.EngineShutdownEvent}.
|
||||
* <p>
|
||||
* Meant for subsystems to perform cleanup and shutdown routines, not for applications.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public final class InternalEngineShutdownEvent implements Event {
|
||||
/**
|
||||
* Constructs this class.
|
||||
* Constructs this event.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public InternalEngineShutdownEvent() {}
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void callEvent() {
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* Contains engine-internal stuff, not part of the API.
|
||||
* Engine-internal stuff, not part of the API.
|
||||
*
|
||||
* @since v1-alpha1
|
||||
*/
|
||||
|
|
|
@ -41,9 +41,8 @@ public final class DateDay implements Placeholder {
|
|||
public DateDay() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%date_day%", Math.padNumbers(Calendar.getInstance().get(Calendar.DAY_OF_MONTH), 2));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,9 +41,8 @@ public final class DateMonth implements Placeholder {
|
|||
public DateMonth() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%date_month%", Math.padNumbers(Calendar.getInstance().get(Calendar.MONTH), 2));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,9 +41,8 @@ public final class DateYear implements Placeholder {
|
|||
public DateYear() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%date_year%", Math.padNumbers(Calendar.getInstance().get(Calendar.YEAR), 4));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
package de.staropensource.sosengine.base.internal.placeholders;
|
||||
|
||||
import de.staropensource.sosengine.base.classes.Placeholder;
|
||||
import de.staropensource.sosengine.base.data.info.EngineInformation;
|
||||
import de.staropensource.sosengine.base.data.information.EngineInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
|
@ -39,9 +39,8 @@ public final class EngineDependencyJansi implements Placeholder {
|
|||
public EngineDependencyJansi() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%engine_dependency_jansi%", EngineInformation.getDependencyJansi());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
package de.staropensource.sosengine.base.internal.placeholders;
|
||||
|
||||
import de.staropensource.sosengine.base.classes.Placeholder;
|
||||
import de.staropensource.sosengine.base.data.info.EngineInformation;
|
||||
import de.staropensource.sosengine.base.data.information.EngineInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
|
@ -39,9 +39,8 @@ public final class EngineDependencyLwjgl implements Placeholder {
|
|||
public EngineDependencyLwjgl() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%engine_dependency_lwjgl%", EngineInformation.getDependencyLwjgl());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
package de.staropensource.sosengine.base.internal.placeholders;
|
||||
|
||||
import de.staropensource.sosengine.base.classes.Placeholder;
|
||||
import de.staropensource.sosengine.base.data.info.EngineInformation;
|
||||
import de.staropensource.sosengine.base.data.information.EngineInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
|
@ -39,9 +39,8 @@ public final class EngineDependencyReflections implements Placeholder {
|
|||
public EngineDependencyReflections() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%engine_dependency_reflections%", EngineInformation.getDependencyReflections());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
package de.staropensource.sosengine.base.internal.placeholders;
|
||||
|
||||
import de.staropensource.sosengine.base.classes.Placeholder;
|
||||
import de.staropensource.sosengine.base.data.info.EngineInformation;
|
||||
import de.staropensource.sosengine.base.data.information.EngineInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
|
@ -39,9 +39,8 @@ public final class EngineDependencySlf4j implements Placeholder {
|
|||
public EngineDependencySlf4j() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%engine_dependency_slf4j%", EngineInformation.getDependencySlf4j());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
package de.staropensource.sosengine.base.internal.placeholders;
|
||||
|
||||
import de.staropensource.sosengine.base.classes.Placeholder;
|
||||
import de.staropensource.sosengine.base.data.info.EngineInformation;
|
||||
import de.staropensource.sosengine.base.data.information.EngineInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
|
@ -39,9 +39,8 @@ public final class EngineGitBranch implements Placeholder {
|
|||
public EngineGitBranch() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%engine_git_branch%", EngineInformation.getGitBranch());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
package de.staropensource.sosengine.base.internal.placeholders;
|
||||
|
||||
import de.staropensource.sosengine.base.classes.Placeholder;
|
||||
import de.staropensource.sosengine.base.data.info.EngineInformation;
|
||||
import de.staropensource.sosengine.base.data.information.EngineInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
|
@ -39,9 +39,8 @@ public final class EngineGitCommitHeader implements Placeholder {
|
|||
public EngineGitCommitHeader() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%engine_git_commit_header%", EngineInformation.getGitCommitHeader());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
package de.staropensource.sosengine.base.internal.placeholders;
|
||||
|
||||
import de.staropensource.sosengine.base.classes.Placeholder;
|
||||
import de.staropensource.sosengine.base.data.info.EngineInformation;
|
||||
import de.staropensource.sosengine.base.data.information.EngineInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
|
@ -39,9 +39,8 @@ public final class EngineGitCommitIdLong implements Placeholder {
|
|||
public EngineGitCommitIdLong() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%engine_git_commit_id_long%", EngineInformation.getGitCommitIdentifierLong());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
package de.staropensource.sosengine.base.internal.placeholders;
|
||||
|
||||
import de.staropensource.sosengine.base.classes.Placeholder;
|
||||
import de.staropensource.sosengine.base.data.info.EngineInformation;
|
||||
import de.staropensource.sosengine.base.data.information.EngineInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
|
@ -39,9 +39,8 @@ public final class EngineGitCommitIdShort implements Placeholder {
|
|||
public EngineGitCommitIdShort() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%engine_git_commit_id_short%", EngineInformation.getGitCommitIdentifierShort());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
package de.staropensource.sosengine.base.internal.placeholders;
|
||||
|
||||
import de.staropensource.sosengine.base.classes.Placeholder;
|
||||
import de.staropensource.sosengine.base.data.info.EngineInformation;
|
||||
import de.staropensource.sosengine.base.data.information.EngineInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
|
@ -39,9 +39,8 @@ public final class EngineGitCommitTimeDay implements Placeholder {
|
|||
public EngineGitCommitTimeDay() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%engine_git_commit_time_day%", String.valueOf(EngineInformation.getGitCommitTime().getDayOfMonth()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
package de.staropensource.sosengine.base.internal.placeholders;
|
||||
|
||||
import de.staropensource.sosengine.base.classes.Placeholder;
|
||||
import de.staropensource.sosengine.base.data.info.EngineInformation;
|
||||
import de.staropensource.sosengine.base.data.information.EngineInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
|
@ -39,9 +39,8 @@ public final class EngineGitCommitTimeHour implements Placeholder {
|
|||
public EngineGitCommitTimeHour() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%engine_git_commit_time_hour%", String.valueOf(EngineInformation.getGitCommitTime().getHour()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
package de.staropensource.sosengine.base.internal.placeholders;
|
||||
|
||||
import de.staropensource.sosengine.base.classes.Placeholder;
|
||||
import de.staropensource.sosengine.base.data.info.EngineInformation;
|
||||
import de.staropensource.sosengine.base.data.information.EngineInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
|
@ -39,9 +39,8 @@ public final class EngineGitCommitTimeMinute implements Placeholder {
|
|||
public EngineGitCommitTimeMinute() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%engine_git_commit_time_minute%", String.valueOf(EngineInformation.getGitCommitTime().getMinute()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
package de.staropensource.sosengine.base.internal.placeholders;
|
||||
|
||||
import de.staropensource.sosengine.base.classes.Placeholder;
|
||||
import de.staropensource.sosengine.base.data.info.EngineInformation;
|
||||
import de.staropensource.sosengine.base.data.information.EngineInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
|
@ -39,9 +39,8 @@ public final class EngineGitCommitTimeMonth implements Placeholder {
|
|||
public EngineGitCommitTimeMonth() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%engine_git_commit_time_month%", String.valueOf(EngineInformation.getGitCommitTime().getMonth()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
package de.staropensource.sosengine.base.internal.placeholders;
|
||||
|
||||
import de.staropensource.sosengine.base.classes.Placeholder;
|
||||
import de.staropensource.sosengine.base.data.info.EngineInformation;
|
||||
import de.staropensource.sosengine.base.data.information.EngineInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
|
@ -39,9 +39,8 @@ public final class EngineGitCommitTimeSecond implements Placeholder {
|
|||
public EngineGitCommitTimeSecond() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%engine_git_commit_time_second%", String.valueOf(EngineInformation.getGitCommitTime().getSecond()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
package de.staropensource.sosengine.base.internal.placeholders;
|
||||
|
||||
import de.staropensource.sosengine.base.classes.Placeholder;
|
||||
import de.staropensource.sosengine.base.data.info.EngineInformation;
|
||||
import de.staropensource.sosengine.base.data.information.EngineInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
|
@ -39,9 +39,8 @@ public final class EngineGitCommitTimeYear implements Placeholder {
|
|||
public EngineGitCommitTimeYear() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%engine_git_commit_time_year%", String.valueOf(EngineInformation.getGitCommitTime().getYear()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
package de.staropensource.sosengine.base.internal.placeholders;
|
||||
|
||||
import de.staropensource.sosengine.base.classes.Placeholder;
|
||||
import de.staropensource.sosengine.base.data.info.EngineInformation;
|
||||
import de.staropensource.sosengine.base.data.information.EngineInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
|
@ -39,9 +39,8 @@ public final class EngineGitCommits implements Placeholder {
|
|||
public EngineGitCommits() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%engine_git_commits%", String.valueOf(EngineInformation.getGitCommitCount()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
package de.staropensource.sosengine.base.internal.placeholders;
|
||||
|
||||
import de.staropensource.sosengine.base.classes.Placeholder;
|
||||
import de.staropensource.sosengine.base.data.info.EngineInformation;
|
||||
import de.staropensource.sosengine.base.data.information.EngineInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
|
@ -39,9 +39,8 @@ public final class EngineGitCommitterEmail implements Placeholder {
|
|||
public EngineGitCommitterEmail() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%engine_git_committer_email%", EngineInformation.getGitCommitterEmail());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
package de.staropensource.sosengine.base.internal.placeholders;
|
||||
|
||||
import de.staropensource.sosengine.base.classes.Placeholder;
|
||||
import de.staropensource.sosengine.base.data.info.EngineInformation;
|
||||
import de.staropensource.sosengine.base.data.information.EngineInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
|
@ -39,9 +39,8 @@ public final class EngineGitCommitterName implements Placeholder {
|
|||
public EngineGitCommitterName() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%engine_git_committer_name%", EngineInformation.getGitCommitterName());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
package de.staropensource.sosengine.base.internal.placeholders;
|
||||
|
||||
import de.staropensource.sosengine.base.classes.Placeholder;
|
||||
import de.staropensource.sosengine.base.data.info.EngineInformation;
|
||||
import de.staropensource.sosengine.base.data.information.EngineInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
|
@ -39,9 +39,8 @@ public final class EngineGitDirty implements Placeholder {
|
|||
public EngineGitDirty() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%engine_git_dirty%", String.valueOf(EngineInformation.getGitDirty()));
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%engine_git_dirty%", String.valueOf(EngineInformation.isGitDirty()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,9 +38,8 @@ public final class EngineVersion implements Placeholder {
|
|||
public EngineVersion() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%engine_version%", "v%engine_version_version%-%engine_version_type%%engine_version_typerelease%%engine_version_fork%");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
package de.staropensource.sosengine.base.internal.placeholders;
|
||||
|
||||
import de.staropensource.sosengine.base.classes.Placeholder;
|
||||
import de.staropensource.sosengine.base.data.info.EngineInformation;
|
||||
import de.staropensource.sosengine.base.data.information.EngineInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
|
@ -39,9 +39,8 @@ public final class EngineVersionFork implements Placeholder {
|
|||
public EngineVersionFork() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%engine_version_fork%", EngineInformation.getVersioningFork());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
package de.staropensource.sosengine.base.internal.placeholders;
|
||||
|
||||
import de.staropensource.sosengine.base.classes.Placeholder;
|
||||
import de.staropensource.sosengine.base.data.info.EngineInformation;
|
||||
import de.staropensource.sosengine.base.data.information.EngineInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
|
@ -39,9 +39,8 @@ public final class EngineVersionType implements Placeholder {
|
|||
public EngineVersionType() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%engine_version_type%", EngineInformation.getVersioningType().name().toLowerCase());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
package de.staropensource.sosengine.base.internal.placeholders;
|
||||
|
||||
import de.staropensource.sosengine.base.classes.Placeholder;
|
||||
import de.staropensource.sosengine.base.data.info.EngineInformation;
|
||||
import de.staropensource.sosengine.base.data.information.EngineInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
|
@ -39,9 +39,8 @@ public final class EngineVersionTyperelease implements Placeholder {
|
|||
public EngineVersionTyperelease() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%engine_version_typerelease%", String.valueOf(EngineInformation.getVersioningTyperelease()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
package de.staropensource.sosengine.base.internal.placeholders;
|
||||
|
||||
import de.staropensource.sosengine.base.classes.Placeholder;
|
||||
import de.staropensource.sosengine.base.data.info.EngineInformation;
|
||||
import de.staropensource.sosengine.base.data.information.EngineInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
|
@ -39,9 +39,8 @@ public final class EngineVersionVersion implements Placeholder {
|
|||
public EngineVersionVersion() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%engine_version_version%", String.valueOf(EngineInformation.getVersioningVersion()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
package de.staropensource.sosengine.base.internal.placeholders;
|
||||
|
||||
import de.staropensource.sosengine.base.classes.Placeholder;
|
||||
import de.staropensource.sosengine.base.data.info.JvmInformation;
|
||||
import de.staropensource.sosengine.base.data.information.JvmInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
|
@ -39,9 +39,8 @@ public final class JvmArguments implements Placeholder {
|
|||
public JvmArguments() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
StringBuilder arguments = new StringBuilder();
|
||||
|
||||
for (String argument : JvmInformation.getArguments()) {
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
package de.staropensource.sosengine.base.internal.placeholders;
|
||||
|
||||
import de.staropensource.sosengine.base.classes.Placeholder;
|
||||
import de.staropensource.sosengine.base.data.info.JvmInformation;
|
||||
import de.staropensource.sosengine.base.data.information.JvmInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
|
@ -39,9 +39,8 @@ public final class JvmImplementationName implements Placeholder {
|
|||
public JvmImplementationName() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%jvm_implementation_name%", JvmInformation.getImplementationName());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
package de.staropensource.sosengine.base.internal.placeholders;
|
||||
|
||||
import de.staropensource.sosengine.base.classes.Placeholder;
|
||||
import de.staropensource.sosengine.base.data.info.JvmInformation;
|
||||
import de.staropensource.sosengine.base.data.information.JvmInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
|
@ -39,9 +39,8 @@ public final class JvmImplementationVendor implements Placeholder {
|
|||
public JvmImplementationVendor() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%jvm_implementation_vendor%", JvmInformation.getImplementationVendor());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
package de.staropensource.sosengine.base.internal.placeholders;
|
||||
|
||||
import de.staropensource.sosengine.base.classes.Placeholder;
|
||||
import de.staropensource.sosengine.base.data.info.JvmInformation;
|
||||
import de.staropensource.sosengine.base.data.information.JvmInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
|
@ -39,9 +39,8 @@ public final class JvmImplementationVersion implements Placeholder {
|
|||
public JvmImplementationVersion() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%jvm_implementation_version%", JvmInformation.getImplementationVersion());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
package de.staropensource.sosengine.base.internal.placeholders;
|
||||
|
||||
import de.staropensource.sosengine.base.classes.Placeholder;
|
||||
import de.staropensource.sosengine.base.data.info.JvmInformation;
|
||||
import de.staropensource.sosengine.base.data.information.JvmInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
|
@ -39,9 +39,8 @@ public final class JvmJava implements Placeholder {
|
|||
public JvmJava() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%jvm_java%", String.valueOf(JvmInformation.getJavaVersion()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
package de.staropensource.sosengine.base.internal.placeholders;
|
||||
|
||||
import de.staropensource.sosengine.base.classes.Placeholder;
|
||||
import de.staropensource.sosengine.base.data.info.JvmInformation;
|
||||
import de.staropensource.sosengine.base.data.information.JvmInformation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
|
@ -39,9 +39,8 @@ public final class JvmUptime implements Placeholder {
|
|||
public JvmUptime() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%jvm_uptime%", String.valueOf(JvmInformation.getUptime()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,9 +40,8 @@ public final class TimeEpoch implements Placeholder {
|
|||
public TimeEpoch() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%time_epoch%", Math.padNumbers(System.currentTimeMillis(), String.valueOf(Long.MAX_VALUE).length()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,9 +41,8 @@ public final class TimeHour implements Placeholder {
|
|||
public TimeHour() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%time_hour%", Math.padNumbers(Calendar.getInstance().get(Calendar.HOUR_OF_DAY), 2));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,9 +41,8 @@ public final class TimeMinute implements Placeholder {
|
|||
public TimeMinute() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%time_minute%", Math.padNumbers(Calendar.getInstance().get(Calendar.MINUTE), 2));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,9 +41,8 @@ public final class TimeSecond implements Placeholder {
|
|||
public TimeSecond() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%time_second%", Math.padNumbers(Calendar.getInstance().get(Calendar.SECOND), 2));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,9 +40,8 @@ public final class TimeZone implements Placeholder {
|
|||
public TimeZone() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%time_zone%", java.util.TimeZone.getDefault().getDisplayName(false, java.util.TimeZone.SHORT, Locale.US));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,13 +23,13 @@ import de.staropensource.sosengine.base.classes.Placeholder;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Implements the {@code issuer_message} placeholder.
|
||||
* Implements the {@code crash_message} placeholder.
|
||||
*
|
||||
* @see Placeholder
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public final class IssuerMessage implements Placeholder {
|
||||
public final class CrashMessage implements Placeholder {
|
||||
/**
|
||||
* The message to use.
|
||||
*
|
||||
|
@ -44,14 +44,13 @@ public final class IssuerMessage implements Placeholder {
|
|||
* @param message message to use
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public IssuerMessage(@NotNull String message) {
|
||||
public CrashMessage(@NotNull String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%issuer_message%", message);
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%crash_message%", message);
|
||||
}
|
||||
}
|
|
@ -20,7 +20,6 @@
|
|||
package de.staropensource.sosengine.base.internal.placeholders.crashhandler;
|
||||
|
||||
import de.staropensource.sosengine.base.classes.Placeholder;
|
||||
import de.staropensource.sosengine.base.types.logging.LogIssuer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
|
@ -32,27 +31,25 @@ import org.jetbrains.annotations.NotNull;
|
|||
@SuppressWarnings({ "unused" })
|
||||
public final class IssuerClass implements Placeholder {
|
||||
/**
|
||||
* The {@link LogIssuer} to use.
|
||||
* Issuer class to use.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
@NotNull
|
||||
private final LogIssuer logIssuer;
|
||||
private final @NotNull Class<?> issuerClass;
|
||||
|
||||
/**
|
||||
* Constructs this class.
|
||||
*
|
||||
* @param logIssuer {@link LogIssuer} to use
|
||||
* @param issuerClass issuer class to use
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public IssuerClass(@NotNull LogIssuer logIssuer) {
|
||||
this.logIssuer = logIssuer;
|
||||
public IssuerClass(@NotNull Class<?> issuerClass) {
|
||||
this.issuerClass = issuerClass;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%issuer_class%", logIssuer.getClazz().getName().replace(logIssuer.getClazz().getPackageName() + ".", ""));
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%issuer_class%", issuerClass.getName().replace(issuerClass.getPackageName() + ".", ""));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,44 +20,42 @@
|
|||
package de.staropensource.sosengine.base.internal.placeholders.crashhandler;
|
||||
|
||||
import de.staropensource.sosengine.base.classes.Placeholder;
|
||||
import de.staropensource.sosengine.base.types.logging.LogIssuer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Implements the {@code issuer_info} placeholder.
|
||||
* Implements the {@code issuer_metadata} placeholder.
|
||||
*
|
||||
* @see Placeholder
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public final class IssuerInfo implements Placeholder {
|
||||
public final class IssuerMetadata implements Placeholder {
|
||||
/**
|
||||
* The {@link LogIssuer} to use.
|
||||
* Issuer metadata to use.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@NotNull
|
||||
private final LogIssuer logIssuer;
|
||||
private final @Nullable String issuerMetadata;
|
||||
|
||||
/**
|
||||
* Constructs this class.
|
||||
*
|
||||
* @param logIssuer {@link LogIssuer} to use
|
||||
* @param issuerMetadata issuer metadata to use
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public IssuerInfo(@NotNull LogIssuer logIssuer) {
|
||||
this.logIssuer = logIssuer;
|
||||
public IssuerMetadata(@Nullable String issuerMetadata) {
|
||||
this.issuerMetadata = issuerMetadata;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
String replacement = "\\<none>";
|
||||
|
||||
if (logIssuer.getAdditionalInformation() != null)
|
||||
replacement = logIssuer.getAdditionalInformation();
|
||||
if (issuerMetadata != null)
|
||||
replacement = issuerMetadata;
|
||||
|
||||
return text.replace("%issuer_info%", replacement);
|
||||
return text.replace("%issuer_metadata%", replacement);
|
||||
}
|
||||
}
|
|
@ -20,39 +20,38 @@
|
|||
package de.staropensource.sosengine.base.internal.placeholders.crashhandler;
|
||||
|
||||
import de.staropensource.sosengine.base.classes.Placeholder;
|
||||
import de.staropensource.sosengine.base.types.logging.LogIssuer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Implements the {@code issuer_code_part} placeholder.
|
||||
* Implements the {@code issuer_origin} placeholder.
|
||||
*
|
||||
* @see Placeholder
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@SuppressWarnings({ "unused" })
|
||||
public final class IssuerCodePart implements Placeholder {
|
||||
public final class IssuerOrigin implements Placeholder {
|
||||
/**
|
||||
* The {@link LogIssuer} to use.
|
||||
* Issuer origin to use.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
@NotNull
|
||||
private final LogIssuer logIssuer;
|
||||
private final @NotNull String issuerOrigin;
|
||||
|
||||
/**
|
||||
* Constructs this class.
|
||||
*
|
||||
* @param logIssuer {@link LogIssuer} to use
|
||||
* @param issuerOrigin issuer origin to use
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public IssuerCodePart(@NotNull LogIssuer logIssuer) {
|
||||
this.logIssuer = logIssuer;
|
||||
public IssuerOrigin(@NotNull String issuerOrigin) {
|
||||
this.issuerOrigin = issuerOrigin;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%issuer_code_part%", logIssuer.getCodePart().name());
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%issuer_origin%", issuerOrigin.toUpperCase(Locale.ROOT));
|
||||
}
|
||||
}
|
|
@ -20,7 +20,6 @@
|
|||
package de.staropensource.sosengine.base.internal.placeholders.crashhandler;
|
||||
|
||||
import de.staropensource.sosengine.base.classes.Placeholder;
|
||||
import de.staropensource.sosengine.base.types.logging.LogIssuer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
|
@ -32,27 +31,25 @@ import org.jetbrains.annotations.NotNull;
|
|||
@SuppressWarnings({ "unused" })
|
||||
public final class IssuerPackage implements Placeholder {
|
||||
/**
|
||||
* The {@link LogIssuer} to use.
|
||||
* Issuer class to use.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
@NotNull
|
||||
private final LogIssuer logIssuer;
|
||||
private final @NotNull Class<?> issuerClass;
|
||||
|
||||
/**
|
||||
* Constructs this class.
|
||||
*
|
||||
* @param logIssuer {@link LogIssuer} to use
|
||||
* @param issuerClass issuer class to use
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public IssuerPackage(@NotNull LogIssuer logIssuer) {
|
||||
this.logIssuer = logIssuer;
|
||||
public IssuerPackage(@NotNull Class<?> issuerClass) {
|
||||
this.issuerClass = issuerClass;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%issuer_package%", logIssuer.getClazz().getPackageName());
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%issuer_package%", issuerClass.getPackageName());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
package de.staropensource.sosengine.base.internal.placeholders.crashhandler;
|
||||
|
||||
import de.staropensource.sosengine.base.classes.Placeholder;
|
||||
import de.staropensource.sosengine.base.types.logging.LogIssuer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
|
@ -32,27 +31,25 @@ import org.jetbrains.annotations.NotNull;
|
|||
@SuppressWarnings({ "unused" })
|
||||
public final class IssuerPath implements Placeholder {
|
||||
/**
|
||||
* The {@link LogIssuer} to use.
|
||||
* Issuer class to use.
|
||||
*
|
||||
* @since v1-alpha0
|
||||
* @since v1-alpha2
|
||||
*/
|
||||
@NotNull
|
||||
private final LogIssuer logIssuer;
|
||||
private final @NotNull Class<?> issuerClass;
|
||||
|
||||
/**
|
||||
* Constructs this class.
|
||||
*
|
||||
* @param logIssuer {@link LogIssuer} to use
|
||||
* @param issuerClass issuer class to use
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
public IssuerPath(@NotNull LogIssuer logIssuer) {
|
||||
this.logIssuer = logIssuer;
|
||||
public IssuerPath(@NotNull Class<?> issuerClass) {
|
||||
this.issuerClass = issuerClass;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
return text.replace("%issuer_path%", logIssuer.getClazz().getName());
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%issuer_path%", issuerClass.getName());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,8 +40,7 @@ public final class Stacktrace implements Placeholder {
|
|||
*
|
||||
* @since v1-alpha0
|
||||
*/
|
||||
@Nullable
|
||||
private final Throwable throwable;
|
||||
private final @Nullable Throwable throwable;
|
||||
|
||||
/**
|
||||
* Constructs this class.
|
||||
|
@ -54,9 +53,8 @@ public final class Stacktrace implements Placeholder {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
return text.replace("%stacktrace%", throwable == null ? "No stack trace is available." : getFullStackTrace(throwable));
|
||||
}
|
||||
|
||||
|
|
|
@ -41,9 +41,8 @@ public final class StacktraceAll implements Placeholder {
|
|||
public StacktraceAll() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@NotNull
|
||||
@Override
|
||||
public String replace(@NotNull String text) {
|
||||
public @NotNull String replace(@NotNull String text) {
|
||||
StringBuilder output = new StringBuilder();
|
||||
Map<Thread, StackTraceElement[]> stacktraces = Thread.getAllStackTraces();
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue