Class BeanCreateMethodFinder<T>
- Type Parameters:
T- The bean type being created.
Used for finding and invoking methods on an object that take in arbitrary parameters and returns bean instances.
This class is instantiated through the following methods:
Example:
See Also:
-
Method Summary
Modifier and TypeMethodDescription<T2> BeanCreateMethodFinder<T>Adds a bean to the lookup for parameters.find(Predicate<MethodInfo> filter) Find the method matching the specified predicate.run()Executes the matched method and returns the result.Same asrun()but also executes a consumer if the returned value was notnull .
-
Method Details
-
addBean
Adds a bean to the lookup for parameters.- Type Parameters:
T2- The bean type.- Parameters:
c- The bean type.t- The bean.- Returns:
- This object.
-
find
Find the method matching the specified predicate.In order for the method to be used, it must adhere to the following restrictions:
- The method must be public.
- The method can be static.
- The method name must match exactly.
- The method must not be deprecated or annotated with
BeanIgnore. - The method must have all parameter types specified in
requiredParams . - The bean store must contain beans for all parameter types.
- The bean store may contain beans for all
Optionalparameter types.
This method can be called multiple times with different method names or required parameters until a match is found.
Once a method is found, subsequent calls to this method will be no-ops. SeeBeanStore.createMethodFinder(Class, Object)for usage.- Parameters:
filter- The predicate to apply.- Returns:
- This object.
-
run
Executes the matched method and returns the result.- Returns:
- The object returned by the method invocation, or the default value if method was not found.
- Throws:
ExecutableException- If method invocation threw an exception.
-
run
Same asrun()but also executes a consumer if the returned value was notnull .- Parameters:
consumer- The consumer of the response.- Returns:
- The object returned by the method invocation, or the default value if method was not found, or
Optional.empty(). - Throws:
ExecutableException- If method invocation threw an exception.
-