PackageRegistry clonePackage(ClassLoader classLoader) {
InternalKnowledgePackage clonedPkg = ClassUtils.deepClone(pkg, classLoader);
clonedPkg.setDialectRuntimeRegistry(pkg.getDialectRuntimeRegistry());
for (org.kie.api.definition.rule.Rule rule : pkg.getRules()) {
RuleImpl clonedRule = clonedPkg.getRule(rule.getName());
clonedRule.setConsequence(((RuleImpl)rule).getConsequence());
if (((RuleImpl)rule).hasNamedConsequences()) {
for (Map.Entry<String, Consequence> namedConsequence : ((RuleImpl)rule).getNamedConsequences().entrySet()) {
clonedRule.addNamedConsequence(namedConsequence.getKey(), namedConsequence.getValue());
}
}
}
PackageRegistry clone = new PackageRegistry(clonedPkg, dialectRuntimeRegistry, dialectCompiletimeRegistry, typeResolver);