Java List Distinct Value addDistinctList(List sourceList, List entryList)

Here you can find the source of addDistinctList(List sourceList, List entryList)

Description

add Distinct List

License

Apache License

Declaration

public static <V> int addDistinctList(List<V> sourceList, List<V> entryList) 

Method Source Code

//package com.java2s;
/**//from  ww w.j  av a 2s .c o m
 *  Copyright (c) 2014 http://www.lushapp.wang
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 */

import java.util.List;

public class Main {

    public static <V> int addDistinctList(List<V> sourceList, List<V> entryList) {
        if (sourceList == null || isEmpty(entryList)) {
            return 0;
        }

        int sourceCount = sourceList.size();
        for (V entry : entryList)
            if (!sourceList.contains(entry)) {
                sourceList.add(entry);
            }

        return sourceList.size() - sourceCount;
    }

    public static boolean isEmpty(List<?> sourceList) {
        return (sourceList == null || sourceList.size() == 0);
    }
}

Related

  1. addDistinctEntry(List sourceList, V entry)
  2. addDistinctItems(List fromItems, List toItems)
  3. addWithExpDecay(List distinctVals)
  4. constructDistinctClause(StringBuffer selectClause, List attributes, boolean isCountOnly)
  5. distinct(List list)
  6. distinct(List list)