Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
NUI
TULIP-CPS
Commits
9b7dfb28
Commit
9b7dfb28
authored
Jun 11, 2020
by
Nico Mack
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed an issue with apply method not visiting all rules
parent
b4b1543f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
5 deletions
+12
-5
CPS/src/lu/list/itis/dkd/tui/ruleengine/RuleEngine.java
CPS/src/lu/list/itis/dkd/tui/ruleengine/RuleEngine.java
+12
-5
No files found.
CPS/src/lu/list/itis/dkd/tui/ruleengine/RuleEngine.java
View file @
9b7dfb28
...
@@ -20,7 +20,6 @@ import org.slf4j.LoggerFactory;
...
@@ -20,7 +20,6 @@ import org.slf4j.LoggerFactory;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Optional
;
/**
/**
* @author Nico Mack [nico.mack@list.lu]
* @author Nico Mack [nico.mack@list.lu]
...
@@ -39,6 +38,8 @@ public class RuleEngine {
...
@@ -39,6 +38,8 @@ public class RuleEngine {
// * Constants
// * Constants
// ***************************************************************************
// ***************************************************************************
private
static
final
String
NEWLINE
=
System
.
lineSeparator
();
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
RuleEngine
.
class
.
getSimpleName
());
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
RuleEngine
.
class
.
getSimpleName
());
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
...
@@ -75,15 +76,21 @@ public class RuleEngine {
...
@@ -75,15 +76,21 @@ public class RuleEngine {
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
public
static
boolean
apply
(
InputEvent
event
)
{
public
static
boolean
apply
(
InputEvent
event
)
{
Optional
<
Rule
>
rule
=
rules
.
values
().
stream
().
filter
(
r
->
r
.
apply
(
event
)).
findFirst
();
// Optional<Rule> rule = rules.values().stream().filter(r -> r.apply(event)).findFirst();
return
(
rule
.
isPresent
());
// return (rule.isPresent());
boolean
fired
=
false
;
for
(
Rule
rule
:
rules
.
values
())
{
fired
|=
rule
.
apply
(
event
);
}
return
fired
;
}
}
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
public
static
String
dump
()
{
public
static
String
dump
()
{
StringBuilder
builder
=
new
StringBuilder
();
StringBuilder
builder
=
new
StringBuilder
(
NEWLINE
);
rules
.
values
().
forEach
(
r
->
builder
.
append
(
r
.
toString
()).
append
(
"\n"
));
rules
.
values
().
forEach
(
r
->
builder
.
append
(
r
.
toString
()).
append
(
NEWLINE
));
return
builder
.
toString
();
return
builder
.
toString
();
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment