mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 10:18:01 +00:00
Cleanup - Map.getOrDefault and Map.computeIfAbsent
This commit is contained in:
@@ -445,7 +445,7 @@ public class ImportSourceAnalyzer {
|
||||
analyzeListedDir(root, ForgeConstants.CACHE_ICON_PICS_DIR, new ListedAnalyzer() {
|
||||
@Override
|
||||
public String map(final String filename) {
|
||||
return iconFileNames.containsKey(filename) ? iconFileNames.get(filename) : null;
|
||||
return iconFileNames.getOrDefault(filename, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -617,7 +617,7 @@ public class ImportSourceAnalyzer {
|
||||
analyzeListedDir(root, targetDir, new ListedAnalyzer() {
|
||||
@Override
|
||||
public String map(final String filename) {
|
||||
return fileDb.containsKey(filename) ? fileDb.get(filename) : null;
|
||||
return fileDb.getOrDefault(filename, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -826,11 +826,7 @@ public abstract class ItemManager<T extends InventoryItem> extends JPanel implem
|
||||
@SuppressWarnings("unchecked")
|
||||
public void addFilter(final ItemFilter<? extends T> filter) {
|
||||
final Class<? extends ItemFilter<? extends T>> filterClass = (Class<? extends ItemFilter<? extends T>>) filter.getClass();
|
||||
List<ItemFilter<? extends T>> classFilters = this.filters.get(filterClass);
|
||||
if (classFilters == null) {
|
||||
classFilters = new ArrayList<>();
|
||||
this.filters.put(filterClass, classFilters);
|
||||
}
|
||||
List<ItemFilter<? extends T>> classFilters = this.filters.computeIfAbsent(filterClass, k -> new ArrayList<>());
|
||||
if (classFilters.size() > 0) {
|
||||
//if filter with the same class already exists, try to merge if allowed
|
||||
//NOTE: can always use first filter for these checks since if
|
||||
|
||||
@@ -44,7 +44,7 @@ class AsyncSoundRegistry {
|
||||
}
|
||||
|
||||
public synchronized static int getNumIterations(String soundName) {
|
||||
return soundsPlayed.containsKey(soundName) ? soundsPlayed.get(soundName) : 0;
|
||||
return soundsPlayed.getOrDefault(soundName, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -940,11 +940,7 @@ public class FSkin {
|
||||
|
||||
/** @return {@link java.awt.font} */
|
||||
private static Font getFixedFont(final int size) {
|
||||
Font fixedFont = fixedFonts.get(size);
|
||||
if (fixedFont == null) {
|
||||
fixedFont = new Font("Monospaced", Font.PLAIN, size);
|
||||
fixedFonts.put(size, fixedFont);
|
||||
}
|
||||
Font fixedFont = fixedFonts.computeIfAbsent(size, s -> new Font("Monospaced", Font.PLAIN, s));
|
||||
return fixedFont;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user