From e82fde025dfc0b52c3d96711bc9a4d779e002d6d Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 24 Jul 2015 06:30:58 +0200 Subject: [PATCH] Extract function for toString() function --- .../net/pterodactylus/sone/template/ImageLinkFilter.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/template/ImageLinkFilter.java b/src/main/java/net/pterodactylus/sone/template/ImageLinkFilter.java index 458d40f..1ac7360 100644 --- a/src/main/java/net/pterodactylus/sone/template/ImageLinkFilter.java +++ b/src/main/java/net/pterodactylus/sone/template/ImageLinkFilter.java @@ -80,12 +80,7 @@ public class ImageLinkFilter implements Filter { if (image == null) { return null; } - String imageClass = Optional.fromNullable(parameters.get("class")).transform(new Function() { - @Override - public String apply(Object input) { - return (input != null) ? input.toString() : null; - } - }).orNull(); + String imageClass = Optional.fromNullable(parameters.get("class")).transform(getStringValue()).orNull(); int maxWidth = parseInt(valueOf(parameters.get("max-width")), MAX_VALUE); int maxHeight = parseInt(valueOf(parameters.get("max-height")), MAX_VALUE); String mode = valueOf(parameters.get("mode")); @@ -123,4 +118,13 @@ public class ImageLinkFilter implements Filter { return stringWriter.toString(); } + private Function getStringValue() { + return new Function() { + @Override + public String apply(Object input) { + return (input != null) ? input.toString() : null; + } + }; + } + } -- 2.7.4