Introduce Mono#justOrEmpty(T)
This commit is contained in:
parent
999dfe3925
commit
fc1b2e96f7
|
@ -46,8 +46,7 @@ public class RequestParamArgumentResolver implements HandlerMethodArgumentResolv
|
||||||
RequestParam annotation = param.getParameterAnnotation(RequestParam.class);
|
RequestParam annotation = param.getParameterAnnotation(RequestParam.class);
|
||||||
String name = (annotation.value().length() != 0 ? annotation.value() : param.getParameterName());
|
String name = (annotation.value().length() != 0 ? annotation.value() : param.getParameterName());
|
||||||
UriComponents uriComponents = UriComponentsBuilder.fromUri(exchange.getRequest().getURI()).build();
|
UriComponents uriComponents = UriComponentsBuilder.fromUri(exchange.getRequest().getURI()).build();
|
||||||
String value = uriComponents.getQueryParams().getFirst(name);
|
return Mono.justOrEmpty(uriComponents.getQueryParams().getFirst(name));
|
||||||
return (value != null ? Mono.just(value) : Mono.empty());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,10 +57,7 @@ import org.springframework.web.server.session.DefaultWebSessionManager;
|
||||||
import org.springframework.web.server.session.WebSessionManager;
|
import org.springframework.web.server.session.WebSessionManager;
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.endsWith;
|
import static org.hamcrest.CoreMatchers.endsWith;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.*;
|
||||||
import static org.junit.Assert.assertNotNull;
|
|
||||||
import static org.junit.Assert.assertThat;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
|
|
||||||
|
@ -226,7 +223,7 @@ public class ViewResolverResultHandlerTests {
|
||||||
@Override
|
@Override
|
||||||
public Mono<View> resolveViewName(String viewName, Locale locale) {
|
public Mono<View> resolveViewName(String viewName, Locale locale) {
|
||||||
View view = this.views.get(viewName);
|
View view = this.views.get(viewName);
|
||||||
return (view != null ? Mono.just(view) : Mono.empty());
|
return Mono.justOrEmpty(view);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue