Java Collection Contain containsIdentity(Collection objects, Object object)

Here you can find the source of containsIdentity(Collection objects, Object object)

Description

Returns true if objects contains object.

License

Open Source License

Declaration

public static boolean containsIdentity(Collection<?> objects,
        Object object) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2007, 2008 Tran Nam Quang.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:/*www .  j  a  v a  2  s  . c om*/
 *    Tran Nam Quang - initial API and implementation
 *******************************************************************************/

import java.util.Collection;

public class Main {
    /**
     * Returns true if <tt>objects</tt> contains <tt>object</tt>.
     */
    public static boolean containsIdentity(Object[] objects, Object object) {
        for (Object candidate : objects)
            if (candidate == object)
                return true;
        return false;
    }

    /**
     * Returns true if <tt>objects</tt> contains <tt>object</tt>.
     */
    public static boolean containsIdentity(Collection<?> objects,
            Object object) {
        for (Object candidate : objects)
            if (candidate == object)
                return true;
        return false;
    }
}

Related

  1. containsByClassName(Collection objects, String className)
  2. containsByIdentity(Collection collection, Object toBeFound)
  3. containsClassOrSuper(Collection classNames, String className)
  4. containsElement(Collection collect, T elem)
  5. containsIdentity(Collection collection, T element)
  6. containsIgnoreCase(Collection c, String s)
  7. containsIgnoreCase(Collection c, String s)
  8. containsIgnoreCase(Collection c, String str)
  9. containsIgnoreCase(Collection collection, String testString)