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

com.github.sebhoss.reguloj.LimitedRuleEngine Maven / Gradle / Ivy

The newest version!
/*
 * Copyright © 2010 Sebastian Hoß 
 * This work is free. You can redistribute it and/or modify it under the
 * terms of the Do What The Fuck You Want To Public License, Version 2,
 * as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.
 */
package com.github.sebhoss.reguloj;

import java.util.Collection;

final class LimitedRuleEngine> extends AbstractRuleEngine {

    private final int maximumNumberOfRuns;

    LimitedRuleEngine(final int maximumNumberOfRuns) {
        this.maximumNumberOfRuns = maximumNumberOfRuns;
    }

    @Override
    public void infer(final Collection> rules, final CONTEXT context) {
        int currentRuns = 0;
        while (analyze(rules, context)) {
            performSinglePass(rules, context);

            if (++currentRuns >= maximumNumberOfRuns) {
                break;
            }
        }
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy