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); }
private static void setIncomingFlashValues(Request request, Flash flash) { CookieParameters requestCookies = request.cookies(); if (!requestCookies.contains(FLASH_COOKIE) || isEmptyJson(requestCookies.getValue(FLASH_COOKIE)) || isBlank(requestCookies.getValue(FLASH_COOKIE))) return; flash.merge(Json.parseMap(requestCookies.getValue(FLASH_COOKIE)).value()); }
private boolean cookieAlreadyHasSameValue(final Request request, final Cookie cookie) { return cookie.value().equals(request.cookies().getValue(FLASH_COOKIE)); }