Don’t apply function to optionals.
[Sone.git] / src / main / java / net / pterodactylus / sone / data / Identified.java
index f12f842..bd1a91f 100644 (file)
@@ -17,8 +17,9 @@
 
 package net.pterodactylus.sone.data;
 
+import javax.annotation.Nonnull;
+
 import com.google.common.base.Function;
-import com.google.common.base.Optional;
 
 /**
  * Interface for all objects that expose an ID.
@@ -28,11 +29,12 @@ import com.google.common.base.Optional;
 public interface Identified {
 
        /** Function to extract the ID from an optional. */
-       public static final Function<Optional<? extends Identified>, Optional<String>> GET_ID = new Function<Optional<? extends Identified>, Optional<String>>() {
+       public static final Function<Identified, String> GET_ID = new Function<Identified, String>() {
 
                @Override
-               public Optional<String> apply(Optional<? extends Identified> identified) {
-                       return identified.isPresent() ? Optional.of(identified.get().getId()) : Optional.<String>absent();
+               @Nonnull
+               public String apply(Identified identified) {
+                       return (identified == null) ? null : identified.getId();
                }
        };