From 06ae2e6649e61e3e3bff71690caa0e98e4ac01ba Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 17 Jan 2013 15:29:23 +0100 Subject: [PATCH] =?utf8?q?Replace=20utils=E2=80=99=20Default=20with=20Guav?= =?utf8?q?a=E2=80=99s=20Optional.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/main/java/net/pterodactylus/sone/data/Album.java | 5 ++--- src/main/java/net/pterodactylus/sone/template/ImageLinkFilter.java | 7 ++++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/data/Album.java b/src/main/java/net/pterodactylus/sone/data/Album.java index f27251b..c1ae267 100644 --- a/src/main/java/net/pterodactylus/sone/data/Album.java +++ b/src/main/java/net/pterodactylus/sone/data/Album.java @@ -28,9 +28,8 @@ import java.util.List; import java.util.Map; import java.util.UUID; -import net.pterodactylus.util.object.Default; - import com.google.common.base.Function; +import com.google.common.base.Optional; import com.google.common.base.Predicates; import com.google.common.collect.Collections2; @@ -330,7 +329,7 @@ public class Album implements Fingerprintable { if (albumImage == null) { return null; } - return Default.forNull(images.get(albumImage), images.values().iterator().next()); + return Optional.fromNullable(images.get(albumImage)).or(images.values().iterator().next()); } /** diff --git a/src/main/java/net/pterodactylus/sone/template/ImageLinkFilter.java b/src/main/java/net/pterodactylus/sone/template/ImageLinkFilter.java index 9b14882..7e3723c 100644 --- a/src/main/java/net/pterodactylus/sone/template/ImageLinkFilter.java +++ b/src/main/java/net/pterodactylus/sone/template/ImageLinkFilter.java @@ -24,13 +24,14 @@ import java.util.Map; import net.pterodactylus.sone.core.Core; import net.pterodactylus.sone.data.Image; import net.pterodactylus.util.number.Numbers; -import net.pterodactylus.util.object.Default; import net.pterodactylus.util.template.Filter; import net.pterodactylus.util.template.Template; import net.pterodactylus.util.template.TemplateContext; import net.pterodactylus.util.template.TemplateContextFactory; import net.pterodactylus.util.template.TemplateParser; +import com.google.common.base.Optional; + /** * Template filter that turns an {@link Image} into an HTML <img> tag, * using some parameters to influence parameters of the image. @@ -105,8 +106,8 @@ public class ImageLinkFilter implements Filter { linkTemplateContext.set("width", (int) (imageWidth * scale + 0.5)); linkTemplateContext.set("height", (int) (imageHeight * scale + 0.5)); } - linkTemplateContext.set("alt", Default.forNull(title, image.getDescription())); - linkTemplateContext.set("title", Default.forNull(title, image.getTitle())); + linkTemplateContext.set("alt", Optional.fromNullable(title).or(image.getDescription())); + linkTemplateContext.set("title", Optional.fromNullable(title).or(image.getTitle())); StringWriter stringWriter = new StringWriter(); linkTemplate.render(linkTemplateContext, stringWriter); -- 2.7.4