X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FWebInterface.java;h=258669af74dc6d292691036e8df12d6b18c041f3;hp=02a5dd50ef81c48d92ce178ed35086e82a41aa77;hb=53a71d1d6b91e4d56af49a06f2e06bc4d11bf3eb;hpb=1a2c9eb50e89d9ba5f9ea9b72721ebfeb68650cd diff --git a/src/main/java/net/pterodactylus/sone/web/WebInterface.java b/src/main/java/net/pterodactylus/sone/web/WebInterface.java index 02a5dd5..258669a 100644 --- a/src/main/java/net/pterodactylus/sone/web/WebInterface.java +++ b/src/main/java/net/pterodactylus/sone/web/WebInterface.java @@ -381,7 +381,7 @@ public class WebInterface { * @return The currently logged in Sone, or {@code null} if no Sone is * currently logged in */ - public Sone getCurrentSone(ToadletContext toadletContext) { + public Optional getCurrentSone(ToadletContext toadletContext) { return getCurrentSone(toadletContext, true); } @@ -396,10 +396,10 @@ public class WebInterface { * @return The currently logged in Sone, or {@code null} if no Sone is * currently logged in */ - public Sone getCurrentSone(ToadletContext toadletContext, boolean createSession) { + public Optional getCurrentSone(ToadletContext toadletContext, boolean createSession) { Collection localSones = getCore().getLocalSones(); if (localSones.size() == 1) { - return localSones.iterator().next(); + return Optional.of(localSones.iterator().next()); } return getCurrentSone(getCurrentSession(toadletContext, createSession)); } @@ -412,15 +412,15 @@ public class WebInterface { * @return The currently logged in Sone, or {@code null} if no Sone is * currently logged in */ - public Sone getCurrentSone(Optional session) { + public Optional getCurrentSone(Optional session) { if (!session.isPresent()) { - return null; + return Optional.absent(); } String soneId = (String) session.get().getAttribute("Sone.CurrentSone"); if (soneId == null) { - return null; + return Optional.absent(); } - return getCore().getLocalSone(soneId); + return Optional.fromNullable(getCore().getLocalSone(soneId)); } /**