com.hubspot.jinjava.interpret.RenderResult Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jinjava Show documentation
Show all versions of jinjava Show documentation
Jinja templating engine implemented in Java
The newest version!
package com.hubspot.jinjava.interpret;
import com.google.common.collect.ImmutableList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
public class RenderResult {
private final String output;
private final Context context;
private final List errors;
public RenderResult(String output, Context context, List errors) {
this.output = output;
this.context = context;
this.errors = errors;
}
public RenderResult(
TemplateError fromException,
Context context,
List errors
) {
this.output = "";
this.context = context;
this.errors =
ImmutableList
.builder()
.add(fromException)
.addAll(Optional.ofNullable(errors).orElse(Collections.emptyList()))
.build();
}
public RenderResult(String result) {
this.output = result;
this.context = null;
this.errors = Collections.emptyList();
}
public boolean hasErrors() {
return !errors.isEmpty();
}
public List getErrors() {
return errors;
}
public Context getContext() {
return context;
}
public String getOutput() {
return output;
}
public RenderResult withOutput(String newOutput) {
return new RenderResult(newOutput, getContext(), getErrors());
}
}