Class ReflectionSetterInvoker
java.lang.Object
io.higson.runtime.engine.util.reflection.ReflectionSetterInvoker
Utility for efficient setter invocation. Useful, when same setters should be
find by reflection and invoked multiple times. Whole search magic is hidden
in findSetter(Class, Object) method.
- Author:
- Adam Dubiel dubiel.adam@gmail.com
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfindSetter(Class<?> setterHostClass, Object forArg) Find setter method on host class (and its supertypes), that can handle setting provided argument.booleaninvokeSetter(Object setterHostObject, Object forArg) Find and invoke setter on provided object.
-
Constructor Details
-
ReflectionSetterInvoker
public ReflectionSetterInvoker()
-
-
Method Details
-
invokeSetter
Find and invoke setter on provided object.- Parameters:
setterHostObject- host ObjectforArg- argument object- Returns:
- true if setter for argument found, false otherwise
-
findSetter
Find setter method on host class (and its supertypes), that can handle setting provided argument. Setter does not have to be conventional JavaBeans setter, it is enough to be a single-argument void method that can accept provided argument, no naming convention is applied. This method uses setter caching, so subsequent calls to retrieve same setter are fast.
Caution! Because search method does not follow JavaBeans convention, using it to find different setters for objects of same type will result in nondeterministic results!- Parameters:
setterHostClass- host ClassforArg- argument object- Returns:
- setter method
-