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

org.drools.verifier.alwaysFalse.Patterns.drl Maven / Gradle / Ivy

There is a newer version: 9.44.0.Final
Show newest version
#
# created on: 5.6.2008
#
# Rules in this package look for patterns and rules that can never be satisfied.
#
#
package org.drools.verifier.alwaysFalse
#list any import classes here.
import org.drools.verifier.components.Pattern;
import org.drools.verifier.components.PatternPossibility;
import org.drools.verifier.components.VerifierRule;

import org.drools.verifier.report.components.Severity;
import org.drools.verifier.report.components.MessageType;
import org.drools.verifier.report.components.Incompatibility;
import org.drools.verifier.report.components.VerifierMessage;

import org.drools.verifier.dao.VerifierResult;

global VerifierResult result;

#
# Finds patterns that are always false.
#
# Dependencies: 
#	Needs at least one of the following packages or rules to fire:
# 		package org.drools.verifier.incompatibility;
#			rule "Incompatible LiteralRestrictions with ranges in pattern possibility, impossible equality less or equal"
#			rule "Incompatible LiteralRestrictions with ranges in pattern possibility, impossible equality greater"
#			rule "Incompatible LiteralRestrictions with ranges in pattern possibility, impossible range"
#			rule "Incoherent VariableRestrictions in pattern possibility, impossible range"
#
# Example:
#		Pattern( a == b && a != b )
#
rule "Pattern that is always false"
	when
		$p :Pattern()
		
		# Check that there is at least one pattern possibility.
		exists PatternPossibility( patternId == $p.id )
		
		# All the pattern possibilities for pattern need to be in conflict
		forall( 
			$pp :PatternPossibility(
				patternId == $p.id
			)
			
			Incompatibility( 
				left memberOf $pp.items,
				right memberOf $pp.items
			)
		)
		
		$r :VerifierRule( id == $p.ruleId )
	then 
		# Report an error
		result.add( new VerifierMessage(
								Severity.ERROR,
								MessageType.ALWAYS_FALSE,
								$p,
								$p + " in " + $r + " can never be satisfied." ) );
end




© 2015 - 2025 Weber Informatics LLC | Privacy Policy