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

com.imsweb.validation.internal.callable.RuleCompilingCallable Maven / Gradle / Ivy

There is a newer version: 021-11
Show newest version
/*
 * Copyright (C) 2015 Information Management Services, Inc.
 */
package com.imsweb.validation.internal.callable;

import com.imsweb.validation.InitializationStats;
import com.imsweb.validation.entities.Rule;
import com.imsweb.validation.internal.ExecutableRule;
import com.imsweb.validation.runtime.CompiledRules;

import java.util.Map;
import java.util.concurrent.Callable;

/**
 * This class is used to multi-thread the compilation of the rules.
 */
public class RuleCompilingCallable implements Callable {

    /**
     * Rule to compile.
     */
    private Rule _rule;

    /**
     * Collection of compiled rules.
     */
    private Map _rules;

    /**
     * Pre-compile rules (can be null).
     */
    private CompiledRules _compiledRules;

    /**
     * Initialization stats.
     */
    private InitializationStats _stats;

    /**
     * Constructor.
     * @param rule rule to compile
     * @param rules collection of compiled rules
     */
    public RuleCompilingCallable(Rule rule, Map rules, CompiledRules compiledRules, InitializationStats stats) {
        _rule = rule;
        _rules = rules;
        _compiledRules = compiledRules;
        _stats = stats;
    }

    @Override
    public Void call() throws Exception {
        _rules.put(_rule.getRuleId(), new ExecutableRule(_rule, _compiledRules, _stats));
        return null;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy