+ /** Filter that matches all {@link Sone#isLocal() local Sones}. */
+ public static final Predicate<Sone> LOCAL_SONE_FILTER = new Predicate<Sone>() {
+
+ @Override
+ public boolean apply(Sone sone) {
+ return (sone == null) ? false : sone.isLocal();
+ }
+
+ };
+
+ /** Filter that matches Sones that have at least one album. */
+ public static final Predicate<Sone> HAS_ALBUM_FILTER = new Predicate<Sone>() {
+
+ @Override
+ public boolean apply(Sone sone) {
+ return (sone == null) ? false : !sone.getRootAlbum().getAlbums().isEmpty();
+ }
+ };
+
+ public static final Function<Sone, FreenetURI> TO_FREENET_URI = new Function<Sone, FreenetURI>() {
+ @Override
+ public FreenetURI apply(Sone sone) {
+ return (sone == null) ? null : create(sone.getIdentity().getRequestUri());
+ }
+ };
+
+ public static final Function<Sone, FreenetURI> TO_INSERT_URI = new Function<Sone, FreenetURI>() {
+ @Override
+ public FreenetURI apply(@Nullable Sone sone) {
+ return ((sone == null) || !sone.isLocal()) ? null : create(((OwnIdentity) sone.getIdentity()).getInsertUri());
+ }
+ };
+
+ public static final Function<Sone, List<Post>> TO_POSTS = new Function<Sone, List<Post>>() {
+ @Override
+ public List<Post> apply(Sone sone) {
+ return (sone == null) ? Collections.<Post>emptyList() : sone.getPosts();
+ }
+ };