Skip to content

Commit

Permalink
Rename TokenFilter.accept() to TokenFilter.test()
Browse files Browse the repository at this point in the history
This makes `TokenFilter` look less like `Consumer<>` and more like `Predicate<>` which it is analogous to.
  • Loading branch information
kwvanderlinde committed Nov 16, 2023
1 parent 62a21bf commit 62e1d2e
Showing 1 changed file with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ private void updateInternal() {

var viewTokens = new ArrayList<Token>();
for (Token token : tokenList) {
if (filter.accept(token)) {
if (filter.test(token)) {
viewTokens.add(token);
}
}
Expand Down Expand Up @@ -241,7 +241,7 @@ public boolean checkPlayer() {
* @param token The token to check.
* @return {@code true} if the filter matches {@code token}, allowing it to be displayed.
*/
public boolean accept(Token token) {
public boolean test(Token token) {
return true;
}
}
Expand All @@ -261,7 +261,7 @@ public boolean checkPlayer() {
}

@Override
public boolean accept(Token token) {
public boolean test(Token token) {
return this.layer == token.getLayer();
}
}
Expand All @@ -281,13 +281,12 @@ public boolean accept(Token token) {
* </ol>
*/
private static class PlayerTokenFilter extends TokenFilter {
/** Accepts only PCs tokens owned by the current player. */
public PlayerTokenFilter() {
super(new View("PLAYERS"));
}

@Override
public boolean accept(Token token) {
public boolean test(Token token) {
if (token.getType() != Token.Type.PC) {
return false;
}
Expand All @@ -304,13 +303,12 @@ public boolean accept(Token token) {

/** Accepts only tokens with an attached light source and only when owned by the user. */
private static class LightSourceFilter extends TokenFilter {
/** Accepts only tokens with an attached light source and only when owned by the user. */
public LightSourceFilter() {
super(new View("LIGHT_SOURCES"));
}

@Override
public boolean accept(Token token) {
public boolean test(Token token) {
return !token.getLightSources().isEmpty() && AppUtil.playerOwns(token);
}
}
Expand All @@ -336,7 +334,7 @@ public NPCTokenFilter() {
}

@Override
public boolean accept(Token token) {
public boolean test(Token token) {
if (!token.getLayer().isTokenLayer() || token.getType() != Token.Type.NPC) {
return false;
}
Expand Down

0 comments on commit 62e1d2e

Please sign in to comment.