Use computeIfAbsent instead of an if
Signed-off-by: Andrew DeMaria <lostonamountain@gmail.com>
This commit is contained in:
@@ -67,11 +67,7 @@ public class JukeboxJavaService {
|
||||
if (StringUtils.isBlank(mixer)) {
|
||||
mixer = DEFAULT_MIXER_ENTRY_KEY;
|
||||
}
|
||||
List<com.github.biconou.AudioPlayer.api.Player> playersForMixer = activeAudioPlayersPerMixer.get(mixer);
|
||||
if (playersForMixer == null) {
|
||||
playersForMixer = new ArrayList<>();
|
||||
activeAudioPlayersPerMixer.put(mixer, playersForMixer);
|
||||
}
|
||||
List<com.github.biconou.AudioPlayer.api.Player> playersForMixer = activeAudioPlayersPerMixer.computeIfAbsent(mixer, k -> new ArrayList<>());
|
||||
playersForMixer.add(newPlayer);
|
||||
foundPlayer = newPlayer;
|
||||
}
|
||||
|
||||
@@ -98,11 +98,7 @@ public class MusicIndexService {
|
||||
|
||||
for (T artist : artists) {
|
||||
MusicIndex index = getIndex(artist, indexes);
|
||||
List<T> artistSet = result.get(index);
|
||||
if (artistSet == null) {
|
||||
artistSet = new ArrayList<T>();
|
||||
result.put(index, artistSet);
|
||||
}
|
||||
List<T> artistSet = result.computeIfAbsent(index, k -> new ArrayList<T>());
|
||||
artistSet.add(artist);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user