Example usage for java.util LinkedHashMap putIfAbsent

List of usage examples for java.util LinkedHashMap putIfAbsent

Introduction

In this page you can find the example usage for java.util LinkedHashMap putIfAbsent.

Prototype

default V putIfAbsent(K key, V value) 

Source Link

Document

If the specified key is not already associated with a value (or is mapped to null ) associates it with the given value and returns null , else returns the current value.

Usage

From source file:org.sonatype.nexus.repository.r.internal.RPackagesUtils.java

static List<Map<String, String>> merge(List<List<Map<String, String>>> parts) {
    final LinkedHashMap<String, Map<String, String>> merged = new LinkedHashMap<>();
    for (List<Map<String, String>> part : parts) {
        for (Map<String, String> thisEntry : part) {
            merged.putIfAbsent(thisEntry.get(P_PACKAGE), thisEntry);
        }//from   w  w w  .  jav a2  s  .  c o  m
    }
    return new ArrayList<>(merged.values());
}