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
ConstructorsConstructorDescriptionDefault constructor for use with setter injection.ClassifierAdapter(Object delegate) Create a newClassifierfrom the delegate provided.ClassifierAdapter(Classifier<C, T> delegate) Create a newClassifierfrom the delegate provided. -
Method Summary
Modifier and TypeMethodDescriptionClassify the given object and return an object of a different type, possibly an enumerated type.final voidsetDelegate(Object delegate) Search for theClassifierannotation on a method in the supplied delegate and use that to create aClassifierfrom the parameter type to the return type.voidsetDelegate(Classifier<C, T> delegate)
-
Constructor Details
-
ClassifierAdapter
public ClassifierAdapter()Default constructor for use with setter injection. -
ClassifierAdapter
Create a newClassifierfrom the delegate provided. Use the constructor as an alternative to thesetDelegate(Object)method.- Parameters:
delegate- the delegate
-
ClassifierAdapter
Create a newClassifierfrom 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 theClassifierannotation on a method in the supplied delegate and use that to create aClassifierfrom 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:
classifyin 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.
-