@Test public void config_string() { assertEquals("constant foo x 17;\n", stmt_single.configString().toString()); assertEquals("constant foo {\n" + " x 17;\n" + " y 19;\n" + "}\n", stmt_multi.configString().toString()); }
@Override public StringBuilder configString() { StringBuilder result = new StringBuilder() .append("constant ") .append(group_.configString()); if (metrics_.size() == 1) { metrics_.entrySet() .forEach((metric) -> result .append(' ') .append(metric.getKey().configString()) .append(' ') .append(metric.getValue())); result.append(";\n"); } else { Optional<StringBuilder> body = metrics_.entrySet().stream() .sorted(Comparator.comparing(metric -> metric.getKey().configString().toString())) .map((metric) -> new StringBuilder() .append(metric.getKey().configString()) .append(' ') .append(metric.getValue()) .append(';')) .reduce((x, y) -> x.append("\n ").append(y)) .map((s) -> s.insert(0, "\n ")); result .append(" {") .append(body.orElseGet(StringBuilder::new)) .append("\n}\n"); } return result; }
ResolvedConstantStatement implements RuleStatement { @Override public StringBuilder configString() { StringBuilder result = new StringBuilder() .append("constant ") .append(group_.configString()); if (metrics_.size() == 1) { metrics_.entrySet() .forEach((metric) -> result .append(' ') .append(metric.getKey().configString()) .append(' ') .append(metric.getValue())); result.append(";\n"); } else { Optional<StringBuilder> body = metrics_.entrySet().stream() .sorted(Comparator.comparing(metric -> metric.getKey().configString().toString())) .map((metric) -> new StringBuilder() .append(metric.getKey().configString()) .append(' ') .append(metric.getValue()) .append(';')) .reduce((x, y) -> x.append("\n ").append(y)) .map((s) -> s.insert(0, "\n ")); result .append(" {") .append(body.orElseGet(StringBuilder::new)) .append("\n}\n"); } return result; } }
ResolvedConstantStatement implements RuleStatement { @Override public StringBuilder configString() { StringBuilder result = new StringBuilder() .append("constant ") .append(group_.configString()); if (metrics_.size() == 1) { metrics_.entrySet() .forEach((metric) -> result .append(' ') .append(metric.getKey().configString()) .append(' ') .append(metric.getValue())); result.append(";\n"); } else { Optional<StringBuilder> body = metrics_.entrySet().stream() .sorted(Comparator.comparing(metric -> metric.getKey().configString().toString())) .map((metric) -> new StringBuilder() .append(metric.getKey().configString()) .append(' ') .append(metric.getValue()) .append(';')) .reduce((x, y) -> x.append("\n ").append(y)) .map((s) -> s.insert(0, "\n ")); result .append(" {") .append(body.orElseGet(StringBuilder::new)) .append("\n}\n"); } return result; } ResolvedConstantStatement(GroupExpression group, NameResolver metric, MetricValue value);  ResolvedConstantStatement(GroupExpression group, Map<NameResolver, MetricValue> metrics); }
ResolvedConstantStatement implements RuleStatement { @Override public StringBuilder configString() { StringBuilder result = new StringBuilder() .append("constant ") .append(group_.configString()); if (metrics_.size() == 1) { metrics_.entrySet() .forEach((metric) -> result .append(' ') .append(metric.getKey().configString()) .append(' ') .append(metric.getValue())); result.append(";\n"); } else { Optional<StringBuilder> body = metrics_.entrySet().stream() .sorted(Comparator.comparing(metric -> metric.getKey().configString().toString())) .map((metric) -> new StringBuilder() .append(metric.getKey().configString()) .append(' ') .append(metric.getValue()) .append(';')) .reduce((x, y) -> x.append("\n ").append(y)) .map((s) -> s.insert(0, "\n ")); result .append(" {") .append(body.orElseGet(StringBuilder::new)) .append("\n}\n"); } return result; } ResolvedConstantStatement(GroupExpression group, NameResolver metric, MetricValue value);  ResolvedConstantStatement(GroupExpression group, Map<NameResolver, MetricValue> metrics); Map<NameResolver, MetricValue> getMetrics(); @Override TimeSeriesTransformer get(); @Override StringBuilder configString(); @Override int hashCode(); @Override boolean equals(Object obj); }
ResolvedConstantStatement implements RuleStatement { @Override public StringBuilder configString() { StringBuilder result = new StringBuilder() .append("constant ") .append(group_.configString()); if (metrics_.size() == 1) { metrics_.entrySet() .forEach((metric) -> result .append(' ') .append(metric.getKey().configString()) .append(' ') .append(metric.getValue())); result.append(";\n"); } else { Optional<StringBuilder> body = metrics_.entrySet().stream() .sorted(Comparator.comparing(metric -> metric.getKey().configString().toString())) .map((metric) -> new StringBuilder() .append(metric.getKey().configString()) .append(' ') .append(metric.getValue()) .append(';')) .reduce((x, y) -> x.append("\n ").append(y)) .map((s) -> s.insert(0, "\n ")); result .append(" {") .append(body.orElseGet(StringBuilder::new)) .append("\n}\n"); } return result; } ResolvedConstantStatement(GroupExpression group, NameResolver metric, MetricValue value);  ResolvedConstantStatement(GroupExpression group, Map<NameResolver, MetricValue> metrics); Map<NameResolver, MetricValue> getMetrics(); @Override TimeSeriesTransformer get(); @Override StringBuilder configString(); @Override int hashCode(); @Override boolean equals(Object obj);  }