Package org.perfectable.introspection
Class FunctionalReference.PartialVisitor<T>
- java.lang.Object
-
- org.perfectable.introspection.FunctionalReference.PartialVisitor<T>
-
- Type Parameters:
T
- type of return value from visitor
- All Implemented Interfaces:
FunctionalReference.Visitor<T>
- Enclosing interface:
- FunctionalReference
public abstract static class FunctionalReference.PartialVisitor<T> extends Object implements FunctionalReference.Visitor<T>
Visitor Pattern partial implementation that allows handling of groups of modes.Calls
fallback()
on any unimplemented method. IfvisitMethod(java.lang.reflect.Method)
is overridden, it is called when mode is "static", "instance" or "bound".
-
-
Constructor Summary
Constructors Constructor Description PartialVisitor()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract T
fallback()
Executes when mode was not overridden.T
visitBound(Method method, Object boundInstance)
Executes when mode of this reference is "bound", i.e.T
visitConstructor(Constructor<?> constructor)
Executes when mode of this reference is "constructor", i.e.T
visitInstance(Method method)
Executes when mode of this reference is "instance", i.e.T
visitLambda(Method method, List<Object> captures)
Executes when mode of this reference is "lambda".protected T
visitMethod(Method method)
Executes when mode of this reference is "static", "instance" or "bound".T
visitStatic(Method method)
Executes when mode of this reference is "static", i.e.
-
-
-
Method Detail
-
visitStatic
public T visitStatic(Method method)
Description copied from interface:FunctionalReference.Visitor
Executes when mode of this reference is "static", i.e. this is a reference to static method.- Specified by:
visitStatic
in interfaceFunctionalReference.Visitor<T>
- Parameters:
method
- method to which this functional references refers- Returns:
- value passed out of
FunctionalReference.Introspection.visit(org.perfectable.introspection.FunctionalReference.Visitor<T>)
-
visitInstance
public T visitInstance(Method method)
Description copied from interface:FunctionalReference.Visitor
Executes when mode of this reference is "instance", i.e. this is a reference to instance method without bound instance.- Specified by:
visitInstance
in interfaceFunctionalReference.Visitor<T>
- Parameters:
method
- method to which this functional references refers- Returns:
- value passed out of
FunctionalReference.Introspection.visit(org.perfectable.introspection.FunctionalReference.Visitor<T>)
-
visitBound
public T visitBound(Method method, Object boundInstance)
Description copied from interface:FunctionalReference.Visitor
Executes when mode of this reference is "bound", i.e. this is a reference to instance method with bound instance present.- Specified by:
visitBound
in interfaceFunctionalReference.Visitor<T>
- Parameters:
method
- method to which this functional references refersboundInstance
- instance that was used to create reference- Returns:
- value passed out of
FunctionalReference.Introspection.visit(org.perfectable.introspection.FunctionalReference.Visitor<T>)
-
visitConstructor
public T visitConstructor(Constructor<?> constructor)
Description copied from interface:FunctionalReference.Visitor
Executes when mode of this reference is "constructor", i.e. this is a reference to constructor.- Specified by:
visitConstructor
in interfaceFunctionalReference.Visitor<T>
- Parameters:
constructor
- constructor to which this functional references refers- Returns:
- value passed out of
FunctionalReference.Introspection.visit(org.perfectable.introspection.FunctionalReference.Visitor<T>)
-
visitLambda
public T visitLambda(Method method, List<Object> captures)
Description copied from interface:FunctionalReference.Visitor
Executes when mode of this reference is "lambda".- Specified by:
visitLambda
in interfaceFunctionalReference.Visitor<T>
- Parameters:
method
- synthetic method that this lambda createdcaptures
- captures caught by this lambda- Returns:
- value passed out of
FunctionalReference.Introspection.visit(org.perfectable.introspection.FunctionalReference.Visitor<T>)
-
visitMethod
protected T visitMethod(Method method)
Executes when mode of this reference is "static", "instance" or "bound".- Parameters:
method
- method that this reference refers to- Returns:
- value passed out of
FunctionalReference.Introspection.visit(org.perfectable.introspection.FunctionalReference.Visitor<T>)
-
fallback
protected abstract T fallback()
Executes when mode was not overridden.- Returns:
- value passed out of
FunctionalReference.Introspection.visit(org.perfectable.introspection.FunctionalReference.Visitor<T>)
-
-