Class ConfigDeserializer
- java.lang.Object
-
- at.matteovalentini.configdeserializer.ConfigDeserializer
-
public class ConfigDeserializer extends Object
Class used to deserialize a config file into a config class using reflection. The config class must have a default constructor and config fields should be annotated with @ConfigValue.
-
-
Constructor Summary
Constructors Constructor Description ConfigDeserializer()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Tdeserialize(Path configFile, Class<T> configClass)Deserializes a config file into a config class.
-
-
-
Method Detail
-
deserialize
public static <T> T deserialize(Path configFile, Class<T> configClass) throws ConfigException.InvalidClassException, ConfigException.InvalidPathException, ConfigException.InvalidValueException, ConfigException.MissingValueException
Deserializes a config file into a config class. If the config file doesn't exist, it will be created and populated with the default values- Type Parameters:
T- Type of the config class- Parameters:
configFile- Path to the config fileconfigClass- Class of the config- Returns:
- The config class
- Throws:
ConfigException.InvalidPathException- If the path is invalidConfigException.InvalidClassException- If the config class is invalidConfigException.MissingValueException- If a required value is missingConfigException.InvalidValueException- If a value is invalid
-
-