Replace contains/put/get pattern with computeIfAbsent

This commit is contained in:
Moritz Halbritter
2023-08-08 10:08:31 +02:00
parent 7bb337aeb1
commit 62fb45f75f
4 changed files with 12 additions and 38 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -108,12 +108,7 @@ public class ClassLoaderFiles implements ClassLoaderFileRepository, Serializable
* @return an existing or newly added {@link SourceDirectory}
*/
protected final SourceDirectory getOrCreateSourceDirectory(String name) {
SourceDirectory sourceDirectory = this.sourceDirectories.get(name);
if (sourceDirectory == null) {
sourceDirectory = new SourceDirectory(name);
this.sourceDirectories.put(name, sourceDirectory);
}
return sourceDirectory;
return this.sourceDirectories.computeIfAbsent(name, (key) -> new SourceDirectory(name));
}
/**