package errorhandler; import ast.type.classes.ErrorType; import java.io.PrintStream; import java.util.ArrayList; import java.util.List; public class ErrorHandler { private static ErrorHandler singleton; private List<ErrorType> errors; private ErrorHandler() { this.errors = new ArrayList<>(); } public static ErrorHandler getInstance() { if (singleton == null) { singleton = new ErrorHandler(); } return singleton; } public void addError(ErrorType errorType) { this.errors.add(errorType); } public void showErrors(PrintStream out) { getErrors().forEach(out::println); } public boolean anyError() { return getErrors().size() > 0; } public List<ErrorType> getErrors() { return this.errors; } public void setErrors(List<ErrorType> errors) { this.errors = errors; } }