title: Nested Hashmap: Alternative to putIfAbsent which does not requires null check and manual get?
body: <p>I have a nested <code>HashMap</code> looking like this: <code>HashMap&lt;String, HashMap&lt;String,Object&gt;&gt;</code>.</p>
  
  <p>I created a <code>add</code> method to fill the <code>HashMap</code></p>
  
  <pre><code>private void add(String currentVersion, String targetVersion, Object object) {
      HashMap &lt;String, HashMap &lt;String, Object &gt;&gt; nestedMap = definedUpdatePlans.putIfAbsent(currentVersion, new HashMap());
      if (nestedMap == null) {
          nestedMap = definedUpdatePlans.get(currentVersion);
      }
      nestedMap.put(targetVersion, object);
  }
  </code></pre>
  
  <p>As you see, I'll add the nested map if absent. If it was already present, I'll get the current value as return value. In case if it was absent, <code>putIfAbsent</code> returns <code>null</code> which requires me to do a null check and a manual get to populate the variable.</p>
  
  <p>This seems not very clean, but I wouldn't know a better way.</p>
  
  <p>Is there a way to add a value if not existing and keep working with the new or pre existing value in a more fluent way?</p>