Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package com.github.dakusui.crest.core;
import com.github.dakusui.crest.utils.InternalUtils;
import com.github.dakusui.crest.utils.printable.Functions;
import java.util.Arrays;
import java.util.function.Function;
import static com.github.dakusui.crest.utils.printable.Functions.THIS;
import static java.util.Objects.requireNonNull;
/**
* An interface of a builder for a function that transforms a "target object" into
* another value by calling a chain of methods on it and a value from a previous call.
*
* That is, you can build a function that does following if a StringBuilder is given as
* its input,
* {@code
* (StringBuilder b) -> b.append("hello").append(1).append("world").append("everyone").toString()
* }
* By following code,
* {@code
* Function func = Call.create("append", "hello")
* .andThen("append", 1)
* .andThen("append", "everyone")
* .andThen("toString")
* .$()
* }
*
* The benefit of using this class is to be able to print what you are going to do
* in a pretty format in "Crest" library's output. If you call {@code toString}
* method on the {@code func} object, you will get,
*
*/
public interface Call {
/**
* Add a method call of a method specified by {@code methodName} and {@code args}
* to this builder on the current target object.
*
* If you need to invoke a method on other than the current target object,
* you need to use {@code andThenOn} method.
* n
*
* @param methodName a name of method to be invoked.
* @param args Arguments with which the method is invoked.
* @return This object.
*/
default Call andThen(String methodName, Object... args) {
return andThenOn(THIS, methodName, args);
}
/**
* Adds a call of a method specified by {@code object}, {@code methodName} and
* {@code args}.
*
* @param object An object on which the method should be invoked.
* @param methodName A name of the method to be invoked
* @param args Arguments with which the method is invoked.
* @return This object.
*/
Call andThenOn(Object object, String methodName, Object... args);
/**
* Builds a function.
*
* @param Type of the result of the function to be built.
* @return The function.
*/
Function