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

org.hisp.dhis.rules.models.RuleEvaluationResult Maven / Gradle / Ivy

package org.hisp.dhis.rules.models;

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

public class RuleEvaluationResult
{

    private Rule rule;

    private List ruleEffects;

    private boolean evaluatedAs;

    private boolean error;

    public static RuleEvaluationResult evaluatedResult(Rule rule, List ruleEffects) {
        return new RuleEvaluationResult( rule, ruleEffects, true, false );
    }

    public static RuleEvaluationResult notEvaluatedResult(Rule rule) {
        return new RuleEvaluationResult( rule, new ArrayList(), false, false );
    }

    public static RuleEvaluationResult errorRule( Rule rule, String errorMessage ) {
        ArrayList effects = new ArrayList<>();

        effects.add(RuleEffect.create(rule.uid(), RuleActionError.create(errorMessage), errorMessage));
        return new RuleEvaluationResult( rule, effects, false, true );
    }

    private RuleEvaluationResult( Rule rule, List ruleEffects, boolean evaluatedAs, boolean error ) {
        this.rule = rule;
        this.ruleEffects = ruleEffects;
        this.evaluatedAs = evaluatedAs;
        this.error = error;
    }

    public Rule getRule() {
        return rule;
    }

    public List getRuleEffects() {
        return ruleEffects;
    }

    public boolean isEvaluatedAs() {
        return evaluatedAs;
    }

    public boolean isError() {
        return error;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy