Package org.springframework.classify
Class BinaryExceptionClassifier
java.lang.Object
org.springframework.classify.SubclassClassifier<Throwable,Boolean>
org.springframework.classify.BinaryExceptionClassifier
- All Implemented Interfaces:
Serializable
,Classifier<Throwable,
Boolean>
A
Classifier
for exceptions that has only two classes (true and false).
Classifies objects according to their inheritance relation with the supplied types. If
the object to be classified is one of the provided types, or is a subclass of one of
the types, then the non-default value is returned (usually true).- Author:
- Dave Syer, Gary Russell
- See Also:
-
Constructor Summary
ConstructorDescriptionBinaryExceptionClassifier
(boolean defaultValue) Create a binary exception classifier with the provided default value.BinaryExceptionClassifier
(Collection<Class<? extends Throwable>> exceptionClasses) Create a binary exception classifier with the default value false and value mapping true for the provided classes and their subclasses.BinaryExceptionClassifier
(Collection<Class<? extends Throwable>> exceptionClasses, boolean value) Create a binary exception classifier with the provided classes and their subclasses.BinaryExceptionClassifier
(Map<Class<? extends Throwable>, Boolean> typeMap) Create a binary exception classifier using the given classification map and a default classification of false.BinaryExceptionClassifier
(Map<Class<? extends Throwable>, Boolean> typeMap, boolean defaultValue) Create a binary exception classifier using the given classification map and the given value for default class.BinaryExceptionClassifier
(Map<Class<? extends Throwable>, Boolean> typeMap, boolean defaultValue, boolean traverseCauses) Create a binary exception classifier. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()
Return the value from the type map whose key is the class of the given Throwable, or its nearest ancestor if a subclass.static BinaryExceptionClassifier
void
setTraverseCauses
(boolean traverseCauses) Methods inherited from class org.springframework.classify.SubclassClassifier
add, getClassified, getDefault, setDefaultValue, setTypeMap
-
Constructor Details
-
BinaryExceptionClassifier
public BinaryExceptionClassifier(boolean defaultValue) Create a binary exception classifier with the provided default value.- Parameters:
defaultValue
- defaults to false
-
BinaryExceptionClassifier
public BinaryExceptionClassifier(Collection<Class<? extends Throwable>> exceptionClasses, boolean value) Create a binary exception classifier with the provided classes and their subclasses. The mapped value for these exceptions will be the one provided (which will be the opposite of the default).- Parameters:
exceptionClasses
- the exceptions to classify amongvalue
- the value to classify
-
BinaryExceptionClassifier
Create a binary exception classifier with the default value false and value mapping true for the provided classes and their subclasses.- Parameters:
exceptionClasses
- the exception types to throw
-
BinaryExceptionClassifier
Create a binary exception classifier using the given classification map and a default classification of false.- Parameters:
typeMap
- the map of types
-
BinaryExceptionClassifier
public BinaryExceptionClassifier(Map<Class<? extends Throwable>, Boolean> typeMap, boolean defaultValue) Create a binary exception classifier using the given classification map and the given value for default class.- Parameters:
defaultValue
- the default value to usetypeMap
- the map of types to classify
-
BinaryExceptionClassifier
public BinaryExceptionClassifier(Map<Class<? extends Throwable>, Boolean> typeMap, boolean defaultValue, boolean traverseCauses) Create a binary exception classifier.- Parameters:
defaultValue
- the default value to usetypeMap
- the map of types to classifytraverseCauses
- if true, throwable's causes will be inspected to find non-default class
-
-
Method Details
-
builder
-
defaultClassifier
-
setTraverseCauses
public void setTraverseCauses(boolean traverseCauses) -
classify
Description copied from class:SubclassClassifier
Return the value from the type map whose key is the class of the given Throwable, or its nearest ancestor if a subclass.- Specified by:
classify
in interfaceClassifier<Throwable,
Boolean> - Overrides:
classify
in classSubclassClassifier<Throwable,
Boolean> - Parameters:
classifiable
- the classifiable thing- Returns:
- C the classified value
-