private Response set(final Request request, final Response response, final Cookie cookie) { if (cookieAlreadyHasSameValue(request, cookie) || (isEmptyJson(cookie.value()) && !request.cookies().contains(FLASH_COOKIE))) { return response; } return response.cookie(cookie); }
/** This is designed to be lossy as Request Cookies never have attributes */ default Request cookie(Cookie cookie) { return cookie(cookie.name(), cookie.value()); }
private boolean cookieAlreadyHasSameValue(final Request request, final Cookie cookie) { return cookie.value().equals(request.cookies().getValue(FLASH_COOKIE)); }