Class Transformations
- java.lang.Object
-
- org.spongepowered.configurate.examples.Transformations
-
public final class Transformations extends Object
An example of how to use transformations to migrate a configuration to a newer schema version.It's like DFU but not hot garbage! (and probably less PhD-worthy)
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ConfigurationTransformation.Versioned
create()
Create a new builder for versioned configurations.static ConfigurationTransformation
initialTransform()
A transformation.static void
main(String[] args)
static ConfigurationTransformation
oneToTwo()
static <N extends ConfigurationNode>
NupdateNode(N node)
Apply the transformations to a node.static ConfigurationTransformation
zeroToOne()
-
-
-
Method Detail
-
create
public static ConfigurationTransformation.Versioned create()
Create a new builder for versioned configurations. This builder uses a field in the node (by defaultschema-version
) to determine the current schema version (using -1 for no version present).- Returns:
- versioned transformation
-
initialTransform
public static ConfigurationTransformation initialTransform()
A transformation. This one has multiple actions, and demonstrates how wildcards work.- Returns:
- created transformation
-
zeroToOne
public static ConfigurationTransformation zeroToOne()
-
oneToTwo
public static ConfigurationTransformation oneToTwo()
-
updateNode
public static <N extends ConfigurationNode> N updateNode(N node) throws ConfigurateException
Apply the transformations to a node.This method also prints information about the version update that occurred
- Type Parameters:
N
- node type- Parameters:
node
- the node to transform- Returns:
- provided node, after transformation
- Throws:
ConfigurateException
-
main
public static void main(String[] args) throws ConfigurateException
- Throws:
ConfigurateException
-
-