Here you can find the source of isUniformCollection(Collection> c, Class> e)
public static boolean isUniformCollection(Collection<?> c, Class<?> e)
//package com.java2s; /*//www.j a v a 2 s .c om * %W% %E% * * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ import java.util.*; public class Main { private static final Map<String, Class<?>> primitiveMap = new HashMap<String, Class<?>>(); /** * Check if the given collection is a uniform collection of the given type. */ public static boolean isUniformCollection(Collection<?> c, Class<?> e) { if (e == null) { throw new IllegalArgumentException("Null reference type"); } if (c == null) { throw new IllegalArgumentException("Null collection"); } if (c.isEmpty()) { return false; } for (Object o : c) { if (o == null || !e.isAssignableFrom(o.getClass())) { return false; } } return true; } /** * This method returns the class matching the name className. * It's used to cater for the primitive types. */ public static Class<?> getClass(String className) throws ClassNotFoundException { Class<?> c; if ((c = primitiveMap.get(className)) != null) return c; return Class.forName(className); } }