Package io.micronaut.context
Class AbstractExecutableMethodsDefinition<T>
- java.lang.Object
-
- io.micronaut.context.AbstractExecutableMethodsDefinition<T>
-
- Type Parameters:
T
- The type
- All Implemented Interfaces:
EnvironmentConfigurable
,ExecutableMethodsDefinition<T>
@Internal public abstract class AbstractExecutableMethodsDefinition<T> extends java.lang.Object implements ExecutableMethodsDefinition<T>, EnvironmentConfigurable
Abstract base class for forExecutableMethodsDefinition
.- Since:
- 3.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AbstractExecutableMethodsDefinition.MethodReference
Internal class representing method's metadata.
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractExecutableMethodsDefinition(AbstractExecutableMethodsDefinition.MethodReference[] methodsReferences)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
configure(Environment environment)
Configure the component for the given environment.protected java.lang.Object
dispatch(int index, T target, java.lang.Object[] args)
Triggers the invocation of the method at index.<R> java.util.Optional<ExecutableMethod<T,R>>
findMethod(java.lang.String name, java.lang.Class<?>... argumentTypes)
Finds a singleExecutableMethod
for the given name and argument types.<R> java.util.stream.Stream<ExecutableMethod<T,R>>
findPossibleMethods(java.lang.String name)
Finds possible methods for the given method name.protected java.lang.reflect.Method
getAccessibleTargetMethodByIndex(int index)
FindMethod
representation at the method by index.<R> ExecutableMethod<T,R>
getExecutableMethodByIndex(int index)
GetsExecutableMethod
method by it's index.java.util.Collection<ExecutableMethod<T,?>>
getExecutableMethods()
protected <R> ExecutableMethod<T,R>
getMethod(java.lang.String name, java.lang.Class<?>... argumentTypes)
Finds executable method or returns a null otherwise.protected abstract java.lang.reflect.Method
getTargetMethodByIndex(int index)
FindMethod
representation at the method by index.protected boolean
methodAtIndexMatches(int index, java.lang.String name, java.lang.Class[] argumentTypes)
Checks if the method at index matches name and argument types.protected java.lang.RuntimeException
unknownDispatchAtIndexException(int index)
Creates a new exception when the dispatch at index is not found.protected java.lang.Throwable
unknownMethodAtIndexException(int index)
Creates a new exception when the method at index is not found.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.micronaut.context.EnvironmentConfigurable
hasPropertyExpressions
-
-
-
-
Constructor Detail
-
AbstractExecutableMethodsDefinition
protected AbstractExecutableMethodsDefinition(AbstractExecutableMethodsDefinition.MethodReference[] methodsReferences)
-
-
Method Detail
-
configure
public void configure(Environment environment)
Description copied from interface:EnvironmentConfigurable
Configure the component for the given environment.- Specified by:
configure
in interfaceEnvironmentConfigurable
- Parameters:
environment
- The environment
-
getExecutableMethods
public java.util.Collection<ExecutableMethod<T,?>> getExecutableMethods()
- Specified by:
getExecutableMethods
in interfaceExecutableMethodsDefinition<T>
- Returns:
- The
ExecutableMethod
instances for this definition
-
findMethod
public <R> java.util.Optional<ExecutableMethod<T,R>> findMethod(java.lang.String name, java.lang.Class<?>... argumentTypes)
Description copied from interface:ExecutableMethodsDefinition
Finds a singleExecutableMethod
for the given name and argument types.- Specified by:
findMethod
in interfaceExecutableMethodsDefinition<T>
- Type Parameters:
R
- The return type- Parameters:
name
- The method nameargumentTypes
- The argument types- Returns:
- An optional
ExecutableMethod
-
findPossibleMethods
public <R> java.util.stream.Stream<ExecutableMethod<T,R>> findPossibleMethods(java.lang.String name)
Description copied from interface:ExecutableMethodsDefinition
Finds possible methods for the given method name.- Specified by:
findPossibleMethods
in interfaceExecutableMethodsDefinition<T>
- Type Parameters:
R
- The return type- Parameters:
name
- The method name- Returns:
- The possible methods
-
getExecutableMethodByIndex
public <R> ExecutableMethod<T,R> getExecutableMethodByIndex(int index)
GetsExecutableMethod
method by it's index.- Type Parameters:
R
- The result type- Parameters:
index
- The method index- Returns:
- The
ExecutableMethod
-
getMethod
@Nullable protected <R> ExecutableMethod<T,R> getMethod(java.lang.String name, java.lang.Class<?>... argumentTypes)
Finds executable method or returns a null otherwise.- Type Parameters:
R
- The return type- Parameters:
name
- The method nameargumentTypes
- The method arguments- Returns:
- The
ExecutableMethod
-
dispatch
protected java.lang.Object dispatch(int index, T target, java.lang.Object[] args)
Triggers the invocation of the method at index. Used byExecutable.invoke(Object, Object...)
.- Parameters:
index
- The method indextarget
- The targetargs
- The arguments- Returns:
- The result
-
getTargetMethodByIndex
protected abstract java.lang.reflect.Method getTargetMethodByIndex(int index)
FindMethod
representation at the method by index. Used byMethodReference.getTargetMethod()
.- Parameters:
index
- The index- Returns:
- The method
-
getAccessibleTargetMethodByIndex
protected final java.lang.reflect.Method getAccessibleTargetMethodByIndex(int index)
FindMethod
representation at the method by index. Used byMethodReference.getTargetMethod()
.- Parameters:
index
- The index- Returns:
- The method
- Since:
- 3.4.0
-
unknownMethodAtIndexException
protected final java.lang.Throwable unknownMethodAtIndexException(int index)
Creates a new exception when the method at index is not found.- Parameters:
index
- The method index- Returns:
- The exception
-
unknownDispatchAtIndexException
protected final java.lang.RuntimeException unknownDispatchAtIndexException(int index)
Creates a new exception when the dispatch at index is not found.- Parameters:
index
- The method index- Returns:
- The exception
-
methodAtIndexMatches
protected final boolean methodAtIndexMatches(int index, java.lang.String name, java.lang.Class[] argumentTypes)
Checks if the method at index matches name and argument types.- Parameters:
index
- The method indexname
- The method nameargumentTypes
- The method arguments- Returns:
- true if matches
-
-