import net.pterodactylus.util.service.AbstractService;
import net.pterodactylus.util.thread.NamedThreadFactory;
+import com.google.common.base.Function;
import freenet.keys.FreenetURI;
import com.google.common.base.Optional;
}
@Override
+ public Function<String, Optional<Sone>> getSone() {
+ return database.getSone();
+ }
+
+ @Override
public Optional<Sone> getSone(String id) {
synchronized (sones) {
return Optional.fromNullable(sones.get(id));
import net.pterodactylus.sone.data.Sone;
+import com.google.common.base.Function;
import com.google.common.base.Optional;
/**
*/
public interface SoneProvider {
+ Function<String, Optional<Sone>> getSone();
+
/**
* Returns the Sone with the given ID, or {@link Optional#absent()} if it
* does not exist.
}
@Override
+ public Function<String, Optional<Sone>> getSone() {
+ return new Function<String, Optional<Sone>>() {
+ @Override
+ public Optional<Sone> apply(String soneId) {
+ return (soneId == null) ? Optional.<Sone>absent() : getSone(soneId);
+ }
+ };
+ }
+
+ @Override
public Optional<Sone> getSone(String soneId) {
lock.readLock().lock();
try {