Don’t apply function to optionals.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 12 Oct 2013 15:30:43 +0000 (17:30 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 28 Feb 2014 21:25:24 +0000 (22:25 +0100)
src/main/java/net/pterodactylus/sone/data/Identified.java

index 4892479..bd1a91f 100644 (file)
@@ -20,7 +20,6 @@ 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.
@@ -30,12 +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
                @Nonnull
-               public Optional<String> apply(Optional<? extends Identified> identified) {
-                       return (identified == null) ? Optional.<String>absent() : (identified.isPresent() ? Optional.of(identified.get().getId()) : Optional.<String>absent());
+               public String apply(Identified identified) {
+                       return (identified == null) ? null : identified.getId();
                }
        };