Skip to content

Commit

Permalink
Hide flash keys, add specific methods instead
Browse files Browse the repository at this point in the history
  • Loading branch information
Cies authored and asolntsev committed Feb 11, 2025
1 parent 3c6e1b6 commit a8958c1
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions framework/src/play/mvc/Scope.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public static class Flash {
final Map<String, String> data;
final Map<String, String> out = new HashMap<>();

public final String ERROR = "error";
public final String SUCCESS = "success";
private final String ERROR = "error";
private final String SUCCESS = "success";

public Flash() {
this(new HashMap<>(2));
Expand Down Expand Up @@ -102,10 +102,26 @@ public void error(@Nonnull String value, Object... args) {
put(ERROR, Messages.get(value, args));
}

public String getErrorMessage() {
return get(ERROR);
}

public boolean containsError() {
return contains(ERROR);
}

public void success(@Nonnull String value, Object... args) {
put(SUCCESS, Messages.get(value, args));
}

public String getSuccessMessage() {
return get(SUCCESS);
}

public boolean containsSuccess() {
return contains(SUCCESS);
}

public void discard(@Nonnull String key) {
out.remove(key);
}
Expand Down

0 comments on commit a8958c1

Please sign in to comment.