/** * 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; } }
/** * 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; } }
/** * 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; } }
/** * 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); }
/** * 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; }
/** * 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); }
/** * 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; }