-
-
Notifications
You must be signed in to change notification settings - Fork 1
Home
Storm is a library for user-oriented configuration. Using Storm, developers can easily create type-safe systems for working with text-based configurations, especially for non-technical users.
- Discord: Development discussion & support
For more introductory information, see the project README.
The current recommended way to depend on Storm is using JitPack, which can be done with Gradle as follows:
repositories {
maven {
url "https://jitpack.io"
}
}
dependencies {
implementation "com.github.flash-labs:FlashLibs:v0.1.0"
}
-SNAPSHOTcan be instead instead of a version for the latest changes.
As of v0.1.0, Storm does not do any work with files. Instead, you will have to read the contents of the file into a String first.
String input = new String(Files.readAllBytes(path));
try {
Node node = Storm.deserialize(input);
} catch (ParseException e) {
System.out.println(e.getDiagnostic());
}Likewise, when reserializing the returned value is a String which can then be used as needed.
String output = Storm.reserialize(node);
Files.write(path, output.getBytes());The Node class is a navigable node hierarchy. The class is fully documented, so for brevity we're going to focus on two key points until a full wiki can be created.
- Many methods are state dependent, so pay attention to the preconditions enforced when using a method.
- Nodes are either defined with a value or undefined. It is possible to navigate to an undefined node, but it is not allowed to set a value to one - instead the
attach()method must be used (likewise,detach()for converting a node to undefined).
Storm provides a variety of serializers for getting data from a node. As above, there are a few key points to mention with serializers.
- Serializers are strict and will not perform any type of conversion, even ones like integers to decimals (for that, use a
UNION). - Deserialization is, in general, a lossy conversion - information about the representation of values can be lost, and therefore reserialization may not produce an identical value (though it will naturally be equivalent). Some serializers, like
UNION, do not currently support reserialization as consequence. -
NULLABLEandOPTIONALare both tricky, since they cannot be used at the same time as anOptionalofnullis not allowed (Optional.ofNullable(null)producesOptional.empty(), which is also used for undefined values). As such, it is recommend to avoid designing configuration where a value can be both (in general, optional should be preferred over nullable).