delegator) {
+ super(delegator);
+ }
+ }
+
+}
diff --git a/vtl-engine/src/main/java/fr/insee/vtl/engine/utils/safetymirror/Fun.java b/vtl-engine/src/main/java/fr/insee/vtl/engine/utils/safetymirror/Fun.java
new file mode 100644
index 000000000..43b4040fa
--- /dev/null
+++ b/vtl-engine/src/main/java/fr/insee/vtl/engine/utils/safetymirror/Fun.java
@@ -0,0 +1,883 @@
+package fr.insee.vtl.engine.utils.safetymirror;
+
+import com.github.hervian.reflection.util.SerializedLambdaToMethod;
+import lombok.NonNull;
+import lombok.SneakyThrows;
+import org.jetbrains.annotations.NotNull;
+
+import java.io.Serializable;
+import java.lang.reflect.Method;
+
+/**
+ *
+ * Copyright 2016 Anders Granau Høfft
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * END OF NOTICE
+ *
+ *
+ * Fun, short for Function, is a super interface that from a user perspective is used as part of a fluent API
+ * in signatures that accepts Method References.
+ * I.e. one writes 'Fun.' and then choose the appropriate nested class such as 'Fun.With2Params'.
+ * (In most IDEs you can simply type Fun.W2 to get the autocomplete to suggest 'Fun.With2Params'.)
+ *
+ * Notice that you must supply the signatures return value and parameters in the generics,
+ * fx: 'Fun.With2Params<Double, Integer, String> for methods that
+ * given an Integer and a String (in that order) returns a Double.
+ *
+ * Note that since capital 'Void' is NOT a boxed lower case 'void' we need to give method references
+ * with return type void special attention. In other words, current Java versions won't accept generics with
+ * primitives, including void, but for all primitives except void, this is ok since fx 'Fun.With2Params<Double>
+ * will match primitive signatures due to autoboxing. But for void as return type we must use a special subclass and
+ * write code like fx: 'Fun.With2ParamsAndVoid<Double>
+ * Note also, that this may (or may not) change once Project Valhalla is completed and specialized Generics
+ * become part of the Java Language Specification. See https://en.wikipedia.org/wiki/Project_Valhalla_(Java_language).
+ *
+ * Besides the fluent API described above (i.e. the subinterfaces that allow you to pass around functions and
+ * use them as types), the Fun interface contains a large number of overloaded methods.
+ * The overloading is actually an implementation detail.
+ * From a user perspective you should consider the Fun type to have the following API:
+ *
+ * java.lang.Method method = Fun.toMethod(SomeClassOrObject::someMethod);
+ *
+ * Please be aware that there are 2 situations where you must help the compiler choose the correct overloaded method.
+ *
+ * 1.
+ * When targeting an overloaded method you must help the compiler choose the correct overloaded toMethod method
+ * by specifying the parameters and return value in generics. This is fx the case with this call:
+ * Fun.<String>toMethod(Class::forName)
+ *
+ * 2.
+ * When targeting a method with varargs you must cast the Method Reference to help the compiler choose
+ * the correct overloaded toMethod method, Fx:
+ * Method m = Fun.toMethod((Fun.With1ParamAndVoid<String[]>)new FunToMethodTest()::methodThatTakesAVarargParam);
+ *
+ *
+ * @author Anders Granau Høfft
+ */
+public interface Fun extends Serializable {
+
+ default Method toMethod(){
+ return SerializedLambdaToMethod.createMethodFromSuperConsumer(this);
+ }
+
+ /**
+ *
+ * Usage:
+ * java.lang.Method method = Fun.toMethod(SomeClassOrObject::someMethod);
+ *
+ * Don't worry too much about the large number of overloaded toMethod methods. The overloading is an implementation
+ * detail. That being said, pay attention to below corner cases.
+ *
+ * Please be aware that there are 2 situations where you must help the compiler choose the correct overloaded method.
+ *
+ * 1.
+ * When targeting an overloaded method you must help the compiler choose the correct overloaded toMethod method
+ * by specifying the parameters and return value in generics. This is fx the case with this call:
+ * Fun.<String>toMethod(Class::forName)
+ *
+ * 2.
+ * When targeting a method with varargs you must cast the Method Reference to help the compiler choose
+ * the correct overloaded toMethod method, Fx:
+ * Method m = Fun.toMethod((Fun.With1ParamAndVoid<String[]>)new FunToMethodTest()::methodThatTakesAVarargParam);
+ *
+ *
+ * @see Fun
+ *
+ * @param methodRef a Method Reference, fx in the form of the double colon syntax like this 'MyClass::myAccessibleMethod', or 'myObject::myAccessibleMethod'.
+ * @param a dummy generic to help the compiler choose the correct overloaded toMethod method.
+ * @return a {@link Method} instance that corresponds to the method reference. Please note, though, that the Method instance will *NOT* return the correct method name. Use Fun.getName for this purpose.
+ */
+ static Method toMethod(Fun.With0ParamsAndVoid methodRef) { return SerializedLambdaToMethod.createMethodFromSuperConsumer(methodRef); }
+
+ /**
+ * @see Fun#toMethod(With0ParamsAndVoid)
+ *
+ * @param methodRef a Method Reference, fx in the form of the double colon syntax like this 'MyClass::myAccessibleMethod', or 'myObject::myAccessibleMethod'.
+ * @param When targeting an overloaded method you must help the compiler choose the correct overloaded toMethod method by specifying the parameters and return value in generics.
+ * @return a {@link Method} instance that corresponds to the method reference. Please note, though, that the Method instance will *NOT* return the correct method name. Use Fun.getName for this purpose.
+ */
+ static Method toMethod(Fun.With1ParamAndVoid methodRef) { return SerializedLambdaToMethod.createMethodFromSuperConsumer(methodRef); }
+ /**
+ * @see Fun#toMethod(With0ParamsAndVoid)
+ *
+ * @param methodRef a Method Reference, fx in the form of the double colon syntax like this 'MyClass::myAccessibleMethod', or 'myObject::myAccessibleMethod'.
+ * @param When targeting an overloaded method you must help the compiler choose the correct overloaded toMethod method by specifying the parameters and return value in generics.
+ * @param When targeting an overloaded method you must help the compiler choose the correct overloaded toMethod method by specifying the parameters and return value in generics.
+ * @return a {@link Method} instance that corresponds to the method reference. Please note, though, that the Method instance will *NOT* return the correct method name. Use Fun.getName for this purpose.
+ */
+ static Method toMethod(Fun.With2ParamsAndVoid methodRef) { return SerializedLambdaToMethod.createMethodFromSuperConsumer(methodRef); }
+ /**
+ * @see Fun#toMethod(With0ParamsAndVoid)
+ *
+ * @param methodRef a Method Reference, fx in the form of the double colon syntax like this 'MyClass::myAccessibleMethod', or 'myObject::myAccessibleMethod'.
+ * @param When targeting an overloaded method you must help the compiler choose the correct overloaded toMethod method by specifying the parameters and return value in generics.
+ * @param When targeting an overloaded method you must help the compiler choose the correct overloaded toMethod method by specifying the parameters and return value in generics.
+ * @param When targeting an overloaded method you must help the compiler choose the correct overloaded toMethod method by specifying the parameters and return value in generics.
+ * @return a {@link Method} instance that corresponds to the method reference. Please note, though, that the Method instance will *NOT* return the correct method name. Use Fun.getName for this purpose.
+ */
+ static Method toMethod(Fun.With3ParamsAndVoid methodRef) { return SerializedLambdaToMethod.createMethodFromSuperConsumer(methodRef); }
+ /**
+ * @see Fun#toMethod(With0ParamsAndVoid)
+ *
+ * @param methodRef a Method Reference, fx in the form of the double colon syntax like this 'MyClass::myAccessibleMethod', or 'myObject::myAccessibleMethod'.
+ * @param When targeting an overloaded method you must help the compiler choose the correct overloaded toMethod method by specifying the parameters and return value in generics.
+ * @param When targeting an overloaded method you must help the compiler choose the correct overloaded toMethod method by specifying the parameters and return value in generics.
+ * @param When targeting an overloaded method you must help the compiler choose the correct overloaded toMethod method by specifying the parameters and return value in generics.
+ * @param When targeting an overloaded method you must help the compiler choose the correct overloaded toMethod method by specifying the parameters and return value in generics.
+ * @return a {@link Method} instance that corresponds to the method reference. Please note, though, that the Method instance will *NOT* return the correct method name. Use Fun.getName for this purpose.
+ */
+ static Method toMethod(Fun.With4ParamsAndVoid methodRef) { return SerializedLambdaToMethod.createMethodFromSuperConsumer(methodRef); }
+ /**
+ * @see Fun#toMethod(With0ParamsAndVoid)
+ *
+ * @param methodRef a Method Reference, fx in the form of the double colon syntax like this 'MyClass::myAccessibleMethod', or 'myObject::myAccessibleMethod'.
+ * @param When targeting an overloaded method you must help the compiler choose the correct overloaded toMethod method by specifying the parameters and return value in generics.
+ * @param When targeting an overloaded method you must help the compiler choose the correct overloaded toMethod method by specifying the parameters and return value in generics.
+ * @param When targeting an overloaded method you must help the compiler choose the correct overloaded toMethod method by specifying the parameters and return value in generics.
+ * @param When targeting an overloaded method you must help the compiler choose the correct overloaded toMethod method by specifying the parameters and return value in generics.
+ * @param When targeting an overloaded method you must help the compiler choose the correct overloaded toMethod method by specifying the parameters and return value in generics.
+ * @return a {@link Method} instance that corresponds to the method reference. Please note, though, that the Method instance will *NOT* return the correct method name. Use Fun.getName for this purpose.
+ */
+ static Method toMethod(Fun.With5ParamsAndVoid methodRef) { return SerializedLambdaToMethod.createMethodFromSuperConsumer(methodRef); }
+ /**
+ * @see Fun#toMethod(With0ParamsAndVoid)
+ *
+ * @param methodRef a Method Reference, fx in the form of the double colon syntax like this 'MyClass::myAccessibleMethod', or 'myObject::myAccessibleMethod'.
+ * @param When targeting an overloaded method you must help the compiler choose the correct overloaded toMethod method by specifying the parameters and return value in generics.
+ * @param When targeting an overloaded method you must help the compiler choose the correct overloaded toMethod method by specifying the parameters and return value in generics.
+ * @param When targeting an overloaded method you must help the compiler choose the correct overloaded toMethod method by specifying the parameters and return value in generics.
+ * @param When targeting an overloaded method you must help the compiler choose the correct overloaded toMethod method by specifying the parameters and return value in generics.
+ * @param When targeting an overloaded method you must help the compiler choose the correct overloaded toMethod method by specifying the parameters and return value in generics.
+ * @param When targeting an overloaded method you must help the compiler choose the correct overloaded toMethod method by specifying the parameters and return value in generics.
+ * @return a {@link Method} instance that corresponds to the method reference. Please note, though, that the Method instance will *NOT* return the correct method name. Use Fun.getName for this purpose.
+ */
+ static Method toMethod(Fun.With6ParamsAndVoid methodRef) { return SerializedLambdaToMethod.createMethodFromSuperConsumer(methodRef); }
+ /**
+ * @see Fun#toMethod(With0ParamsAndVoid)
+ *
+ * @param methodRef a Method Reference, fx in the form of the double colon syntax like this 'MyClass::myAccessibleMethod', or 'myObject::myAccessibleMethod'.
+ * @param When targeting an overloaded method you must help the compiler choose the correct overloaded toMethod method by specifying the parameters and return value in generics.
+ * @param When targeting an overloaded method you must help the compiler choose the correct overloaded toMethod method by specifying the parameters and return value in generics.
+ * @param When targeting an overloaded method you must help the compiler choose the correct overloaded toMethod method by specifying the parameters and return value in generics.
+ * @param When targeting an overloaded method you must help the compiler choose the correct overloaded toMethod method by specifying the parameters and return value in generics.
+ * @param When targeting an overloaded method you must help the compiler choose the correct overloaded toMethod method by specifying the parameters and return value in generics.
+ * @param When targeting an overloaded method you must help the compiler choose the correct overloaded toMethod method by specifying the parameters and return value in generics.
+ * @param When targeting an overloaded method you must help the compiler choose the correct overloaded toMethod method by specifying the parameters and return value in generics.
+ * @return a {@link Method} instance that corresponds to the method reference. Please note, though, that the Method instance will *NOT* return the correct method name. Use Fun.getName for this purpose.
+ */
+ static Method toMethod(Fun.With7ParamsAndVoid methodRef) { return SerializedLambdaToMethod.createMethodFromSuperConsumer(methodRef); }
+ /**
+ * @see Fun#toMethod(With0ParamsAndVoid)
+ *
+ * @param methodRef a Method Reference, fx in the form of the double colon syntax like this 'MyClass::myAccessibleMethod', or 'myObject::myAccessibleMethod'.
+ * @param When targeting an overloaded method you must help the compiler choose the correct overloaded toMethod method by specifying the parameters and return value in generics.
+ * @param When targeting an overloaded method you must help the compiler choose the correct overloaded toMethod method by specifying the parameters and return value in generics.
+ * @param When targeting an overloaded method you must help the compiler choose the correct overloaded toMethod method by specifying the parameters and return value in generics.
+ * @param When targeting an overloaded method you must help the compiler choose the correct overloaded toMethod method by specifying the parameters and return value in generics.
+ * @param When targeting an overloaded method you must help the compiler choose the correct overloaded toMethod method by specifying the parameters and return value in generics.
+ * @param When targeting an overloaded method you must help the compiler choose the correct overloaded toMethod method by specifying the parameters and return value in generics.
+ * @param When targeting an overloaded method you must help the compiler choose the correct overloaded toMethod method by specifying the parameters and return value in generics.
+ * @param When targeting an overloaded method you must help the compiler choose the correct overloaded toMethod method by specifying the parameters and return value in generics.
+ * @return a {@link Method} instance that corresponds to the method reference. Please note, though, that the Method instance will *NOT* return the correct method name. Use Fun.getName for this purpose.
+ */
+ static Method toMethod(Fun.With8ParamsAndVoid methodRef) { return SerializedLambdaToMethod.createMethodFromSuperConsumer(methodRef); }
+ /**
+ * @see Fun#toMethod(With0ParamsAndVoid)
+ *
+ * @param methodRef a Method Reference, fx in the form of the double colon syntax like this 'MyClass::myAccessibleMethod', or 'myObject::myAccessibleMethod'.
+ * @param When targeting an overloaded method you must help the compiler choose the correct overloaded toMethod method by specifying the parameters and return value in generics.
+ * @param When targeting an overloaded method you must help the compiler choose the correct overloaded toMethod method by specifying the parameters and return value in generics.
+ * @param When targeting an overloaded method you must help the compiler choose the correct overloaded toMethod method by specifying the parameters and return value in generics.
+ * @param When targeting an overloaded method you must help the compiler choose the correct overloaded toMethod method by specifying the parameters and return value in generics.
+ * @param When targeting an overloaded method you must help the compiler choose the correct overloaded toMethod method by specifying the parameters and return value in generics.
+ * @param When targeting an overloaded method you must help the compiler choose the correct overloaded toMethod method by specifying the parameters and return value in generics.
+ * @param When targeting an overloaded method you must help the compiler choose the correct overloaded toMethod method by specifying the parameters and return value in generics.
+ * @param