/*
- * 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;
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());
}
};