org.perfectjpattern.core.structural.adapter
Class ExactMatchAdaptingStrategy

java.lang.Object
  extended by org.perfectjpattern.core.structural.adapter.ExactMatchAdaptingStrategy
All Implemented Interfaces:
IStrategy, IAdaptingStrategy
Direct Known Subclasses:
NameMatchAdaptingStrategy

public class ExactMatchAdaptingStrategy
extends Object
implements IAdaptingStrategy

Concrete implementation of IAdaptingStrategy. Implements the exact matching strategy. The Adaptee and Target methods (name and parameters) must match or at least the Adaptee methods must be a subset of Target methods.

Version:
$Revision: 1.0 $Date: Jan 28, 2009 2:20:39 PM $
Author:
Giovanni Azua
 

Constructor Summary
ExactMatchAdaptingStrategy()
           
 
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.
protected  Method resolve(Object anObject, Method aMethodPrototype)
          Returns the found matching Method if exists, null or NoSuchMethodError otherwise
protected  Method resolve(Object anObject, Method aMethodPrototype, String aMethodName)
          Returns the found matching Method if exists, null or NoSuchMethodError otherwise
 void validate(Class<?> aTargetClass, Object anAdaptee, Object anAdapter)
          According to the definition of this strategy validates the tuple Target/Adaptee.
protected  void validate(Class<?> anInterface, Object anImplementor, Set<String> aTargetMethods)
          Removes from aTargetMethods all methods found in anInterface that are actually implemented by anImplementor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExactMatchAdaptingStrategy

public ExactMatchAdaptingStrategy()
Method Detail

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
Parameters:
aTargetClass - Target class type
anAdaptee - Adaptee instance
anAdapter - 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
Parameters:
aTargetClass - Target class type
anAdaptee - Adaptee instance
anAdapter - Adapter instance
aTargetMethod - 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)

validate

protected void validate(Class<?> anInterface,
                        Object anImplementor,
                        Set<String> aTargetMethods)
Removes from aTargetMethods all methods found in anInterface that are actually implemented by anImplementor

Parameters:
anInterface - The target interface
anImplementor - The underlying implementor
aTargetMethods - The methods to search for

resolve

protected Method resolve(Object anObject,
                         Method aMethodPrototype,
                         String aMethodName)
                  throws NoSuchMethodError
Returns the found matching Method if exists, null or NoSuchMethodError otherwise

Parameters:
anObject -
aMethodPrototype -
aMethodName -
Returns:
found matching Method if exists, null or NoSuchMethodError otherwise
Throws:
NoSuchMethodError

resolve

protected Method resolve(Object anObject,
                         Method aMethodPrototype)
                  throws NoSuchMethodError
Returns the found matching Method if exists, null or NoSuchMethodError otherwise

Parameters:
anObject -
aMethodPrototype -
Returns:
found matching Method if exists, null or NoSuchMethodError otherwise
Throws:
NoSuchMethodError


Copyright © 2007-2009. All Rights Reserved.