Skip to content

Commit 05cbb9e

Browse files
committed
Miscellaneous updates
- Implement isTrue and isFalse operators for conditions. - Refactor operator filtering to use index if available.
1 parent eab4784 commit 05cbb9e

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

lib/src/api/models/condition.dart

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,13 @@ enum ConditionOperation {
5050
isEven,
5151

5252
/// Checks if the value of the variable is null.
53-
isNull;
53+
isNull,
54+
55+
/// Checks if the value of the variable is true.
56+
isTrue,
57+
58+
/// Checks if the value of the variable is false.
59+
isFalse;
5460

5561
/// label for the operation
5662
String get label => switch (this) {
@@ -66,6 +72,8 @@ enum ConditionOperation {
6672
isOdd => 'Is Odd',
6773
isEven => 'Is Even',
6874
isNull => 'Is Null',
75+
isTrue => 'Is True',
76+
isFalse => 'Is False',
6977
};
7078

7179
/// short description of the operation
@@ -82,6 +90,8 @@ enum ConditionOperation {
8290
isOdd => 'is odd',
8391
isEven => 'is even',
8492
isNull => 'is null',
93+
isTrue => 'is true',
94+
isFalse => 'is false',
8595
};
8696

8797
/// short description of the operation
@@ -98,6 +108,8 @@ enum ConditionOperation {
98108
isOdd => null,
99109
isEven => null,
100110
isNull => null,
111+
isTrue => null,
112+
isFalse => null,
101113
};
102114

103115
/// Allows the provided [visitor] to visit this operation.
@@ -117,6 +129,8 @@ enum ConditionOperation {
117129
isOdd => visitor.visitIsOddOperator(left),
118130
isEven => visitor.visitIsEvenOperator(left),
119131
isNull => visitor.visitIsNullOperator(left),
132+
isTrue => visitor.visitIsTrueOperator(left),
133+
isFalse => visitor.visitIsFalseOperator(left),
120134
};
121135

122136
/// Returns true if the operation requires a right operand.
@@ -133,6 +147,8 @@ enum ConditionOperation {
133147
isOdd => false,
134148
isEven => false,
135149
isNull => false,
150+
isTrue => false,
151+
isFalse => false,
136152
};
137153
}
138154

@@ -684,6 +700,12 @@ abstract interface class ConditionOperatorVisitor {
684700

685701
/// Visits a [ConditionOperation.isNull] operator.
686702
bool visitIsNullOperator(Object? value);
703+
704+
/// Visits a [ConditionOperation.isTrue] operator.
705+
bool visitIsTrueOperator(Object? value);
706+
707+
/// Visits a [ConditionOperation.isFalse] operator.
708+
bool visitIsFalseOperator(Object? value);
687709
}
688710

689711
/// An interface for evaluating conditions.

lib/src/api/models/condition.g.dart

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)