org.drools.impl.adapters.KnowledgePackageAdapter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of knowledge-api Show documentation
Show all versions of knowledge-api Show documentation
The Drools and jBPM public API which is backwards compatible between releases.
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