47 lines
959 B
Java
47 lines
959 B
Java
package de.hsel.itech.config;
|
|
|
|
import com.google.gson.Gson;
|
|
import lombok.EqualsAndHashCode;
|
|
import lombok.Getter;
|
|
import lombok.ToString;
|
|
|
|
import java.io.File;
|
|
import java.io.FileNotFoundException;
|
|
import java.io.FileReader;
|
|
|
|
/**
|
|
* config object.
|
|
*
|
|
* @author Johannes Theiner
|
|
* @version 0.1
|
|
* @since 0.1
|
|
*/
|
|
|
|
@ToString
|
|
@EqualsAndHashCode
|
|
public class Configuration {
|
|
|
|
private static final String filename = "config.json";
|
|
|
|
@Getter
|
|
private Database database;
|
|
|
|
|
|
/**
|
|
* gets Configuration object from file.
|
|
* @return {@link de.hsel.itech.config.Configuration}
|
|
*/
|
|
public static Configuration get() {
|
|
Gson gson = new Gson();
|
|
|
|
FileReader reader = null;
|
|
try {
|
|
reader = new FileReader(new File(filename));
|
|
} catch (FileNotFoundException e) {
|
|
e.printStackTrace();
|
|
}
|
|
assert reader != null;
|
|
return gson.fromJson(reader, Configuration.class);
|
|
}
|
|
|
|
} |