Fix some FindBugs warnings.
[Sone.git] / src / main / java / net / pterodactylus / sone / data / Identified.java
index f12f842..4892479 100644 (file)
@@ -17,6 +17,8 @@
 
 package net.pterodactylus.sone.data;
 
+import javax.annotation.Nonnull;
+
 import com.google.common.base.Function;
 import com.google.common.base.Optional;
 
@@ -31,8 +33,9 @@ public interface Identified {
        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());
                }
        };