aboutsummaryrefslogtreecommitdiff
path: root/common/src/main/java/dev/isxander/yacl/config/ConfigInstance.java
diff options
context:
space:
mode:
authorisXander <xandersmith2008@gmail.com>2023-06-03 23:10:03 +0100
committerisXander <xandersmith2008@gmail.com>2023-06-04 16:25:09 +0100
commit3e36feeef60e56ef8cb7f737ac8eeab9fbcd6abb (patch)
treef9c3395b4da2235681b87a35ac5056a0724a181b /common/src/main/java/dev/isxander/yacl/config/ConfigInstance.java
parentd00a486d3bdf6105f8ca8af1034c384058b8c832 (diff)
downloadYetAnotherConfigLib-3e36feeef60e56ef8cb7f737ac8eeab9fbcd6abb.tar.gz
YetAnotherConfigLib-3e36feeef60e56ef8cb7f737ac8eeab9fbcd6abb.tar.bz2
YetAnotherConfigLib-3e36feeef60e56ef8cb7f737ac8eeab9fbcd6abb.zip
Change package and modid to yacl3 and yet_another_config_lib_3 respectively
Diffstat (limited to 'common/src/main/java/dev/isxander/yacl/config/ConfigInstance.java')
-rw-r--r--common/src/main/java/dev/isxander/yacl/config/ConfigInstance.java48
1 files changed, 0 insertions, 48 deletions
diff --git a/common/src/main/java/dev/isxander/yacl/config/ConfigInstance.java b/common/src/main/java/dev/isxander/yacl/config/ConfigInstance.java
deleted file mode 100644
index c207161..0000000
--- a/common/src/main/java/dev/isxander/yacl/config/ConfigInstance.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package dev.isxander.yacl.config;
-
-import java.lang.reflect.InvocationTargetException;
-
-/**
- * Responsible for handing the actual config data type.
- * Holds the instance along with a final default instance
- * to reference default values for options and should not be changed.
- *
- * Abstract methods to save and load the class, implementations are responsible for
- * how it saves and load.
- *
- * @param <T> config data type
- */
-public abstract class ConfigInstance<T> {
- private final Class<T> configClass;
- private final T defaultInstance;
- private T instance;
-
- public ConfigInstance(Class<T> configClass) {
- this.configClass = configClass;
-
- try {
- this.defaultInstance = this.instance = configClass.getConstructor().newInstance();
- } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
- throw new IllegalStateException(String.format("Could not create default instance of config for %s. Make sure there is a default constructor!", this.configClass.getSimpleName()));
- }
- }
-
- public abstract void save();
- public abstract void load();
-
- public T getConfig() {
- return this.instance;
- }
-
- protected void setConfig(T instance) {
- this.instance = instance;
- }
-
- public T getDefaults() {
- return this.defaultInstance;
- }
-
- public Class<T> getConfigClass() {
- return this.configClass;
- }
-}