-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add ConditionType.OPERATOR * Implement OperatorCondition Refactor Condition and RuleEngine Move logic create conditionMap & actionMap to RuleContext * Update Class diagram
- Loading branch information
1 parent
21ad916
commit 1c23b56
Showing
12 changed files
with
154 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package trile.rule.condition | ||
|
||
import org.springframework.core.Ordered | ||
import org.springframework.core.annotation.Order | ||
import org.springframework.stereotype.Component | ||
import trile.rule.engine.ConditionWithParameter | ||
import trile.rule.model.TransactionContext | ||
|
||
@Order(value = Ordered.LOWEST_PRECEDENCE - 1000) | ||
@Component | ||
class OperatorCondition : Condition<OperatorConditionParameter> { | ||
|
||
override fun evaluate( | ||
context: TransactionContext, parameter: OperatorConditionParameter | ||
): Boolean { | ||
return when (parameter.type) { | ||
OperatorType.NOT -> !parameter.conditions.all { it.condition.evaluate(context, it.parameter) } | ||
OperatorType.AND -> parameter.conditions.all { it.condition.evaluate(context, it.parameter) } | ||
OperatorType.OR -> parameter.conditions.any { it.condition.evaluate(context, it.parameter) } | ||
} | ||
} | ||
|
||
override val type: ConditionType = ConditionType.OPERATOR | ||
} | ||
|
||
data class OperatorConditionParameter( | ||
val type: OperatorType, | ||
val conditions: List<ConditionWithParameter<Any>> | ||
) | ||
|
||
enum class OperatorType { | ||
NOT, | ||
AND, | ||
OR | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters