* @return The currently logged in Sone, or {@code null} if no Sone is
* currently logged in
*/
- public Sone getCurrentSone(ToadletContext toadletContext) {
+ public Optional<Sone> getCurrentSone(ToadletContext toadletContext) {
return getCurrentSone(toadletContext, true);
}
* @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<Sone> getCurrentSone(ToadletContext toadletContext, boolean createSession) {
Collection<Sone> localSones = getCore().getLocalSones();
if (localSones.size() == 1) {
- return localSones.iterator().next();
+ return Optional.of(localSones.iterator().next());
}
return getCurrentSone(getCurrentSession(toadletContext, createSession));
}
* @return The currently logged in Sone, or {@code null} if no Sone is
* currently logged in
*/
- public Sone getCurrentSone(Optional<Session> session) {
+ public Optional<Sone> getCurrentSone(Optional<Session> 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));
}
/**