org.springframework.batch.classify
Class ClassifierAdapter<C,T>

java.lang.Object
  extended by org.springframework.batch.classify.ClassifierAdapter<C,T>
All Implemented Interfaces:
Classifier<C,T>

public class ClassifierAdapter<C,T>
extends Object
implements Classifier<C,T>

Wrapper for an object to adapt it to the Classifier interface.

Author:
Dave Syer

Constructor Summary
ClassifierAdapter()
          Default constructor for use with setter injection.
ClassifierAdapter(Classifier<C,T> delegate)
          Create a new Classifier from the delegate provided.
ClassifierAdapter(Object delegate)
          Create a new Classifier from the delegate provided.
 
Method Summary
 T classify(C classifiable)
          Classify the given object and return an object of a different type, possibly an enumerated type.
 void setDelegate(Classifier<C,T> delegate)
           
 void setDelegate(Object delegate)
          Search for the Classifier annotation on a method in the supplied delegate and use that to create a Classifier from the parameter type to the return type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassifierAdapter

public ClassifierAdapter()
Default constructor for use with setter injection.


ClassifierAdapter

public ClassifierAdapter(Object delegate)
Create a new Classifier from the delegate provided. Use the constructor as an alternative to the setDelegate(Object) method.

Parameters:
delegate -

ClassifierAdapter

public ClassifierAdapter(Classifier<C,T> delegate)
Create a new Classifier from the delegate provided. Use the constructor as an alternative to the setDelegate(Classifier) method.

Parameters:
delegate -
Method Detail

setDelegate

public void setDelegate(Classifier<C,T> delegate)

setDelegate

public final void setDelegate(Object delegate)
Search for the Classifier annotation on a method in the supplied delegate and use that to create a Classifier from the parameter type to the return type. If the annotation is not found a unique non-void method with a single parameter will be used, if it exists. The signature of the method cannot be checked here, so might be a runtime exception when the method is invoked if the signature doesn't match the classifier types.

Parameters:
delegate - an object with an annotated method

classify

public T classify(C classifiable)
Classify the given object and return an object of a different type, possibly an enumerated type.

Specified by:
classify in interface Classifier<C,T>
Parameters:
classifiable - the input object. Can be null.
Returns:
an object. Can be null, but implementations should declare if this is the case.


Copyright © 2013 SpringSource. All Rights Reserved.