import net.pterodactylus.util.template.Template;
import net.pterodactylus.util.template.TemplateContext;
+import com.google.common.base.Optional;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.collect.Collections2;
templateContext.set("sort", sortField);
templateContext.set("order", sortOrder);
templateContext.set("filter", filter);
- final Sone currentSone = getCurrentSone(request.getToadletContext(), false);
+ final Optional<Sone> currentSone = getCurrentSone(request.getToadletContext(), false);
Collection<Sone> knownSones = Collections2.filter(webInterface.getCore().getSones(), Sone.EMPTY_SONE_FILTER);
- if ((currentSone != null) && "followed".equals(filter)) {
+ if (currentSone.isPresent() && "followed".equals(filter)) {
knownSones = Collections2.filter(knownSones, new Predicate<Sone>() {
@Override
public boolean apply(Sone sone) {
- return currentSone.hasFriend(sone.getId());
+ return currentSone.get().hasFriend(sone.getId());
}
});
- } else if ((currentSone != null) && "not-followed".equals(filter)) {
+ } else if (currentSone.isPresent() && "not-followed".equals(filter)) {
knownSones = Collections2.filter(knownSones, new Predicate<Sone>() {
@Override
public boolean apply(Sone sone) {
- return !currentSone.hasFriend(sone.getId());
+ return !currentSone.get().hasFriend(sone.getId());
}
});
} else if ("new".equals(filter)) {