Changeset 16959 in josm


Ignore:
Timestamp:
2020-08-29T13:33:21+02:00 (4 years ago)
Author:
simon04
Message:

Java 8: use Map.computeIfAbsent

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/StyleElement.java

    r16553 r16959  
    171171
    172172    private static class FontDescriptor {
    173         public String name;
    174         public int style;
    175         public int size;
     173        final String name;
     174        final int style;
     175        final int size;
    176176
    177177        FontDescriptor(String name, int style, int size) {
     
    199199    private static final Map<FontDescriptor, Font> FONT_MAP = new HashMap<>();
    200200
    201     private static Font getCachedFont(FontDescriptor fd) {
    202         Font f = FONT_MAP.get(fd);
    203         if (f != null) return f;
    204         f = new Font(fd.name, fd.style, fd.size);
    205         FONT_MAP.put(fd, f);
    206         return f;
    207     }
    208 
    209201    private static Font getCachedFont(String name, int style, int size) {
    210         return getCachedFont(new FontDescriptor(name, style, size));
     202        return FONT_MAP.computeIfAbsent(new FontDescriptor(name, style, size), fd -> new Font(fd.name, fd.style, fd.size));
    211203    }
    212204
Note: See TracChangeset for help on using the changeset viewer.