diff --git a/base/src/main/java/de/staropensource/sosengine/base/EngineConfiguration.java b/base/src/main/java/de/staropensource/sosengine/base/EngineConfiguration.java index e43eaf2..6c90c5b 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/EngineConfiguration.java +++ b/base/src/main/java/de/staropensource/sosengine/base/EngineConfiguration.java @@ -25,6 +25,7 @@ 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.utility.converter.AnsiShortcodeConverter; import de.staropensource.sosengine.base.utility.parser.PropertyParser; import lombok.Getter; @@ -273,6 +274,25 @@ public final class EngineConfiguration implements SubsystemConfiguration { */ private int loggerPollingSpeed; + /** + * Will truncate the path of types when using their {@code toString} method. + *
+ * 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 + * 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}. + * + * @return variable value + * @see EngineConfiguration#hideFullTypePath + * @since v1-alpha2 + */ + private boolean hideFullTypePath; + /** * Constructs this class. * @@ -328,6 +348,8 @@ public final class EngineConfiguration implements SubsystemConfiguration { case "loggerImmediateShutdown" -> loggerImmediateShutdown = parser.getBoolean(group + property); case "loggerForceStandardOutput" -> loggerForceStandardOutput = parser.getBoolean(group + property); case "loggerPollingSpeed" -> loggerPollingSpeed = parser.getInteger(group + property, true); + + case "hideFullTypePath" -> hideFullTypePath = parser.getBoolean(group + property); } } catch (NullPointerException ignored) {} } @@ -361,6 +383,8 @@ public final class EngineConfiguration implements SubsystemConfiguration { loggerImmediateShutdown = false; loggerForceStandardOutput = false; loggerPollingSpeed = 5; + + hideFullTypePath = false; } /** {@inheritDoc} */ @@ -382,6 +406,8 @@ public final class EngineConfiguration implements SubsystemConfiguration { case "loggerImmediateShutdown" -> { return loggerImmediateShutdown; } case "loggerForceStandardOutput" -> { return loggerForceStandardOutput; } case "loggerPollingSpeed" -> { return loggerPollingSpeed; } + + case "hideFullTypePath" -> { return hideFullTypePath; } default -> { return null; } } } diff --git a/base/src/main/java/de/staropensource/sosengine/base/types/vectors/Vec2.java b/base/src/main/java/de/staropensource/sosengine/base/types/vectors/Vec2.java index c4dfe8d..63d4285 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/types/vectors/Vec2.java +++ b/base/src/main/java/de/staropensource/sosengine/base/types/vectors/Vec2.java @@ -19,6 +19,7 @@ package de.staropensource.sosengine.base.types.vectors; +import de.staropensource.sosengine.base.EngineConfiguration; import lombok.Getter; import lombok.Setter; import lombok.SneakyThrows; @@ -104,6 +105,9 @@ public class Vec2 { @NotNull @Override public String toString() { - return getClass().getName() + "(x=" + x + " y=" + y + ")"; + return (EngineConfiguration.getInstance().isHideFullTypePath() + ? getClass().getName().replace(getClass().getPackage() + ".", "") + : getClass().getName()) + + "(x=" + x + " y=" + y + ")"; } } diff --git a/base/src/main/java/de/staropensource/sosengine/base/types/vectors/Vec2i.java b/base/src/main/java/de/staropensource/sosengine/base/types/vectors/Vec2i.java index 3b82272..700ab41 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/types/vectors/Vec2i.java +++ b/base/src/main/java/de/staropensource/sosengine/base/types/vectors/Vec2i.java @@ -19,6 +19,7 @@ package de.staropensource.sosengine.base.types.vectors; +import de.staropensource.sosengine.base.EngineConfiguration; import lombok.Getter; import lombok.Setter; import lombok.SneakyThrows; @@ -104,6 +105,9 @@ public class Vec2i implements Cloneable { @NotNull @Override public String toString() { - return getClass().getName() + "(x=" + x + " y=" + y + ")"; + return (EngineConfiguration.getInstance().isHideFullTypePath() + ? getClass().getName().replace(getClass().getPackage() + ".", "") + : getClass().getName()) + + "(x=" + x + " y=" + y + ")"; } } diff --git a/base/src/main/java/de/staropensource/sosengine/base/types/vectors/Vec3.java b/base/src/main/java/de/staropensource/sosengine/base/types/vectors/Vec3.java index 2fdcd62..e4dcf19 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/types/vectors/Vec3.java +++ b/base/src/main/java/de/staropensource/sosengine/base/types/vectors/Vec3.java @@ -19,6 +19,7 @@ package de.staropensource.sosengine.base.types.vectors; +import de.staropensource.sosengine.base.EngineConfiguration; import lombok.Getter; import lombok.Setter; import lombok.SneakyThrows; @@ -125,6 +126,9 @@ public class Vec3 { @NotNull @Override public String toString() { - return getClass().getName() + "(x=" + x + " y=" + y + " z=" + z + ")"; + return (EngineConfiguration.getInstance().isHideFullTypePath() + ? getClass().getName().replace(getClass().getPackage() + ".", "") + : getClass().getName()) + + "(x=" + x + " y=" + y + ")"; } } diff --git a/base/src/main/java/de/staropensource/sosengine/base/types/vectors/Vec3i.java b/base/src/main/java/de/staropensource/sosengine/base/types/vectors/Vec3i.java index 42b6baf..fb5dd8c 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/types/vectors/Vec3i.java +++ b/base/src/main/java/de/staropensource/sosengine/base/types/vectors/Vec3i.java @@ -19,6 +19,7 @@ package de.staropensource.sosengine.base.types.vectors; +import de.staropensource.sosengine.base.EngineConfiguration; import lombok.Getter; import lombok.Setter; import lombok.SneakyThrows; @@ -125,6 +126,9 @@ public class Vec3i { @NotNull @Override public String toString() { - return getClass().getName() + "(x=" + x + " y=" + y + " z=" + z + ")"; + return (EngineConfiguration.getInstance().isHideFullTypePath() + ? getClass().getName().replace(getClass().getPackage() + ".", "") + : getClass().getName()) + + "(x=" + x + " y=" + y + ")"; } }