public final class CollectionUtils extends Object
Modifier and Type | Method and Description |
---|---|
static <T> List<T> |
merge(List<T> source,
List<T> target)
Merge two lists, the merge is performed based on the contains method so
elements presents both in source and target are not added twice to the
list.
|
static <T,V> Map<T,V> |
merge(Map<T,? extends V> source,
Map<T,V> target,
boolean override)
Add the content of the 'source' Map to the 'target' set and return the
union Map.
|
static <T> Set<T> |
merge(Set<T> source,
Set<T> target)
Add the content of the 'source' Set to the 'target' set and return the
union set.
|
public static <T> Set<T> merge(Set<T> source, Set<T> target)
source
- The Set to merge in the target Set.target
- The Set in which the source set will be merged (through
addAll).public static <T,V> Map<T,V> merge(Map<T,? extends V> source, Map<T,V> target, boolean override)
Add the content of the 'source' Map to the 'target' set and return the union Map.
If 'source' is null then a new Map is created and returned. If 'target' is null then no content is added to the 'source' Map or newly created Map.
source
- The Map to merge in the target Map.target
- The Map in which the source Map will be merged (through
addAll).override
- If an key from the source map already exists in the target
map, should it override (true) or not (false) the value.public static <T> List<T> merge(List<T> source, List<T> target)
source
- The source list.target
- The target list.Copyright © 2017. All rights reserved.