Package org.springframework.classify
Class ClassifierAdapter<C,T>
java.lang.Object
org.springframework.classify.ClassifierAdapter<C,T>
- Type Parameters:
C
- the type of the thing to classifyT
- the output of the classifier
- All Implemented Interfaces:
Serializable
,Classifier<C,
T>
Wrapper for an object to adapt it to the
Classifier
interface.- Author:
- Dave Syer
- See Also:
-
Constructor Summary
ConstructorDescriptionDefault constructor for use with setter injection.ClassifierAdapter
(Object delegate) Create a newClassifier
from the delegate provided.ClassifierAdapter
(Classifier<C, T> delegate) Create a newClassifier
from the delegate provided. -
Method Summary
Modifier and TypeMethodDescriptionClassify the given object and return an object of a different type, possibly an enumerated type.final void
setDelegate
(Object delegate) Search for theClassifier
annotation on a method in the supplied delegate and use that to create aClassifier
from the parameter type to the return type.void
setDelegate
(Classifier<C, T> delegate)
-
Constructor Details
-
ClassifierAdapter
public ClassifierAdapter()Default constructor for use with setter injection. -
ClassifierAdapter
Create a newClassifier
from the delegate provided. Use the constructor as an alternative to thesetDelegate(Object)
method.- Parameters:
delegate
- the delegate
-
ClassifierAdapter
Create a newClassifier
from the delegate provided. Use the constructor as an alternative to thesetDelegate(Classifier)
method.- Parameters:
delegate
- the classifier to delegate to
-
-
Method Details
-
setDelegate
-
setDelegate
Search for theClassifier
annotation on a method in the supplied delegate and use that to create aClassifier
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
Classify the given object and return an object of a different type, possibly an enumerated type.- Specified by:
classify
in interfaceClassifier<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.
-