Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: LGPL 

import java.util.Collection;

public class Main {
    /**
     * Checks if the given collection of strings contains the provided string ignoring case.
     * <p>
     * <b>NOTE:</b> for optimal results if possible construct your collection only with lower/upper
     * case strings. It's going to be faster if the checks need to be performed often.
     * 
     * @param collection
     *            the collection to check if contains the given string
     * @param value
     *            the value to check for
     * @return <code>true</code>, if found into the collection ignoring case.
     */
    public static boolean containsIgnoreCase(Collection<String> collection, String value) {
        if (value == null) {
            return false;
        }
        for (String string : collection) {
            if (string.equalsIgnoreCase(value)) {
                return true;
            }
        }
        return false;
    }
}