Java 类org.springframework.core.ExceptionDepthComparator 实例源码

项目:lams    文件:ExceptionHandlerMethodResolver.java   
/**
 * Return the {@link Method} mapped to the given exception type, or {@code null} if none.
 */
private Method getMappedMethod(Class<? extends Exception> exceptionType) {
    List<Class<? extends Throwable>> matches = new ArrayList<Class<? extends Throwable>>();
    for(Class<? extends Throwable> mappedException : this.mappedMethods.keySet()) {
        if (mappedException.isAssignableFrom(exceptionType)) {
            matches.add(mappedException);
        }
    }
    if (!matches.isEmpty()) {
        Collections.sort(matches, new ExceptionDepthComparator(exceptionType));
        return this.mappedMethods.get(matches.get(0));
    }
    else {
        return null;
    }
}
项目:spring4-understanding    文件:AbstractExceptionHandlerMethodResolver.java   
/**
 * Return the method mapped to the given exception type or {@code null}.
 */
private Method getMappedMethod(Class<? extends Exception> exceptionType) {
    List<Class<? extends Throwable>> matches = new ArrayList<Class<? extends Throwable>>();
    for (Class<? extends Throwable> mappedException : this.mappedMethods.keySet()) {
        if (mappedException.isAssignableFrom(exceptionType)) {
            matches.add(mappedException);
        }
    }
    if (!matches.isEmpty()) {
        Collections.sort(matches, new ExceptionDepthComparator(exceptionType));
        return this.mappedMethods.get(matches.get(0));
    }
    else {
        return null;
    }
}
项目:spring4-understanding    文件:ExceptionHandlerMethodResolver.java   
/**
 * Return the {@link Method} mapped to the given exception type, or {@code null} if none.
 */
private Method getMappedMethod(Class<? extends Exception> exceptionType) {
    List<Class<? extends Throwable>> matches = new ArrayList<Class<? extends Throwable>>();
    for (Class<? extends Throwable> mappedException : this.mappedMethods.keySet()) {
        if (mappedException.isAssignableFrom(exceptionType)) {
            matches.add(mappedException);
        }
    }
    if (!matches.isEmpty()) {
        Collections.sort(matches, new ExceptionDepthComparator(exceptionType));
        return this.mappedMethods.get(matches.get(0));
    }
    else {
        return null;
    }
}
项目:class-guard    文件:ExceptionHandlerMethodResolver.java   
/**
 * Return the {@link Method} mapped to the given exception type, or {@code null} if none.
 */
private Method getMappedMethod(Class<? extends Exception> exceptionType) {
    List<Class<? extends Throwable>> matches = new ArrayList<Class<? extends Throwable>>();
    for(Class<? extends Throwable> mappedException : this.mappedMethods.keySet()) {
        if (mappedException.isAssignableFrom(exceptionType)) {
            matches.add(mappedException);
        }
    }
    if (!matches.isEmpty()) {
        Collections.sort(matches, new ExceptionDepthComparator(exceptionType));
        return this.mappedMethods.get(matches.get(0));
    }
    else {
        return null;
    }
}
项目:spring4-understanding    文件:AnnotationMethodHandlerExceptionResolver.java   
/**
 * Uses the {@link ExceptionDepthComparator} to find the best matching method.
 * @return the best matching method, or {@code null} if none found
 */
private Method getBestMatchingMethod(
        Map<Class<? extends Throwable>, Method> resolverMethods, Exception thrownException) {

    if (resolverMethods.isEmpty()) {
        return null;
    }
    Class<? extends Throwable> closestMatch =
            ExceptionDepthComparator.findClosestMatch(resolverMethods.keySet(), thrownException);
    Method method = resolverMethods.get(closestMatch);
    return (method == null || NO_METHOD_FOUND == method ? null : method);
}
项目:spring4-understanding    文件:AnnotationMethodHandlerExceptionResolver.java   
/**
 * Uses the {@link ExceptionDepthComparator} to find the best matching method.
 * @return the best matching method, or {@code null} if none found
 */
private Method getBestMatchingMethod(
        Map<Class<? extends Throwable>, Method> resolverMethods, Exception thrownException) {

    if (resolverMethods.isEmpty()) {
        return null;
    }
    Class<? extends Throwable> closestMatch =
            ExceptionDepthComparator.findClosestMatch(resolverMethods.keySet(), thrownException);
    Method method = resolverMethods.get(closestMatch);
    return ((method == null) || (NO_METHOD_FOUND == method)) ? null : method;
}
项目:class-guard    文件:AnnotationMethodHandlerExceptionResolver.java   
/**
 * Uses the {@link ExceptionDepthComparator} to find the best matching method.
 * @return the best matching method or {@code null}.
 */
private Method getBestMatchingMethod(
        Map<Class<? extends Throwable>, Method> resolverMethods, Exception thrownException) {

    if (resolverMethods.isEmpty()) {
        return null;
    }
    Class<? extends Throwable> closestMatch =
            ExceptionDepthComparator.findClosestMatch(resolverMethods.keySet(), thrownException);
    Method method = resolverMethods.get(closestMatch);
    return (method == null || NO_METHOD_FOUND == method ? null : method);
}
项目:class-guard    文件:AnnotationMethodHandlerExceptionResolver.java   
/**
 * Uses the {@link DepthComparator} to find the best matching method
 * @return the best matching method or {@code null}.
 */
private Method getBestMatchingMethod(
        Map<Class<? extends Throwable>, Method> resolverMethods, Exception thrownException) {

    if (resolverMethods.isEmpty()) {
        return null;
    }
    Class<? extends Throwable> closestMatch =
            ExceptionDepthComparator.findClosestMatch(resolverMethods.keySet(), thrownException);
    Method method = resolverMethods.get(closestMatch);
    return ((method == null) || (NO_METHOD_FOUND == method)) ? null : method;
}