Source:
protected void createRuleToConstraintWeightExtractorMap(KieBase kieBase) { ConstraintConfigurationDescriptor<Solution_> constraintConfigurationDescriptor = solutionDescriptor.getConstraintConfigurationDescriptor(); if (constraintConfigurationDescriptor == null) { ruleToConstraintWeightExtractorMap = new LinkedHashMap<>(0); return; } Collection<ConstraintWeightDescriptor<Solution_>> constraintWeightDescriptors = constraintConfigurationDescriptor.getConstraintWeightDescriptors(); ruleToConstraintWeightExtractorMap = new LinkedHashMap<>(constraintWeightDescriptors.size()); for (ConstraintWeightDescriptor<Solution_> constraintWeightDescriptor : constraintWeightDescriptors) { String constraintPackage = constraintWeightDescriptor.getConstraintPackage(); String constraintName = constraintWeightDescriptor.getConstraintName(); Rule rule = kieBase.getRule(constraintPackage, constraintName); if (rule == null) { Rule potentialRule = kieBase.getKiePackages().stream().flatMap(kiePackage -> kiePackage.getRules().stream()) .filter(selectedRule -> selectedRule.getName().equals(constraintName)).findFirst().orElse(null); throw new IllegalStateException("The constraintConfigurationClass (" + constraintConfigurationDescriptor.getConstraintConfigurationClass() + ") has a " + ConstraintWeight.class.getSimpleName() + " annotated member (" + constraintWeightDescriptor.getMemberAccessor() + ") with constraintPackage/rulePackage (" + constraintPackage + ") and constraintName/ruleName (" + constraintName + ") for which no Drools rule exist in the DRL.\n" + (potentialRule != null ? "Maybe the constraintPackage (" + constraintPackage + ") is wrong," + " because there is a rule with the same ruleName (" + constraintName + "), but in a different rulePackage (" + rule.getPackageName() + ")." : "Maybe there is a typo in the constraintName (" + constraintName + ") so it not identical to the constraint's ruleName.")); } ruleToConstraintWeightExtractorMap.put(rule, constraintWeightDescriptor.createExtractionFunction()); } }

Target:
protected void createRuleToConstraintWeightExtractorMap(KieBase kieBase) { ConstraintConfigurationDescriptor<Solution_> constraintConfigurationDescriptor = solutionDescriptor.getConstraintConfigurationDescriptor(); if (constraintConfigurationDescriptor == null) { ruleToConstraintWeightExtractorMap = new LinkedHashMap<>(0); return; } Collection<ConstraintWeightDescriptor<Solution_>> constraintWeightDescriptors = constraintConfigurationDescriptor.getConstraintWeightDescriptors(); ruleToConstraintWeightExtractorMap = new LinkedHashMap<>(constraintWeightDescriptors.size()); for (ConstraintWeightDescriptor<Solution_> constraintWeightDescriptor : constraintWeightDescriptors) { String constraintPackage = constraintWeightDescriptor.getConstraintPackage(); String constraintName = constraintWeightDescriptor.getConstraintName(); Rule rule = kieBase.getRule(constraintPackage, constraintName); if (rule == null) { Rule potentialRule = kieBase.getKiePackages().stream().flatMap(kiePackage -> kiePackage.getRules().stream()) .filter(selectedRule -> selectedRule.getName().equals(constraintName)).findFirst().orElse(null); throw new IllegalStateException("The constraintConfigurationClass (" + constraintConfigurationDescriptor.getConstraintConfigurationClass() + ") has a " + ConstraintWeight.class.getSimpleName() + " annotated member (" + constraintWeightDescriptor.getMemberAccessor() + ") with constraintPackage/rulePackage (" + constraintPackage + ") and constraintName/ruleName (" + constraintName + ") for which no Drools rule exist in the DRL.\n" + (potentialRule != null ? "Maybe the constraintPackage (" + constraintPackage + ") is wrong," + " because there is a rule with the same ruleName (" + constraintName + "), but in a different rulePackage (" + potentialRule.getPackageName() + ")." : "Maybe there is a typo in the constraintName (" + constraintName + ") so it not identical to the constraint's ruleName.")); } ruleToConstraintWeightExtractorMap.put(rule, constraintWeightDescriptor.createExtractionFunction()); } }