From 67a171da5689fab27981da97069b2f7466f82f63 Mon Sep 17 00:00:00 2001 From: coolGi2007 Date: Sun, 6 Feb 2022 05:00:25 +0000 Subject: [PATCH] Update ConfigEntry --- .../seibel/lod/core/config/ConfigEntry.java | 59 ++++++++++++++++--- 1 file changed, 51 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/seibel/lod/core/config/ConfigEntry.java b/src/main/java/com/seibel/lod/core/config/ConfigEntry.java index c31a4172a..db530a047 100644 --- a/src/main/java/com/seibel/lod/core/config/ConfigEntry.java +++ b/src/main/java/com/seibel/lod/core/config/ConfigEntry.java @@ -4,19 +4,31 @@ package com.seibel.lod.core.config; * Use for making the config variables * * @author coolGi2007 - * @version 02-03-2022 + * @version 02-06-2022 */ public class ConfigEntry { - public Object value; - public String comment; - // Should the min and max be long or int or double or something else - public double min = Double.MIN_VALUE; - public double max = Double.MAX_VALUE; + private Object value; + private String comment; + private Class type; + private double min = Double.MIN_VALUE; + private double max = Double.MAX_VALUE; + /** Defult entry */ + public ConfigEntry() { + } + + /** Sets everything */ + public ConfigEntry(Object value, Class type, String comment, double min, double max) { + this.value = value; + this.type = type; + this.comment = comment; + this.min = min; + this.max = max; + } /** Gets the value */ - public Object get() { - return this.value; + public type get() { + return (type) this.value; } /** Sets the value */ public void set(Object new_value) { @@ -56,4 +68,35 @@ public class ConfigEntry { return true; return false; } + + // Use this so it dosnt do file handling stuff + public static class Builder { + private Object tmpValue; + private String tmpComment; + private Class tmpType; + private double tmpMin = Double.MIN_VALUE; + private double tmpMax = Double.MAX_VALUE; + + public Builder set(Object newValue) { + this.tmpValue = newValue; + this.tmpType = newValue.getClass(); + return this; + } + + public Builder comment(String newComment) { + this.tmpComment = newComment; + return this; + } + + public Builder setMinMax(double newMin, double newMax) { + this.tmpMin = newMin; + this.tmpMax = newMax; + return this; + } + + + public ConfigEntry build() { + return new ConfigEntry(tmpValue, tmpType, tmpComment, tmpMin, tmpMax); + } + } }