Package spoon.reflect.visitor.chain
Interface CtConsumableFunction<T>
-
- Type Parameters:
T
- the type of the input to the function
- All Known Implementing Classes:
AllMethodsSameSignatureFunction
,AllTypeMembersFunction
,CatchVariableReferenceFunction
,CatchVariableScopeFunction
,CtScannerFunction
,FieldReferenceFunction
,FieldScopeFunction
,LocalVariableReferenceFunction
,LocalVariableScopeFunction
,OverriddenMethodQuery
,ParameterReferenceFunction
,ParameterScopeFunction
,ParentFunction
,PotentialVariableDeclarationFunction
,SiblingsFunction
,SubInheritanceHierarchyFunction
,SuperInheritanceHierarchyFunction
,VariableReferenceFunction
,VariableScopeFunction
public interface CtConsumableFunction<T>
Represents a function, asCtFunction
. However, the main difference is that while aCtFunction
returns something with a standard Java return keyword, aCtConsumableFunction
returns 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 ofCtQueryable.map(CtConsumableFunction)
, can be written as one-liners with Java8 lambdas:.`cls.map((CtClass<?> c, CtConsumer<Object> out)->out.accept(c.getParent()))`
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
apply(T input, CtConsumer<Object> outputConsumer)
Evaluates the function on the given input.
-
-
-
Method Detail
-
apply
void apply(T input, CtConsumer<Object> outputConsumer)
Evaluates the function on the given input.- Parameters:
input
- the input of the functionoutputConsumer
- the consumer which accepts the results of this function.
-
-