Here you can find the source of containsIgnoreCase(Collection
Parameter | Description |
---|---|
collection | the collection to check if contains the given string |
value | the value to check for |
true
, if found into the collection ignoring case.
public static boolean containsIgnoreCase(Collection<String> collection, String value)
//package com.java2s; //License from project: LGPL import java.util.Collection; public class Main { /**/* w w w.j a va 2 s .co m*/ * 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; } }