Java Utililty Methods List Merge

List of utility methods to do List Merge

Description

The list of methods to do List Merge are organized into topic(s).

Method

ListmergeCollectionsToList(Collection... cols)
merge Collections To List
List<T> mergedList = new ArrayList<T>(countCollectionsSize(cols));
for (Collection<T> oneList : cols) {
    if (oneList == null)
        continue;
    mergedList.addAll(oneList);
return mergedList;
ListmergeCoords(List x, List y)
This will merge the coordinates of the given coordinate system.
if (x.size() != y.size())
    throw new IllegalArgumentException(
            "Sample sizes must be the same for each data applyTransformToDestination.");
List<Double> ret = new ArrayList<>();
for (int i = 0; i < x.size(); i++) {
    ret.add(x.get(i));
    ret.add(y.get(i));
return ret;
voidmergeData(List lstMain, List lstData, List lstKey)
Merge the list of data to main list by list of key
if (lstMain == null || lstData == null || lstData.size() == 0 || lstKey == null || lstKey.size() == 0) {
    return;
for (int index1 = 0, n = lstMain.size(); index1 < n; index1++) {
    Map mapMain = (Map) lstMain.get(index1);
    Map keyValue = new HashMap();
    for (int index2 = 0, m = lstKey.size(); index2 < m; index2++) {
        Object key = lstKey.get(index2);
...
ListmergedView(final List left, final List right)
Returns a new unmodifiable view that is the merging of two lists
List<T> merged = new AbstractList<T>() {
    @Override
    public T get(int index) {
        if (index < left.size())
            return left.get(index);
        else if (index - left.size() < right.size())
            return right.get(index - left.size());
        else
...
StringmergeErrorMsgList(List errorMsgs)
merge Error Msg List
StringBuilder errorMsg = new StringBuilder();
for (String msg : errorMsgs) {
    errorMsg.append(msg);
    errorMsg.append(", ");
return errorMsg.substring(0, errorMsg.length() - 2);
ExceptionmergeException(List t)
merge Exception
Exception exception = new Exception();
return exception;
String[]mergeExcludedFieldLists(String[] superClassExcludes, String[] localClassExcludes)
Utility method to merge two list of excluded fields.
List<String> localExcludes = Arrays.asList(localClassExcludes);
List<String> superExcludes = Arrays.asList(superClassExcludes);
List<String> mergedExcludes = new ArrayList<String>(localExcludes);
mergedExcludes.addAll(superExcludes);
return mergedExcludes.toArray(new String[] {});
voidmergeFilterLists(List childFilters, List parentFilters)
merge Filter Lists
for (String f : parentFilters) {
    if (!childFilters.contains(f)) {
        childFilters.add(f);
Collection>mergeHierarchicalAndFlatDimensions( Collection> hierachicalDimensions, Collection> flatDimensions)
Hierarchical: {1, 0, 0} {1, 1, 0} {1, 1, 1} Flat: {1, 0} {1, 1} {0, 0} {0, 1} Result: {1, 0, 0, 1, 0} {1, 0, 0, 1, 1} {1, 0, 0, 0, 0} {1, 0, 0, 0, 1} {1, 1, 0, 1, 0} {1, 1, 0, 1, 1} {1, 1, 0, 0, 0} {1, 1, 0, 0, 1} {1, 1, 1, 1, 0} {1, 1, 1, 1, 1} {1, 1, 1, 0, 0} {1, 1, 1, 0, 1}
if (hierachicalDimensions.size() == 0) {
    return flatDimensions;
if (flatDimensions.size() == 0) {
    return hierachicalDimensions;
Collection<List<Boolean>> result = new ArrayList<>(hierachicalDimensions.size() * flatDimensions.size());
hierachicalDimensions.forEach(hierarchicalCombination -> {
...
ListmergeIdAndStrings(Long accountId, Long workspaceId, List strs)
merge Id And Strings
List<String> ps = new ArrayList<>();
for (String str : strs) {
    ps.add(mergeIdAndString(accountId, workspaceId, str));
return ps;