-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Range Rule Implementation #24
base: main
Are you sure you want to change the base?
Conversation
if (step != null && min instanceof Number && max instanceof Number && step instanceof Number) { | ||
double minVal = ((Number) min).doubleValue(); | ||
double maxVal = ((Number) max).doubleValue(); | ||
double stepVal = ((Number) step).doubleValue(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type should be on the class: RangeRule, so there should be no need for this.
|
||
private Result evaluateIn(T fact) { | ||
if (step == null) { | ||
return evaluateBetween(fact); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you assumign that step=1 in this case? Have you considered failing if step is not specified in IN
operation?
if (fact instanceof Number && step instanceof Number) { | ||
double value = ((Number) fact).doubleValue(); | ||
double minVal = ((Number) min).doubleValue(); | ||
double stepVal = ((Number) step).doubleValue(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure I understand the step
. Could we remove this for this initial iteration please?
} | ||
|
||
private Result evaluateIsBefore(T fact) { | ||
int compareMin = fact.compareTo(min); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should consider the exclusive param for min here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is still valid.
Hi @sic2 , Thanks for the review and the comments. I have addressed the same. Please do have a look. |
} | ||
|
||
private Result evaluateIsBefore(T fact) { | ||
int compareMin = fact.compareTo(min); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is still valid.
", ignore=" + isIgnore() + | ||
"}"; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New line at end of file missing
DIVISIBLE_BY, | ||
BETWEEN, | ||
IS_BEFORE, | ||
IS_AFTER | ||
|
||
// Operators not supported yet | ||
// BETWEEN, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this
* @param <T> type of the fact (must extend Comparable) | ||
*/ | ||
@Experimental | ||
public class RangeRule<T extends Comparable<T>> extends OperatorBasedRule { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for an update to the README as this is experimental for now, but do have unit tests please.
Description
This change introduces RANGE_RULE based on discussion #10
Related Issue
#10
Motivation and Context
The RangeRule class will be specifically designed for validating whether a given fact falls within a specified numeric range with different inclusivity options. It's well-suited for scenarios where we have predefined expectations about the valid range of values for a particular fact.
How Has This Been Tested?
Custom Implementation for use case
Types of changes
Checklist: