T- the type of the input to the function
public interface CtConsumableFunction<T>
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()))`
Copyright © 2007–2020 Inria. All rights reserved.