package com.codahale.dropwizard.sessions;

import com.google.common.base.Optional;

import javax.servlet.http.HttpSession;

public class Flash<T> {
    private final HttpSession session;
    private final T value;

    @SuppressWarnings("unchecked")
    Flash(HttpSession session) {
        this.session = session;
        this.value = (T) session.getAttribute("flash");
        if (this.value != null) {
            session.removeAttribute("flash");
        }
    }

    public Optional<T> get() {
        return Optional.fromNullable(value);
    }

    public void set(T value) {
        session.setAttribute("flash", value);
    }
}

@@ -141,16 +141,69 @@
 sh%3CT%3E %7B%0A
+    private static final String ATTRIBUTE = %22flash%22;%0A
     priv
@@ -399,39 +399,41 @@
 on.getAttribute(
-%22flash%22
+ATTRIBUTE
 );%0A        if (t
@@ -489,23 +489,25 @@
 tribute(
-%22flash%22
+ATTRIBUTE
 );%0A     
@@ -661,23 +661,25 @@
 tribute(
-%22flash%22
+ATTRIBUTE
 , value)

Tidy up Flash.