<artifactId>jackson-databind</artifactId>
<version>2.1.2</version>
</dependency>
+ <dependency>
+ <groupId>com.google.code.findbugs</groupId>
+ <artifactId>jsr305</artifactId>
+ <version>2.0.1</version>
+ </dependency>
</dependencies>
<repositories>
<repository>
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import static java.util.Arrays.asList;
+import static java.util.Collections.emptyList;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
+import javax.annotation.Nonnull;
import com.google.common.base.Function;
import com.google.common.base.Optional;
public static final Function<Album, List<Album>> FLATTENER = new Function<Album, List<Album>>() {
@Override
+ @Nonnull
public List<Album> apply(Album album) {
+ if (album == null) {
+ return emptyList();
+ }
List<Album> albums = new ArrayList<Album>();
albums.add(album);
for (Album subAlbum : album.getAlbums()) {
public static final Function<Album, List<Image>> IMAGES = new Function<Album, List<Image>>() {
@Override
+ @Nonnull
public List<Image> apply(Album album) {
- return album.getImages();
+ return (album != null) ? album.getImages() : Collections.<Image>emptyList();
}
};
package net.pterodactylus.sone.data;
+import javax.annotation.Nonnull;
+
import com.google.common.base.Function;
import com.google.common.base.Optional;
public static final Function<Optional<? extends Identified>, Optional<String>> GET_ID = new Function<Optional<? extends Identified>, Optional<String>>() {
@Override
+ @Nonnull
public Optional<String> apply(Optional<? extends Identified> identified) {
- return identified.isPresent() ? Optional.of(identified.get().getId()) : Optional.<String>absent();
+ return (identified == null) ? Optional.<String>absent() : (identified.isPresent() ? Optional.of(identified.get().getId()) : Optional.<String>absent());
}
};
@Override
public boolean apply(Post post) {
- return post.getTime() <= System.currentTimeMillis();
+ return (post == null) ? false : post.getTime() <= System.currentTimeMillis();
}
};
@Override
public boolean apply(PostReply postReply) {
- return postReply.getPost().isPresent();
+ return (postReply == null) ? false : postReply.getPost().isPresent();
}
};
*/
@Override
public boolean apply(Reply<?> reply) {
- return reply.getTime() <= System.currentTimeMillis();
+ return (reply == null) ? false : reply.getTime() <= System.currentTimeMillis();
}
};
@Override
public boolean apply(Sone sone) {
- return sone.getTime() != 0;
+ return (sone == null) ? false : sone.getTime() != 0;
}
};
@Override
public boolean apply(Sone sone) {
- return sone.getIdentity() instanceof OwnIdentity;
+ return (sone == null) ? false : sone.getIdentity() instanceof OwnIdentity;
}
};
@Override
public boolean apply(Sone sone) {
- return !sone.getRootAlbum().getAlbums().isEmpty();
+ return (sone == null) ? false : !sone.getRootAlbum().getAlbums().isEmpty();
}
};
@Override
public boolean apply(Hit<?> hit) {
- return hit.getScore() > 0;
+ return (hit == null) ? false : hit.getScore() > 0;
}
};