Polishing

This commit is contained in:
Juergen Hoeller
2017-05-23 22:05:22 +02:00
parent db69a082d9
commit 0183576215
7 changed files with 74 additions and 71 deletions

View File

@@ -22,7 +22,8 @@ import org.springframework.util.Assert;
/**
* Represents a function that evaluates on a given {@link ServerRequest}.
* Instances of this function that evaluate on common request properties can be found in {@link RequestPredicates}.
* Instances of this function that evaluate on common request properties
* can be found in {@link RequestPredicates}.
*
* @author Arjen Poutsma
* @since 5.0
@@ -74,17 +75,17 @@ public interface RequestPredicate {
/**
* Transform the given request into a request used for a nested route. For instance,
* a path-based predicate can return a {@code ServerRequest} with a the path remaining after a
* match.
* a path-based predicate can return a {@code ServerRequest} with a the path remaining
* after a match.
* <p>The default implementation returns an {@code Optional} wrapping the given path if
* {@link #test(ServerRequest)} evaluates to {@code true}; or {@link Optional#empty()} if it
* evaluates to {@code false}.
* {@link #test(ServerRequest)} evaluates to {@code true}; or {@link Optional#empty()}
* if it evaluates to {@code false}.
* @param request the request to be nested
* @return the nested request
* @see RouterFunctions#nest(RequestPredicate, RouterFunction)
*/
default Optional<ServerRequest> nest(ServerRequest request) {
return test(request) ? Optional.of(request) : Optional.empty();
return (test(request) ? Optional.of(request) : Optional.empty());
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,10 +44,11 @@ public class HandlerFunctionAdapter implements HandlerAdapter {
HANDLER_FUNCTION_RETURN_TYPE = new MethodParameter(method, -1);
}
catch (NoSuchMethodException ex) {
throw new Error(ex);
throw new IllegalStateException(ex);
}
}
@Override
public boolean supports(Object handler) {
return handler instanceof HandlerFunction;