Java Collection Contain containsPrefix(String str, Collection prefixes)

Here you can find the source of containsPrefix(String str, Collection prefixes)

Description

if str starts with a prefix which is included in prefixes collection return true, otherwise return false.

License

LGPL

Parameter

Parameter Description
str a parameter
prefixes a collection of String objects

Return

if str starts with a prefix which is included in prefixes collection return true, otherwise return false.

Declaration

public static boolean containsPrefix(String str, Collection prefixes) 

Method Source Code

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

import java.util.Collection;

import java.util.Iterator;

public class Main {
    /**//www. j ava 2 s  . c o m
     * if str starts with a prefix which is included in prefixes collection
     * return true, otherwise return false.
     * 
     * @param str
     * @param prefixes
     *            a collection of String objects
     * 
     * @return if str starts with a prefix which is included in prefixes collection
     *         return true, otherwise return false.
     */
    public static boolean containsPrefix(String str, Collection prefixes) {
        if (str != null && prefixes != null) {
            Iterator it = prefixes.iterator();
            while (it.hasNext()) {
                String prefix = (String) it.next();
                if (str.startsWith(prefix)) {
                    return true;
                }
            }
        }
        return false;
    }
}

Related

  1. containsNumber(Collection collection, Number number)
  2. containsObject(Collection c, T o)
  3. containsObjectIdentity(Collection collection, Object object)
  4. containsOne(final Collection sup, final Collection parts)
  5. containsPrefix(final Collection words, final String prefix)
  6. containsSafe(Collection collection, V value)
  7. containsSame(Collection first, Collection second)
  8. containsSameItems(Collection col1, Collection col2)
  9. containsSameType(Object o, Collection collection)