org.callbackparams.combine.annotation
Class AnnotationAwareCallbackRecordsFactory

java.lang.Object
  extended by org.callbackparams.combine.reflect.CallbackRecordsFactory
      extended by org.callbackparams.combine.annotation.AnnotationAwareCallbackRecordsFactory

public class AnnotationAwareCallbackRecordsFactory
extends CallbackRecordsFactory

This Java5+ extension to CallbackRecordsFactory supports the annotations @CombineConfig and @CallbackRecords. An instance of this class will be returned by CallbackRecordsFactory.getInstance() when invoked inside a Java5+ JVM. It also sees to that fields that are annotated with @ParameterizedValue will be combined and made available as callback (usually).

Author:
Henrik Kaipe
See Also:
CallbackRecordsFactory.getInstance()

Constructor Summary
AnnotationAwareCallbackRecordsFactory()
           
 
Method Summary
 Collection collectCallbackRecordsReflectively(Class testClass)
          This overridden implementation looks for a method that is annotated with CallbackRecords and returns the records provided by that method.
protected  Map<Field,Class<?>> collectValueInjections(Class testClass)
          Collects values for the parameterized fields that are to be value-injected.
protected  boolean isValueAlsoAvailableAsCallback(Field f)
          This overridden method makes sure that a parameter value stays out of the callback-record if its field is annotated with @ParameterizedValue(alsoAvailableAsCallback=false)
 CombineStrategy retrieveCombineStrategy(Class testClass)
          The default combine strategy is CombineAllPossible2Combinations but any other strategy could be used by overriding this class or by using the @CombineConfig annotation (if using JDK-1.5+).
 
Methods inherited from class org.callbackparams.combine.reflect.CallbackRecordsFactory
asCombinedArray, findCallbackValuesFactoryClasses, getInstance, isCallbackValuesFactoryClass, retrieveCombinedArray, valuesMethodFor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnnotationAwareCallbackRecordsFactory

public AnnotationAwareCallbackRecordsFactory()
Method Detail

retrieveCombineStrategy

public CombineStrategy retrieveCombineStrategy(Class testClass)
Description copied from class: CallbackRecordsFactory
The default combine strategy is CombineAllPossible2Combinations but any other strategy could be used by overriding this class or by using the @CombineConfig annotation (if using JDK-1.5+).

Overrides:
retrieveCombineStrategy in class CallbackRecordsFactory

collectCallbackRecordsReflectively

public Collection collectCallbackRecordsReflectively(Class testClass)
This overridden implementation looks for a method that is annotated with CallbackRecords and returns the records provided by that method. The method must be static or an Error will be thrown. If there is no such method or if the method is declared in a super-class and there is a CombineConfig annotation on a subclass then the callback-records will instead be determined in the combinatory manner. If the CallbackRecords annotated method's class is also annotated with CombineConfig then the callback-records will be collected by both strategies, i.e. combinatory-determined records will be collected as well as the records returned by the CallbackRecords method.

Overrides:
collectCallbackRecordsReflectively in class CallbackRecordsFactory
Parameters:
testClass - the test class
Returns:
the collection of combined and ready-to-use callback-records retrieved from testClass

collectValueInjections

protected Map<Field,Class<?>> collectValueInjections(Class testClass)
Description copied from class: CallbackRecordsFactory
Collects values for the parameterized fields that are to be value-injected. This default implementation returns an empty map but the JDK-1.5+ implementation overrides this and makes sure that @ParameterizedValue annotated fields are value-injected.

Overrides:
collectValueInjections in class CallbackRecordsFactory
Returns:
a map that maps instances of Field to the class, in which to find the values() method that will provide the values for this field

isValueAlsoAvailableAsCallback

protected boolean isValueAlsoAvailableAsCallback(Field f)
This overridden method makes sure that a parameter value stays out of the callback-record if its field is annotated with @ParameterizedValue(alsoAvailableAsCallback=false)

Overrides:
isValueAlsoAvailableAsCallback in class CallbackRecordsFactory
See Also:
ParameterizedValue


Copyright © 2010-2013 Henrik Kaipe. All Rights Reserved.