package net.pterodactylus.sone.template;
+import static java.lang.Integer.MAX_VALUE;
+import static java.lang.String.valueOf;
+import static net.pterodactylus.sone.utils.NumberParsers.parseInt;
+
import java.io.StringReader;
import java.io.StringWriter;
import java.util.Map;
import net.pterodactylus.util.template.TemplateParser;
import com.google.common.base.Optional;
-import com.google.common.primitives.Ints;
/**
* Template filter that turns an {@link Image} into an HTML <img> tag,
if (image == null) {
return null;
}
- String imageClass = String.valueOf(parameters.get("class"));
- int maxWidth = Optional.fromNullable(Ints.tryParse(String.valueOf(parameters.get("max-width")))).or(Integer.MAX_VALUE);
- int maxHeight = Optional.fromNullable(Ints.tryParse(String.valueOf(parameters.get("max-height")))).or(Integer.MAX_VALUE);
- String mode = String.valueOf(parameters.get("mode"));
- String title = String.valueOf(parameters.get("title"));
+ String imageClass = valueOf(parameters.get("class"));
+ 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"));
TemplateContext linkTemplateContext = templateContextFactory.createTemplateContext();
linkTemplateContext.set("class", imageClass);