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

org.drools.impl.adapters.KnowledgePackageAdapter Maven / Gradle / Ivy

Go to download

The Drools and jBPM public API which is backwards compatible between releases.

There is a newer version: 6.5.0.Final
Show newest version
package org.drools.impl.adapters;

import org.drools.definition.process.Process;
import org.drools.definition.rule.Global;
import org.drools.definition.rule.Query;
import org.drools.definition.rule.Rule;
import org.drools.definition.type.FactType;
import org.kie.internal.definition.KnowledgePackage;

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

import static org.drools.impl.adapters.FactTypeAdapter.adaptFactTypes;
import static org.drools.impl.adapters.GlobalAdapter.adaptGlobals;
import static org.drools.impl.adapters.ProcessAdapter.adaptProcesses;
import static org.drools.impl.adapters.QueryAdapter.adaptQueries;
import static org.drools.impl.adapters.RuleAdapter.adaptRules;

public class KnowledgePackageAdapter implements org.drools.definition.KnowledgePackage {

    private final KnowledgePackage delegate;

    public KnowledgePackageAdapter(KnowledgePackage delegate) {
        this.delegate = delegate;
    }

    public String getName() {
        return delegate.getName();
    }

    public Collection getRules() {
        return adaptRules(delegate.getRules());
    }

    public Collection getProcesses() {
        return adaptProcesses(delegate.getProcesses());
    }

    public Collection getFactTypes() {
        return adaptFactTypes(delegate.getFactTypes());
    }

    public Collection getQueries() {
        return adaptQueries(delegate.getQueries());
    }

    public Collection getFunctionNames() {
        return delegate.getFunctionNames();
    }

    public Collection getGlobalVariables() {
        return adaptGlobals(delegate.getGlobalVariables());
    }

    public KnowledgePackage getDelegate() {
        return delegate;
    }

    public static List adaptKnowledgePackages(Collection pkgs) {
        List result = new ArrayList();
        for (KnowledgePackage pkg : pkgs) {
            result.add(new KnowledgePackageAdapter(pkg));
        }
        return result;
    }

    public static Collection fromKiePackages(Collection pkgs) {
        List result = new ArrayList();
        for (org.drools.definition.KnowledgePackage pkg : pkgs) {
            result.add(((KnowledgePackageAdapter)pkg).getDelegate());
        }
        return result;
    }

    @Override
    public int hashCode() {
        return delegate.hashCode();
    }

    @Override
    public boolean equals(Object obj) {
        return obj instanceof KnowledgePackageAdapter && delegate.equals(((KnowledgePackageAdapter)obj).delegate);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy