All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jbpm.migration.ErrorCollector Maven / Gradle / Ivy

The newest version!
package org.jbpm.migration;

import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;

/** Convenience class for making the error handling within the parsing and validation processes a little more verbose. */
abstract class ErrorCollector {
    private final List warningList = new ArrayList();
    private final List errorList = new ArrayList();
    private final List fatalList = new ArrayList();

    public void warning(final T ex) {
        warningList.add(ex);
    }

    public void error(final T ex) {
        errorList.add(ex);
    }

    public void fatalError(final T ex) {
        fatalList.add(ex);
    }

    public boolean didErrorOccur() {
        // checking warnings might be too restrictive
        return !warningList.isEmpty() || !errorList.isEmpty() || !fatalList.isEmpty();
    }

    public List getWarningList() {
        return warningList;
    }

    public List getErrorList() {
        return errorList;
    }

    public List getFatalList() {
        return fatalList;
    }

    public void logErrors(final Logger logger) {
        for (final T ex : warningList) {
            logger.warn("==>", ex);
        }
        for (final T ex : errorList) {
            logger.error("==>", ex);
        }
        for (final T ex : fatalList) {
            logger.fatal("==>", ex);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy