Session.getAttribute returns generic type

This prevents the need to cast the attribute values.

Fixes: gh-64
This commit is contained in:
Rob Winch
2014-12-11 11:05:33 -06:00
parent 9834e91c6d
commit 604ec4a50d
3 changed files with 4 additions and 3 deletions

View File

@@ -63,7 +63,7 @@ public class UserAccountsFilter implements Filter {
continue;
}
String username = (String) session.getAttribute("username");
String username = session.getAttribute("username");
if(username == null) {
newSessionAlias = alias;
continue;

View File

@@ -38,8 +38,9 @@ public interface Session {
*
* @param attributeName the name of the attribute to get
* @return the Object associated with the specified name or null if no Object is associated to that name
* @param <T> The return type of the attribute
*/
Object getAttribute(String attributeName);
<T> T getAttribute(String attributeName);
/**
* Gets the attribute names that have a value associated with it. Each value can be passed into {@link org.springframework.session.Session#getAttribute(String)} to obtain the attribute value.

View File

@@ -121,7 +121,7 @@ import org.springframework.session.Session;
* continue;
* }
*
* String username = (String) session.getAttribute("username");
* String username = session.getAttribute("username");
* if(username == null) {
* newSessionAlias = alias;
* continue;