类 ExceptionDepthComparator

java.lang.Object
cn.taketoday.util.comparator.ExceptionDepthComparator
所有已实现的接口:
Comparator<Class<? extends Throwable>>

public class ExceptionDepthComparator extends Object implements Comparator<Class<? extends Throwable>>
Comparator capable of sorting exceptions based on their depth from the thrown exception type.
从以下版本开始:
4.0
作者:
Juergen Hoeller, Arjen Poutsma
  • 字段详细资料

    • targetException

      private final Class<? extends Throwable> targetException
  • 构造器详细资料

    • ExceptionDepthComparator

      public ExceptionDepthComparator(Throwable exception)
      Create a new ExceptionDepthComparator for the given exception.
      参数:
      exception - the target exception to compare to when sorting by depth
    • ExceptionDepthComparator

      public ExceptionDepthComparator(Class<? extends Throwable> exceptionType)
      Create a new ExceptionDepthComparator for the given exception type.
      参数:
      exceptionType - the target exception type to compare to when sorting by depth
  • 方法详细资料

    • compare

      public int compare(Class<? extends Throwable> o1, Class<? extends Throwable> o2)
      指定者:
      compare 在接口中 Comparator<Class<? extends Throwable>>
    • getDepth

      private int getDepth(Class<?> declaredException, Class<?> exceptionToMatch, int depth)
    • findClosestMatch

      public static Class<? extends Throwable> findClosestMatch(Collection<Class<? extends Throwable>> exceptionTypes, Throwable targetException)
      Obtain the closest match from the given exception types for the given target exception.
      参数:
      exceptionTypes - the collection of exception types
      targetException - the target exception to find a match for
      返回:
      the closest matching exception type from the given collection