org.drools.verifier.rangeChecks.Doubles.drl Maven / Gradle / Ivy
#created on: 7.6.2007
package org.drools.verifier.rangeChecks.doubles;
#list any import classes here.
import org.drools.base.evaluators.Operator;
import org.drools.verifier.components.*;
import org.drools.verifier.report.components.Gap;
import org.drools.verifier.dao.VerifierResult;
#declare any global variables here
global VerifierResult result;
# If all ranges are not checked for a field.
#
# Type: Warning
# Dependencies: None
# Example: in "Rule 1" Foo( bar > 42 )
# and in Foo( <= 42 || == 42 ) is missing.
#
rule "Range check for doubles, if smaller than or equal is missing"
when
$f :Field( fieldType == Field.FieldType.DOUBLE )
# Foo( bar > 42 )
$r :LiteralRestriction(
fieldId == $f.id,
operator == Operator.GREATER
)
# Check if Foo( bar == 42 || <= 42 ) is missing.
not LiteralRestriction(
fieldId == $f.id,
( operator == Operator.EQUAL || == Operator.LESS_OR_EQUAL ),
patternIsNot == $r.patternIsNot,
doubleValue == $r.doubleValue
)
then
Gap gap = new Gap( $f, Operator.LESS_OR_EQUAL, $r );
result.add( gap );
insert( gap );
end
# If all ranges are not checked for a field.
#
# Type: Warning
# Dependencies: None
# Example: in "Rule 1" Foo( bar < 42 )
# and in Foo( >= 42 || == 42 ) is missing.
#
rule "Range check for doubles, if greater than or equal is missing"
when
$f :Field( fieldType == Field.FieldType.DOUBLE )
# Foo( bar > 42 )
$r :LiteralRestriction(
fieldId == $f.id,
operator == Operator.LESS
)
# Check if Foo( bar == 42 || <= 42 ) is missing.
not LiteralRestriction(
fieldId == $f.id,
( operator == Operator.EQUAL || == Operator.GREATER_OR_EQUAL ),
patternIsNot == $r.patternIsNot,
doubleValue == $r.doubleValue
)
then
Gap gap = new Gap( $f, Operator.GREATER_OR_EQUAL, $r );
result.add( gap );
insert( gap );
end
# If all ranges are not checked for a field.
#
# Type: Warning
# Dependencies: None
# Example: in "Rule 1" Foo( bar == 42 || bar <= 42 )
# and no Foo( bar > 42 || >= 42 || >= 43 || == 43 )
# then Foo( bar > 42 ) is missing.
#
rule "Range check for doubles, equal and greater than"
when
$f :Field( fieldType == Field.FieldType.DOUBLE )
# Foo( bar == 42 )
$r :LiteralRestriction(
fieldId == $f.id,
( operator == Operator.EQUAL || == Operator.LESS_OR_EQUAL )
)
# Check if Foo( bar > 42 || >= 42 ) is missing.
not LiteralRestriction(
fieldId == $f.id,
( operator == Operator.GREATER || == Operator.GREATER_OR_EQUAL ),
patternIsNot == $r.patternIsNot,
doubleValue == $r.doubleValue
)
then
Gap gap = new Gap( $f, Operator.GREATER, $r );
result.add( gap );
insert( gap );
end
# If all ranges are not checked for a field.
#
# Type: Warning
# Dependencies: None
# Example: in "Rule 1" Foo( bar == 42 || bar >= 42 )
# and no Foo( bar < 42 || <= 42 || <= 41 || == 41 )
# then Foo( bar < 42 ) is missing.
#
rule "Range check for doubles, equal and smaller than"
when
$f :Field( fieldType == Field.FieldType.DOUBLE )
# Foo( bar == 42 )
$r :LiteralRestriction(
fieldId == $f.id,
( operator == Operator.EQUAL || == Operator.GREATER_OR_EQUAL )
)
# Check if Foo( bar < 42 || <= 42 ) is missing.
not LiteralRestriction(
fieldId == $f.id,
( operator == Operator.LESS || == Operator.LESS_OR_EQUAL ),
patternIsNot == $r.patternIsNot,
doubleValue == $r.doubleValue
)
then
Gap gap = new Gap( $f, Operator.LESS, $r );
result.add( gap );
insert( gap );
end
© 2015 - 2025 Weber Informatics LLC | Privacy Policy