From: David ‘Bombe’ Roden Date: Sat, 12 Oct 2013 15:30:43 +0000 (+0200) Subject: Don’t apply function to optionals. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=d39e39ed52c231bd7331c4b2da8e55ffbed081f5;p=Sone.git Don’t apply function to optionals. --- diff --git a/src/main/java/net/pterodactylus/sone/data/Identified.java b/src/main/java/net/pterodactylus/sone/data/Identified.java index 4892479..bd1a91f 100644 --- a/src/main/java/net/pterodactylus/sone/data/Identified.java +++ b/src/main/java/net/pterodactylus/sone/data/Identified.java @@ -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> GET_ID = new Function, Optional>() { + public static final Function GET_ID = new Function() { @Override @Nonnull - public Optional apply(Optional identified) { - return (identified == null) ? Optional.absent() : (identified.isPresent() ? Optional.of(identified.get().getId()) : Optional.absent()); + public String apply(Identified identified) { + return (identified == null) ? null : identified.getId(); } };