Merge pull request #15575 from igor-suhorukov

* pr/15575:
  Polish "Use Optional value in more functional style"
  Use Optional value in more functional style
This commit is contained in:
Stephane Nicoll
2018-12-29 11:27:15 +01:00

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2018 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.
@@ -63,10 +63,9 @@ class CompositeHandlerAdapter implements HandlerAdapter {
@Override
public long getLastModified(HttpServletRequest request, Object handler) {
Optional<HandlerAdapter> adapter = getAdapter(handler);
if (adapter.isPresent()) {
return adapter.get().getLastModified(request, handler);
}
return 0;
return adapter
.map((handlerAdapter) -> handlerAdapter.getLastModified(request, handler))
.orElse(0L);
}
private Optional<HandlerAdapter> getAdapter(Object handler) {