From 3aa5a5898e25ab9dec22602a84033f2f10a0b70e Mon Sep 17 00:00:00 2001 From: Tagir Valeev Date: Tue, 28 Feb 2017 11:06:51 +0700 Subject: [PATCH] Java8MapApi: samples simplified (IDEA-CR-18613) --- .../inspectionDescriptions/Java8MapApi.html | 22 +++++-------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/resources-en/src/inspectionDescriptions/Java8MapApi.html b/resources-en/src/inspectionDescriptions/Java8MapApi.html index 4df75ae89815..2697a4557190 100644 --- a/resources-en/src/inspectionDescriptions/Java8MapApi.html +++ b/resources-en/src/inspectionDescriptions/Java8MapApi.html @@ -5,11 +5,7 @@ Inspection detects calls to Map.get which could be replaced with
  • Map.getOrDefault method could be used to replace the code like this:
    -      aValue = map.get(aKey);
    -      if (aValue == null) {
    -        aValue = "none";
    -      }
    -    
    + String val = map.containsKey(key) ? map.get(key) : "none";
  • Map.computeIfAbsent method could be used to replace the code like this:
    @@ -17,26 +13,18 @@ Inspection detects calls to Map.get which could be replaced with 
    +      }
  • Map.putIfAbsent method could be used to replace the code like this:
           String val = map.get(key);
    -      if (val == null) {
    -        map.put(key, newVal);
    -      }
    -    
    + if (val == null) map.put(key, newVal);
  • Map.merge method could be used to replace the code like this:
           Integer val = map.get(key);
    -      if (val == null) {
    -        map.put(key, 1);
    -      } else {
    -        map.put(key, val + 1);
    -      }
    -    
    + if (val == null) map.put(key, 1); + else map.put(key, val + 1);