Here you can find the source of getGivenClassObject(Collection coll, Class clazz)
Parameter | Description |
---|---|
coll | a parameter |
clazz | a parameter |
public static final Object getGivenClassObject(Collection coll, Class clazz)
//package com.java2s; //License from project: Apache License import java.util.Collection; import java.util.Iterator; public class Main { /**//from w w w .j a v a 2s .com * Get the given class type object from the collection. Return null if not found. * @param coll * @param clazz * @return */ public static final Object getGivenClassObject(Collection coll, Class clazz) { for (Iterator iterator = coll.iterator(); iterator.hasNext();) { Object object = (Object) iterator.next(); if (object != null && clazz.isAssignableFrom(object.getClass())) { return object; } } return null; } }