net.sourceforge.hiveutils.util
Class DefaultMethodMappingBuilder
java.lang.Object
net.sourceforge.hiveutils.util.DefaultMethodMappingBuilder
- All Implemented Interfaces:
- MethodMappingBuilder
public class DefaultMethodMappingBuilder
- extends java.lang.Object
- implements MethodMappingBuilder
Default implementation to generate a mapping between public methods of a
source class (or interface) into equivalent methods (same name, same
arguments, compatible returned type, but possibly different thrown
exceptions).
- Author:
- Jean-Francois Poilpret
Method Summary |
java.util.Map<java.lang.reflect.Method,java.lang.reflect.Method> |
buildMapping(java.lang.Class source,
java.lang.Class target,
MethodMappingErrorHandler handler)
The method analyses all public methods of source class. |
protected java.lang.reflect.Method |
mapMethod(java.lang.reflect.Method source,
java.lang.Class targetClass,
MethodMappingErrorHandler handler)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DefaultMethodMappingBuilder
public DefaultMethodMappingBuilder()
buildMapping
public java.util.Map<java.lang.reflect.Method,java.lang.reflect.Method> buildMapping(java.lang.Class source,
java.lang.Class target,
MethodMappingErrorHandler handler)
- The method analyses all public methods of source class. For each method:
- search a public method with the name and arguments list in target
- check the returned type of the target method is assignable to the
the returned type of the source method
If a source
method has no target
method with
matches for name and arguments, then a warning is generated and that
method will not appear in the returned Map
.
- Specified by:
buildMapping
in interface MethodMappingBuilder
- Parameters:
source
- class (or interface) which methods need to be mapped to
target
target
- class (or interface) to which source
methods
need to be mappedhandler
- the instance that will be called back when errors occur
- Returns:
- a
Map
of source Method
s to
equivalent target Method
s
mapMethod
protected java.lang.reflect.Method mapMethod(java.lang.reflect.Method source,
java.lang.Class targetClass,
MethodMappingErrorHandler handler)