sorted methods alphabetically
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -17,6 +17,45 @@ public class Configuration {
|
||||
private JSONObject data;
|
||||
private File file;
|
||||
|
||||
public File archiveDir() {
|
||||
var locations = locations();
|
||||
if (!locations.containsKey(ARCHIVE)) locations.put(ARCHIVE, String.join(File.separator,baseDir(),"archive"));
|
||||
return new File((String) locations.get(ARCHIVE));
|
||||
}
|
||||
|
||||
public String baseDir() {
|
||||
var locations = locations();
|
||||
if (!locations.containsKey(BASE)) locations.put(BASE,System.getProperty("user.dir"));
|
||||
return (String) locations.get(BASE);
|
||||
}
|
||||
|
||||
public String baseUrl() {
|
||||
if (!data.containsKey(BASE_URL)) data.put(BASE_URL,"http://localhost");
|
||||
return (String) data.get(BASE_URL);
|
||||
}
|
||||
|
||||
public File configFile() {
|
||||
var locations = locations();
|
||||
if (!locations.containsKey(CONFIG)) locations.put(CONFIG, String.join(File.separator,baseDir(),"config","config.json"));
|
||||
return new File((String) locations.get(CONFIG));
|
||||
}
|
||||
|
||||
public File dbFile() {
|
||||
var locations = locations();
|
||||
if (!locations.containsKey(DB)) locations.put(DB, String.join(File.separator,baseDir(),"db","db.sqlite3"));
|
||||
return new File((String) locations.get(DB));
|
||||
}
|
||||
|
||||
public Configuration dbFile(File dbFile){
|
||||
var locations = locations();
|
||||
locations.put(DB,dbFile.toString());
|
||||
return this;
|
||||
}
|
||||
|
||||
public File file() {
|
||||
return file;
|
||||
}
|
||||
|
||||
public static Configuration instance() {
|
||||
if (singleton == null) singleton = new Configuration().setDefaults();
|
||||
return singleton;
|
||||
@@ -42,6 +81,12 @@ public class Configuration {
|
||||
return this;
|
||||
}
|
||||
|
||||
private JSONObject locations() {
|
||||
Object o = data.get(LOCATIONS);
|
||||
if (!(o instanceof JSONObject)) data.put(LOCATIONS,o = new JSONObject());
|
||||
return (JSONObject) o;
|
||||
}
|
||||
|
||||
public Configuration save(File file) throws IOException {
|
||||
this.file = file;
|
||||
return save();
|
||||
@@ -64,57 +109,9 @@ public class Configuration {
|
||||
return this;
|
||||
}
|
||||
|
||||
private JSONObject locations() {
|
||||
Object o = data.get(LOCATIONS);
|
||||
if (!(o instanceof JSONObject)) data.put(LOCATIONS,o = new JSONObject());
|
||||
return (JSONObject) o;
|
||||
}
|
||||
|
||||
public String baseDir() {
|
||||
var locations = locations();
|
||||
if (!locations.containsKey(BASE)) locations.put(BASE,System.getProperty("user.dir"));
|
||||
return (String) locations.get(BASE);
|
||||
}
|
||||
|
||||
public File configFile() {
|
||||
var locations = locations();
|
||||
if (!locations.containsKey(CONFIG)) locations.put(CONFIG, String.join(File.separator,baseDir(),"config","config.json"));
|
||||
return new File((String) locations.get(CONFIG));
|
||||
}
|
||||
|
||||
public File dbFile() {
|
||||
var locations = locations();
|
||||
if (!locations.containsKey(DB)) locations.put(DB, String.join(File.separator,baseDir(),"db","db.sqlite3"));
|
||||
return new File((String) locations.get(DB));
|
||||
}
|
||||
|
||||
public Configuration dbFile(File dbFile){
|
||||
var locations = locations();
|
||||
locations.put(DB,dbFile.toString());
|
||||
return this;
|
||||
}
|
||||
|
||||
public File archiveDir() {
|
||||
var locations = locations();
|
||||
if (!locations.containsKey(ARCHIVE)) locations.put(ARCHIVE, String.join(File.separator,baseDir(),"archive"));
|
||||
return new File((String) locations.get(ARCHIVE));
|
||||
}
|
||||
|
||||
|
||||
public int serverPort() {
|
||||
if (!data.containsKey(PORT)) data.put(PORT,80L);
|
||||
var o = data.get(PORT);
|
||||
return (int) (long) o;
|
||||
}
|
||||
|
||||
public String baseUrl() {
|
||||
if (!data.containsKey(BASE_URL)) data.put(BASE_URL,"http://localhost");
|
||||
return (String) data.get(BASE_URL);
|
||||
}
|
||||
|
||||
|
||||
public File file() {
|
||||
return file;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user