Use computeIfAbsent with a protected method, make reset protected

Signed-off-by: Guillaume Nodet <gnodet@gmail.com>
This commit is contained in:
Guillaume Nodet 2024-01-08 16:41:13 +01:00 committed by Ceki Gülcü
parent d564304a61
commit db8cd90c10
1 changed files with 6 additions and 0 deletions

View File

@ -47,11 +47,17 @@ public class SimpleLoggerFactory implements ILoggerFactory {
/**
* 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);
}