Here you can find the source of addDistinctEntry(List
Parameter | Description |
---|---|
V | a parameter |
sourceList | a parameter |
entry | a parameter |
public static <V> boolean addDistinctEntry(List<V> sourceList, V entry)
//package com.java2s; //License from project: Apache License import java.util.List; public class Main { /**// w w w. ja va 2 s . co m * add distinct entry to list * * @param <V> * @param sourceList * @param entry * @return if entry already exist in sourceList, return false, else add it and return true. */ public static <V> boolean addDistinctEntry(List<V> sourceList, V entry) { return (sourceList != null && !sourceList.contains(entry)) ? sourceList.add(entry) : false; } }