org.perfectjpattern.core.structural.adapter
Class NameMatchAdaptingStrategy
java.lang.Object
org.perfectjpattern.core.structural.adapter.ExactMatchAdaptingStrategy
org.perfectjpattern.core.structural.adapter.NameMatchAdaptingStrategy
- All Implemented Interfaces:
- IStrategy, IAdaptingStrategy
public final class NameMatchAdaptingStrategy
- extends ExactMatchAdaptingStrategy
- implements IAdaptingStrategy
Concrete implementation of IAdaptingStrategy. Implements the name
matching strategy. The Adaptee and Target methods
are matched by name. The method correspondence is provided by the user as
a Map of Target method names keyed by
Adaptee method names. The mapping does not have to be exhaustive,
those methods not explicitly mapped will be resolved against the Adaptee
and Adapter using exact match.
- Version:
- $Revision: 1.0 $Date: Jan 28, 2009 3:42:25 PM $
- Author:
- Giovanni Azua
-
-
|
Method Summary |
Method |
resolve(Class<?> aTargetClass,
Object anAdaptee,
Object anAdapter,
Method aTargetMethod)
Returns the Adaptee or otherwise Adapter method
that corresponds to the given Target class type. |
void |
validate(Class<?> aTargetClass,
Object anAdaptee,
Object anAdapter)
According to the definition of this strategy validates the tuple
Target/Adaptee. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
NameMatchAdaptingStrategy
public NameMatchAdaptingStrategy(Map<String,String> aMethodsMapping)
- Constructs a
NameMatchAdaptingStrategy from a map that defines
the correspondence between Target and Adaptee i.e. Adaptee method names
keyed by Target method names.
- Parameters:
aMethodsMapping - Map of Target method names keyed by Target
method names
- Throws:
IllegalArgumentException - 'aMethodsMap' must not be null
validate
public void validate(Class<?> aTargetClass,
Object anAdaptee,
Object anAdapter)
throws NoSuchMethodError
- According to the definition of this strategy validates the tuple
Target/Adaptee. Should the two not match an
NoSuchMethodError will be thrown.
- Specified by:
validate in interface IAdaptingStrategy- Overrides:
validate in class ExactMatchAdaptingStrategy
- Parameters:
aTargetClass - Target class typeanAdaptee - Adaptee instanceanAdapter - Adapter instance
- Throws:
NoSuchMethodError
resolve
public Method resolve(Class<?> aTargetClass,
Object anAdaptee,
Object anAdapter,
Method aTargetMethod)
throws IllegalArgumentException,
NoSuchMethodError
- Returns the
Adaptee or otherwise Adapter method
that corresponds to the given Target class type. If the
corresponding method is not found an NoSuchMethodError will
be thrown.
- Specified by:
resolve in interface IAdaptingStrategy- Overrides:
resolve in class ExactMatchAdaptingStrategy
- Parameters:
aTargetClass - Target class typeanAdaptee - Adaptee instanceanAdapter - Adapter instanceaTargetMethod - Target method to search for in the Adaptee
- Returns:
Adaptee method that corresponds to the given
Target class type
- Throws:
NoSuchMethodError
IllegalArgumentException- See Also:
IAdaptingStrategy.validate(Class, Object, Object)
Copyright © 2007-2009. All Rights Reserved.