Minimized calls to getDefaultValue

This commit is contained in:
Erik C. Thauvin 2023-03-22 04:04:22 -07:00
parent 9d3452304c
commit 4e3f021ec3
7 changed files with 31 additions and 27 deletions

View file

@ -46,10 +46,11 @@ public class Abbreviate implements ValueRenderer {
public String render(Template template, String valueId, String differentiator) {
var mark = "...";
var max = -1;
if (template.hasDefaultValue(valueId)) {
var defaultValue = template.getDefaultValue(valueId);
if (defaultValue != null) {
var properties = new Properties();
try {
properties.load(new StringReader(template.getDefaultValue(valueId)));
properties.load(new StringReader(defaultValue));
mark = properties.getProperty("mark", mark);
max = Integer.parseInt(properties.getProperty("max", String.valueOf(max)));
} catch (IOException | NumberFormatException ignore) {