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

下面列出了怎么用org.springframework.core.ExceptionDepthComparator的API类实例代码及写法,或者点击链接到github查看源代码。

/**
 * Return the {@link Method} mapped to the given exception type, or {@code null} if none.
 */
@Nullable
private Method getMappedMethod(Class<? extends Throwable> exceptionType) {
	List<Class<? extends Throwable>> matches = new ArrayList<>();
	for (Class<? extends Throwable> mappedException : this.mappedMethods.keySet()) {
		if (mappedException.isAssignableFrom(exceptionType)) {
			matches.add(mappedException);
		}
	}
	if (!matches.isEmpty()) {
		matches.sort(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.
 */
@Nullable
private Method getMappedMethod(Class<? extends Throwable> exceptionType) {
	List<Class<? extends Throwable>> matches = new ArrayList<>();
	for (Class<? extends Throwable> mappedException : this.mappedMethods.keySet()) {
		if (mappedException.isAssignableFrom(exceptionType)) {
			matches.add(mappedException);
		}
	}
	if (!matches.isEmpty()) {
		matches.sort(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.
 */
@Nullable
private Method getMappedMethod(Class<? extends Throwable> exceptionType) {
	List<Class<? extends Throwable>> matches = new ArrayList<>();
	for (Class<? extends Throwable> mappedException : this.mappedMethods.keySet()) {
		if (mappedException.isAssignableFrom(exceptionType)) {
			matches.add(mappedException);
		}
	}
	if (!matches.isEmpty()) {
		matches.sort(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.
 */
@Nullable
private Method getMappedMethod(Class<? extends Throwable> exceptionType) {
	List<Class<? extends Throwable>> matches = new ArrayList<>();
	for (Class<? extends Throwable> mappedException : this.mappedMethods.keySet()) {
		if (mappedException.isAssignableFrom(exceptionType)) {
			matches.add(mappedException);
		}
	}
	if (!matches.isEmpty()) {
		matches.sort(new ExceptionDepthComparator(exceptionType));
		return this.mappedMethods.get(matches.get(0));
	}
	else {
		return null;
	}
}
 
源代码5 项目: lams   文件: ExceptionHandlerMethodResolver.java
/**
 * Return the {@link Method} mapped to the given exception type, or {@code null} if none.
 */
private Method getMappedMethod(Class<? extends Throwable> 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} 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;
}
 
 类所在包
 同包方法