-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: KingSimon <[email protected]>
- Loading branch information
1 parent
2f7747f
commit 217c044
Showing
2 changed files
with
71 additions
and
0 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
33 changes: 33 additions & 0 deletions
33
core/src/main/java/tc/oc/pgm/filters/MatchPhaseFilter.java
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,33 @@ | ||
package tc.oc.pgm.filters; | ||
|
||
import tc.oc.pgm.api.filter.Filter; | ||
import tc.oc.pgm.api.filter.query.MatchQuery; | ||
import tc.oc.pgm.api.match.MatchPhase; | ||
|
||
public class MatchPhaseFilter extends TypedFilter<MatchQuery> { | ||
|
||
public static final MatchPhaseFilter RUNNING = new MatchPhaseFilter(MatchPhase.RUNNING); | ||
public static final MatchPhaseFilter FINISHED = new MatchPhaseFilter(MatchPhase.FINISHED); | ||
public static final MatchPhaseFilter STARTING = new MatchPhaseFilter(MatchPhase.STARTING); | ||
public static final MatchPhaseFilter IDLE = new MatchPhaseFilter(MatchPhase.IDLE); | ||
public static final Filter STARTED = | ||
AnyFilter.of( | ||
new MatchPhaseFilter(MatchPhase.RUNNING), new MatchPhaseFilter(MatchPhase.FINISHED)); | ||
|
||
private final MatchPhase matchPhase; | ||
|
||
public MatchPhaseFilter(MatchPhase matchPhase) { | ||
this.matchPhase = matchPhase; | ||
} | ||
|
||
@Override | ||
public Class<? extends MatchQuery> getQueryType() { | ||
return MatchQuery.class; | ||
} | ||
|
||
@Override | ||
protected QueryResponse queryTyped(MatchQuery query) { | ||
MatchPhase current = query.getMatch().getPhase(); | ||
return QueryResponse.fromBoolean(matchPhase == current); | ||
} | ||
} |