Package io.github.frc5024.lib5k.config
Class SingleInstanceJSONConfig<T>
- java.lang.Object
-
- io.github.frc5024.lib5k.config.SingleInstanceJSONConfig<T>
-
- Type Parameters:
T
- Type of object to load
public class SingleInstanceJSONConfig<T> extends java.lang.Object
SingleInstanceJSONConfig is a tool for loading a JSON file into a Java object
-
-
Constructor Summary
Constructors Constructor Description SingleInstanceJSONConfig(java.lang.Class<T> clazz)
Create a SingleInstanceJSONConfig with default settingsSingleInstanceJSONConfig(java.lang.Class<T> clazz, boolean saveToSession)
Create a SingleInstanceJSONConfigSingleInstanceJSONConfig(java.lang.Class<T> clazz, java.lang.String filename, boolean saveToSession)
Create a SingleInstanceJSONConfig
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.io.File
getBackupFilePath()
Builds a file path for the config inside session folderT
getConfig()
Get an instance of the loaded config, or load the configboolean
hasLoadedConfig()
Get if the config has been loaded yet
-
-
-
Constructor Detail
-
SingleInstanceJSONConfig
public SingleInstanceJSONConfig(java.lang.Class<T> clazz)
Create a SingleInstanceJSONConfig with default settings- Parameters:
clazz
- Class of the config
-
SingleInstanceJSONConfig
public SingleInstanceJSONConfig(java.lang.Class<T> clazz, boolean saveToSession)
Create a SingleInstanceJSONConfig- Parameters:
clazz
- Class of the configsaveToSession
- Should save a copy of the config for debugging?
-
SingleInstanceJSONConfig
public SingleInstanceJSONConfig(java.lang.Class<T> clazz, java.lang.String filename, boolean saveToSession)
Create a SingleInstanceJSONConfig- Parameters:
clazz
- Class of the configfilename
- Config JSON filenamesaveToSession
- Should save a copy of the config for debugging?
-
-
Method Detail
-
getBackupFilePath
protected java.io.File getBackupFilePath()
Builds a file path for the config inside session folder- Returns:
- Path to config file backup location
-
getConfig
public T getConfig() throws java.io.IOException
Get an instance of the loaded config, or load the config- Returns:
- Config object
- Throws:
java.io.IOException
- Thrown if there is a read issue
-
hasLoadedConfig
public boolean hasLoadedConfig()
Get if the config has been loaded yet- Returns:
- Has been loaded?
-
-