summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/openslx/virtualization/configuration/transformation/TransformationFunction.java
diff options
context:
space:
mode:
authorManuel Bentele2021-04-15 14:01:47 +0200
committerManuel Bentele2021-04-15 14:01:47 +0200
commit90d94a479e5af0d884c63643f1266dc0a6596318 (patch)
treea84ee0f2c9bf1bce9abc43cfacdb87cd52592fcf /src/main/java/org/openslx/virtualization/configuration/transformation/TransformationFunction.java
parentAdd representation of used virtualization systems (diff)
downloadmaster-sync-shared-90d94a479e5af0d884c63643f1266dc0a6596318.tar.gz
master-sync-shared-90d94a479e5af0d884c63643f1266dc0a6596318.tar.xz
master-sync-shared-90d94a479e5af0d884c63643f1266dc0a6596318.zip
Add generic transformation library to transform configs
Diffstat (limited to 'src/main/java/org/openslx/virtualization/configuration/transformation/TransformationFunction.java')
-rw-r--r--src/main/java/org/openslx/virtualization/configuration/transformation/TransformationFunction.java39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/main/java/org/openslx/virtualization/configuration/transformation/TransformationFunction.java b/src/main/java/org/openslx/virtualization/configuration/transformation/TransformationFunction.java
new file mode 100644
index 0000000..b5be7a0
--- /dev/null
+++ b/src/main/java/org/openslx/virtualization/configuration/transformation/TransformationFunction.java
@@ -0,0 +1,39 @@
+package org.openslx.virtualization.configuration.transformation;
+
+/**
+ * Represents a transformation operation that transforms (alters) a given configuration with
+ * specified input arguments and returns no result.
+ *
+ * @author Manuel Bentele
+ * @version 1.0
+ *
+ * @param <T> type of the configuration which will be transformed.
+ * @param <R> type of input arguments for the transformation.
+ */
+@FunctionalInterface
+public interface TransformationFunction<T, R>
+{
+ /**
+ * Transforms a given configuration with the specified input arguments.
+ *
+ * @param config configuration which will be transformed.
+ * @param args input arguments for the transformation.
+ *
+ * @throws TransformationException transformation of the configuration failed.
+ */
+ public void transform( T config, R args ) throws TransformationException;
+
+ /**
+ * Applies the transformation function {@link #transform(Object, Object)} to the given
+ * configuration and specified input arguments.
+ *
+ * @param config configuration which will be transformed.
+ * @param args input arguments for the transformation.
+ *
+ * @throws TransformationException transformation of the configuration failed.
+ */
+ public default void apply( T config, R args ) throws TransformationException
+ {
+ this.transform( config, args );
+ }
+}