-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit adds the new interface IOStreamConfigurationStore that provides two new methods, one for reading configurations from InputStreams and a second for writing configurations to OutputStreams. This interfaces is implemented by the YamlConfigurationStore class.
- Loading branch information
Showing
11 changed files
with
1,525 additions
and
996 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
configlib-core/src/main/java/de/exlll/configlib/IOStreamConfigurationStore.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package de.exlll.configlib; | ||
|
||
import java.io.InputStream; | ||
import java.io.OutputStream; | ||
|
||
/** | ||
* Instances of this class read and write configurations from input streams and to output streams, | ||
* respectively. | ||
* <p> | ||
* The details of how configurations are serialized and deserialized are defined by the | ||
* implementations of this interface. | ||
* | ||
* @param <T> the configuration type | ||
*/ | ||
public interface IOStreamConfigurationStore<T> { | ||
/** | ||
* Writes a configuration instance to the given output stream. | ||
* | ||
* @param configuration the configuration | ||
* @param outputStream the output stream the configuration is written to | ||
* @throws ConfigurationException if the configuration contains invalid values or | ||
* cannot be serialized | ||
* @throws NullPointerException if any argument is null | ||
* @throws RuntimeException if writing the configuration throws an exception | ||
*/ | ||
void write(T configuration, OutputStream outputStream); | ||
|
||
/** | ||
* Reads a configuration from the given input stream. | ||
* | ||
* @param inputStream the input stream the configuration is read from | ||
* @return a newly created configuration initialized with values read from {@code inputStream} | ||
* @throws ConfigurationException if the configuration cannot be deserialized | ||
* @throws NullPointerException if {@code inputStream} is null | ||
* @throws RuntimeException if reading the input stream throws an exception | ||
*/ | ||
T read(InputStream inputStream); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.