use of org.drools.core.common.InstanceNotEqualsConstraint in project drools by kiegroup.
the class PatternBuilder method checkRemoveIdentities.
/**
* @param context
* @param pattern
* @param betaConstraints
*/
private void checkRemoveIdentities(final BuildContext context, final Pattern pattern, final List<BetaNodeFieldConstraint> betaConstraints) {
if (context.getKnowledgeBase().getConfiguration().isRemoveIdentities() && pattern.getObjectType().getClass() == ClassObjectType.class) {
// Check if this object type exists before
// If it does we need stop instance equals cross product
final Class<?> thisClass = ((ClassObjectType) pattern.getObjectType()).getClassType();
for (final Pattern previousPattern : context.getObjectType()) {
final Class<?> previousClass = ((ClassObjectType) previousPattern.getObjectType()).getClassType();
if (thisClass.isAssignableFrom(previousClass)) {
betaConstraints.add(new InstanceNotEqualsConstraint(previousPattern));
}
}
// Must be added after the checking, otherwise it matches against itself
context.getObjectType().add(pattern);
}
}
Aggregations