public class BinaryExceptionClassifier extends SubclassClassifier<Throwable,Boolean>
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).SubclassClassifier
,
Serialized FormConstructor and Description |
---|
BinaryExceptionClassifier(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.
|
Modifier and Type | Method and Description |
---|---|
static BinaryExceptionClassifierBuilder |
builder() |
Boolean |
classify(Throwable classifiable)
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 |
defaultClassifier() |
void |
setTraverseCauses(boolean traverseCauses) |
add, getClassified, getDefault, setDefaultValue, setTypeMap
public BinaryExceptionClassifier(boolean defaultValue)
defaultValue
- defaults to falsepublic BinaryExceptionClassifier(Collection<Class<? extends Throwable>> exceptionClasses, boolean value)
exceptionClasses
- the exceptions to classify amongvalue
- the value to classifypublic BinaryExceptionClassifier(Collection<Class<? extends Throwable>> exceptionClasses)
exceptionClasses
- the exception types to throwpublic BinaryExceptionClassifier(Map<Class<? extends Throwable>,Boolean> typeMap)
typeMap
- the map of typespublic BinaryExceptionClassifier(Map<Class<? extends Throwable>,Boolean> typeMap, boolean defaultValue)
defaultValue
- the default value to usetypeMap
- the map of types to classifypublic BinaryExceptionClassifier(Map<Class<? extends Throwable>,Boolean> typeMap, boolean defaultValue, boolean traverseCauses)
defaultValue
- the default value to usetypeMap
- the map of types to classifytraverseCauses
- if true, throwable's causes will be inspected to find
non-default classpublic static BinaryExceptionClassifierBuilder builder()
public static BinaryExceptionClassifier defaultClassifier()
public void setTraverseCauses(boolean traverseCauses)
public Boolean classify(Throwable classifiable)
SubclassClassifier
classify
in interface Classifier<Throwable,Boolean>
classify
in class SubclassClassifier<Throwable,Boolean>
classifiable
- the classifiable thingCopyright © 2022 SpringSource. All rights reserved.