Update ConfigEntry
This commit is contained in:
@@ -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> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user