Replace AbstractSoneCommand with Kotlin version
[Sone.git] / src / main / java / net / pterodactylus / sone / data / Identified.java
index f12f842..12e1b72 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Sone - Identified.java - Copyright © 2013 David Roden
+ * Sone - Identified.java - Copyright © 2013–2016 David Roden
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
 
 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.
- *
- * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
  */
 public interface Identified {
 
@@ -31,8 +31,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());
                }
        };