53 lines
1.4 KiB
Java
53 lines
1.4 KiB
Java
|
package be.jaud;
|
||
|
|
||
|
import java.io.File;
|
||
|
import java.nio.file.Paths;
|
||
|
import java.util.Iterator;
|
||
|
import java.util.List;
|
||
|
import java.util.Map.Entry;
|
||
|
|
||
|
import com.typesafe.config.Config;
|
||
|
import com.typesafe.config.ConfigException;
|
||
|
import com.typesafe.config.ConfigFactory;
|
||
|
import com.typesafe.config.ConfigValue;
|
||
|
|
||
|
public class Settings {
|
||
|
private static Settings instance = null;
|
||
|
private final Config config;
|
||
|
public static Settings getInstance() {
|
||
|
if (instance == null) {
|
||
|
instance = new Settings();
|
||
|
}
|
||
|
return instance;
|
||
|
}
|
||
|
|
||
|
private Settings(){
|
||
|
config = ConfigFactory.load(ConfigFactory.parseFile(new File(Paths.get("").toAbsolutePath() +"/config/apiserver.conf"))).getConfig("apiserver");
|
||
|
try {
|
||
|
config.checkValid(ConfigFactory.defaultReference().getConfig("apiserver"));
|
||
|
} catch (ConfigException.ValidationFailed ex) {
|
||
|
System.out.println("Error loading Config! "+ ex);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public Iterator<Entry<String, ConfigValue>> getall(){
|
||
|
return config.entrySet().iterator();
|
||
|
}
|
||
|
|
||
|
public String getString(String key){
|
||
|
return config.getString(key);
|
||
|
}
|
||
|
|
||
|
public Boolean getBoolean(String key){
|
||
|
return config.getBoolean(key);
|
||
|
}
|
||
|
|
||
|
public int getInt(String key){
|
||
|
return config.getInt(key);
|
||
|
}
|
||
|
|
||
|
public List<String> getStringList(String key){
|
||
|
return config.getStringList(key);
|
||
|
}
|
||
|
}
|