Class ClassifierAdapter<C,T>

java.lang.Object
org.springframework.classify.ClassifierAdapter<C,T>
Type Parameters:
C - the type of the thing to classify
T - the output of the classifier
All Implemented Interfaces:
Serializable, 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
See Also:
  • Constructor Details

    • 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 - the 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 - the classifier to delegate to
  • Method Details

    • 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.