From: David ‘Bombe’ Roden Date: Thu, 17 Jan 2013 14:29:23 +0000 (+0100) Subject: Replace utils’ Default with Guava’s Optional. X-Git-Tag: 0.8.5^2~3^2~69 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=06ae2e6649e61e3e3bff71690caa0e98e4ac01ba;p=Sone.git Replace utils’ Default with Guava’s Optional. --- 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);