projects
/
Sone.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Change dates in file headers
[Sone.git]
/
src
/
main
/
java
/
net
/
pterodactylus
/
sone
/
template
/
ImageLinkFilter.java
diff --git
a/src/main/java/net/pterodactylus/sone/template/ImageLinkFilter.java
b/src/main/java/net/pterodactylus/sone/template/ImageLinkFilter.java
index
9ede851
..
2f1526f
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/template/ImageLinkFilter.java
+++ b/
src/main/java/net/pterodactylus/sone/template/ImageLinkFilter.java
@@
-1,5
+1,5
@@
/*
/*
- * Sone - ImageLinkFilter.java - Copyright © 2011–201
3
David Roden
+ * Sone - ImageLinkFilter.java - Copyright © 2011–201
6
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
*
* 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
@@
-33,6
+33,7
@@
import net.pterodactylus.util.template.TemplateContext;
import net.pterodactylus.util.template.TemplateContextFactory;
import net.pterodactylus.util.template.TemplateParser;
import net.pterodactylus.util.template.TemplateContextFactory;
import net.pterodactylus.util.template.TemplateParser;
+import com.google.common.base.Function;
import com.google.common.base.Optional;
/**
import com.google.common.base.Optional;
/**
@@
-79,11
+80,11
@@
public class ImageLinkFilter implements Filter {
if (image == null) {
return null;
}
if (image == null) {
return null;
}
- String imageClass =
valueOf(parameters.get("class")
);
+ 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"));
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"));
- String title =
valueOf(parameters.get("title")
);
+ String title =
Optional.fromNullable(parameters.get("title")).transform(getStringValue()).orNull(
);
TemplateContext linkTemplateContext = templateContextFactory.createTemplateContext();
linkTemplateContext.set("class", imageClass);
TemplateContext linkTemplateContext = templateContextFactory.createTemplateContext();
linkTemplateContext.set("class", imageClass);
@@
-117,4
+118,13
@@
public class ImageLinkFilter implements Filter {
return stringWriter.toString();
}
return stringWriter.toString();
}
+ private Function<Object, String> getStringValue() {
+ return new Function<Object, String>() {
+ @Override
+ public String apply(Object input) {
+ return (input != null) ? input.toString() : null;
+ }
+ };
+ }
+
}
}