I have below code which iterates over Cookies
to reset the cookie whose name matches CookieSession.NAME
Cookie[] cookies = httpServletRequest.getCookies();
LOGGER.info("Clearing cookies on welcome page");
if (cookies != null)
for (Cookie cookie : cookies) {
if (cookie.getName().equals(CookieSession.NAME)) {
cookie.setValue(null);
cookie.setMaxAge(0);
cookie.setPath("/");
httpServletResponse.addCookie(cookie);
}
}
can someone simplify it using java 8 lambda expression
{}
in your if condition