Add hideFullTypePath engine setting

This commit is contained in:
JeremyStar™ 2024-07-23 20:19:49 +02:00
parent 062b68a93b
commit a07dc6db84
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D
5 changed files with 46 additions and 4 deletions

View file

@ -25,6 +25,7 @@ import de.staropensource.sosengine.base.logging.Logger;
import de.staropensource.sosengine.base.types.CodePart; import de.staropensource.sosengine.base.types.CodePart;
import de.staropensource.sosengine.base.types.logging.LogIssuer; import de.staropensource.sosengine.base.types.logging.LogIssuer;
import de.staropensource.sosengine.base.types.logging.LogLevel; 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.converter.AnsiShortcodeConverter;
import de.staropensource.sosengine.base.utility.parser.PropertyParser; import de.staropensource.sosengine.base.utility.parser.PropertyParser;
import lombok.Getter; import lombok.Getter;
@ -273,6 +274,25 @@ public final class EngineConfiguration implements SubsystemConfiguration {
*/ */
private int loggerPollingSpeed; private int loggerPollingSpeed;
/**
* 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
* 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. * Constructs this class.
* *
@ -328,6 +348,8 @@ public final class EngineConfiguration implements SubsystemConfiguration {
case "loggerImmediateShutdown" -> loggerImmediateShutdown = parser.getBoolean(group + property); case "loggerImmediateShutdown" -> loggerImmediateShutdown = parser.getBoolean(group + property);
case "loggerForceStandardOutput" -> loggerForceStandardOutput = parser.getBoolean(group + property); case "loggerForceStandardOutput" -> loggerForceStandardOutput = parser.getBoolean(group + property);
case "loggerPollingSpeed" -> loggerPollingSpeed = parser.getInteger(group + property, true); case "loggerPollingSpeed" -> loggerPollingSpeed = parser.getInteger(group + property, true);
case "hideFullTypePath" -> hideFullTypePath = parser.getBoolean(group + property);
} }
} catch (NullPointerException ignored) {} } catch (NullPointerException ignored) {}
} }
@ -361,6 +383,8 @@ public final class EngineConfiguration implements SubsystemConfiguration {
loggerImmediateShutdown = false; loggerImmediateShutdown = false;
loggerForceStandardOutput = false; loggerForceStandardOutput = false;
loggerPollingSpeed = 5; loggerPollingSpeed = 5;
hideFullTypePath = false;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@ -382,6 +406,8 @@ public final class EngineConfiguration implements SubsystemConfiguration {
case "loggerImmediateShutdown" -> { return loggerImmediateShutdown; } case "loggerImmediateShutdown" -> { return loggerImmediateShutdown; }
case "loggerForceStandardOutput" -> { return loggerForceStandardOutput; } case "loggerForceStandardOutput" -> { return loggerForceStandardOutput; }
case "loggerPollingSpeed" -> { return loggerPollingSpeed; } case "loggerPollingSpeed" -> { return loggerPollingSpeed; }
case "hideFullTypePath" -> { return hideFullTypePath; }
default -> { return null; } default -> { return null; }
} }
} }

View file

@ -19,6 +19,7 @@
package de.staropensource.sosengine.base.types.vectors; package de.staropensource.sosengine.base.types.vectors;
import de.staropensource.sosengine.base.EngineConfiguration;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.SneakyThrows; import lombok.SneakyThrows;
@ -104,6 +105,9 @@ public class Vec2 {
@NotNull @NotNull
@Override @Override
public String toString() { 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 + ")";
} }
} }

View file

@ -19,6 +19,7 @@
package de.staropensource.sosengine.base.types.vectors; package de.staropensource.sosengine.base.types.vectors;
import de.staropensource.sosengine.base.EngineConfiguration;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.SneakyThrows; import lombok.SneakyThrows;
@ -104,6 +105,9 @@ public class Vec2i implements Cloneable {
@NotNull @NotNull
@Override @Override
public String toString() { 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 + ")";
} }
} }

View file

@ -19,6 +19,7 @@
package de.staropensource.sosengine.base.types.vectors; package de.staropensource.sosengine.base.types.vectors;
import de.staropensource.sosengine.base.EngineConfiguration;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.SneakyThrows; import lombok.SneakyThrows;
@ -125,6 +126,9 @@ public class Vec3 {
@NotNull @NotNull
@Override @Override
public String toString() { 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 + ")";
} }
} }

View file

@ -19,6 +19,7 @@
package de.staropensource.sosengine.base.types.vectors; package de.staropensource.sosengine.base.types.vectors;
import de.staropensource.sosengine.base.EngineConfiguration;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.SneakyThrows; import lombok.SneakyThrows;
@ -125,6 +126,9 @@ public class Vec3i {
@NotNull @NotNull
@Override @Override
public String toString() { 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 + ")";
} }
} }