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

de.tsl2.nano.incubation.specification.rules.RulePool Maven / Gradle / Ivy

Go to download

TSL2 Framework Specification (Pools of descripted and runnable Actions and Rules, Generic Tree)

There is a newer version: 2.5.1
Show newest version
/*
 * File: $HeadURL$
 * Id  : $Id$
 * 
 * created by: Tom, Thomas Schneider
 * created on: 01.12.2013
 * 
 * Copyright: (c) Thomas Schneider 2013, all rights reserved
 */
package de.tsl2.nano.incubation.specification.rules;

import de.tsl2.nano.incubation.specification.Pool;

/**
 * Holds all defined rules. Reading existing rules from directory.
 * 
 * @author Tom, Thomas Schneider
 * @version $Revision$
 */
public class RulePool extends Pool> {
    
    static {
        Pool.registerPool(RulePool.class);
    }
    /**
     * constructor
     */
    public RulePool() {
        super();
    }

    @Override
    protected String getFileName(String name) {
        //cut optional rule prefix
        name = name.matches("\\w+.*") ? name : name.substring(1);
        return super.getFileName(name);
    }
    @Override
    public AbstractRule get(String name) {
        Class type;
        if (name.startsWith(String.valueOf(RuleScript.PREFIX))) {
            type = RuleScript.class;
            name = name.substring(1);
        } else if (name.startsWith(String.valueOf(RuleDecisionTable.PREFIX))) {
                type = RuleDecisionTable.class;
                name = name.substring(1);
        } else {
            type = Rule.class;
            if (name.startsWith(String.valueOf(AbstractRule.PREFIX)))
                name = name.substring(1);
        }
        return super.get(name, type);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy