Module net.morimekta.tiny.server
Package net.morimekta.tiny.server.config
Class ConfigReader<ConfigType>
- java.lang.Object
-
- net.morimekta.tiny.server.config.ConfigReader<ConfigType>
-
- Type Parameters:
ConfigType- The config type.
- Direct Known Subclasses:
ConfigReader.YamlConfigReader
public abstract class ConfigReader<ConfigType> extends Object
A helper class to load config files from disk and parse into the specified config type.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classConfigReader.YamlConfigReader<ConfigType>Read config as YAML.
-
Constructor Summary
Constructors Modifier Constructor Description protectedConfigReader()Protected constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract ConfigTypeparseConfig(String fileName, InputStream stream)Parse config file into the designated type.ConfigTypereadConfig(Path file)
-
-
-
Method Detail
-
readConfig
public ConfigType readConfig(Path file) throws IOException
- Parameters:
file- File path to load config from.- Returns:
- The loaded config file.
- Throws:
IOException- If reading the config file failed.
-
parseConfig
protected abstract ConfigType parseConfig(String fileName, InputStream stream) throws IOException
Parse config file into the designated type.- Parameters:
fileName- File name that is parsed. In case this has influence on the parsing.stream- The file input stream to read from.- Returns:
- The parsed config file.
- Throws:
IOException- If parsing failed.
-
-