Java Utililty Methods List Contain

List of utility methods to do List Contain

Description

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

Method

booleancontainsItems(List smallerList, List largerList)
contains Items
List tempList = new ArrayList();
for (Object o : largerList)
    tempList.add(o);
for (Object check : smallerList) {
    if (tempList.contains(check))
        tempList.remove(check); 
    else
        return false;
...
booleancontainsNonPositives(List vals)
contains Non Positives
for (Long val : vals) {
    if (val <= 0L) {
        return true;
return false;
booleancontainsNull(List list)
Returns true if the given (non-null) List contains null as one of its values.
for (Object o : list) {
    if (o == null) {
        return true;
return false;
booleancontainsNullElement(List source)
Checks whether 'list' has any null element in it.
if (source == null)
    return false;
if (source.isEmpty())
    return false;
if (source.contains(null))
    return true;
return false;
booleancontainsOneEqualElem(List first, List second)
Test of a list contains one or more equal elements
for (Object str : first) {
    if (second.contains(str))
        return true;
return false;
booleancontainsOnly(List elements, Class clazz)
contains Only
if (elements.isEmpty())
    return false;
for (Iterator iter = elements.iterator(); iter.hasNext();) {
    if (!clazz.isAssignableFrom(iter.next().getClass()))
        return false;
return true;
booleancontainsOnlyEmptyValues(List list)
Checks if all of the entries in a list of Strings is empty or null.
if (list != null) {
    int emptyCount = 0;
    for (String value : list) {
        if (isEmpty(value))
            emptyCount++;
    return (list.size() == emptyCount);
return (false);
booleancontainsOnlyNulls(List list)
contains Only Nulls
for (T t : list)
    if (t != null)
        return false;
return true;
booleancontainsOnlySequentialNumbers(List values)
contains Only Sequential Numbers
for (int i = 0; i < values.size() - 1; i++) {
    if (values.get(i) != values.get(i + 1) - 1) {
        return false;
return true;
booleancontainsOrIsEmpty(List list, Object item)
contains Or Is Empty
if (list == null || list.isEmpty() || list.contains(item))
    return true;
return false;