Skip to content

Commit

Permalink
Use computeIfAbsent with a protected method, make reset protected
Browse files Browse the repository at this point in the history
Signed-off-by: Guillaume Nodet <gnodet@gmail.com>
  • Loading branch information
gnodet authored and ceki committed Jan 8, 2024
1 parent d564304 commit db8cd90
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,17 @@ public SimpleLoggerFactory() {

/**
* Return an appropriate {@link SimpleLogger} instance by name.
*
* This method will call {@link #createLogger(String)} if the logger
* has not been created yet.
*/
public Logger getLogger(String name) {
return loggerMap.computeIfAbsent(name, this::createLogger);
}

/**
* Actually creates the logger for the given name.
*/
protected Logger createLogger(String name) {
return new SimpleLogger(name);
}
Expand Down

0 comments on commit db8cd90

Please sign in to comment.