- Type Parameters:
T- the type of the input to the function
- All Known Implementing Classes:
public interface CtConsumableFunction<T>
Represents a function, as
CtFunction. However, the main difference is that while a
CtFunctionreturns something with a standard Java return keyword, a
CtConsumableFunctionreturns something by passing the returned object as parameter to the given outpuConsumer#accept. This enables to write efficient and concise code in certain situations. It also enables one to emulate several returns, by simply calling several times accept, while not paying the code or performance price of creating a list or an iterable object. It is typically used as parameter of
CtQueryable.map(CtConsumableFunction), can be written as one-liners with Java8 lambdas:.`cls.map((CtClass<?> c, CtConsumer<Object> out)->out.accept(c.getParent()))`
applyEvaluates the function on the given input.
input- the input of the function
outputConsumer- the consumer which accepts the results of this function.