All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.rauberprojects.client.Collections Maven / Gradle / Ivy

There is a newer version: 1.0.3
Show newest version
package com.github.rauberprojects.client;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Collection;
import java.util.Comparator;

/**
 * @author Thomas Eizinger
 */
public final class Collections {

    private Collections() { }

    private static final Logger logger = LoggerFactory.getLogger(Collections.class);

    public static  boolean contains(Collection collection, T item, Comparator comparator) {

        for (T t : collection) {
            final int difference = comparator.compare(t, item);

            logger.trace("Compared {} against {} using {}: {}", t, item, comparator, difference);

            if (difference == 0) {
                return true;
            }
        }

        return false;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy