Java Collection Check isClassCollection(Class type)

Here you can find the source of isClassCollection(Class type)

Description

is Class Collection

License

Apache License

Parameter

Parameter Description
type any class

Return

true if this class is a collection (e.g. , , )

Declaration

public static boolean isClassCollection(Class<?> type) 

Method Source Code

//package com.java2s;
/**/*ww w.j  a  va  2  s . c  o m*/
 * $Id: ConstructorUtils.java 61 2009-09-25 11:14:16Z azeckoski $
 * $URL: http://reflectutils.googlecode.com/svn/trunk/src/main/java/org/azeckoski/reflectutils/ConstructorUtils.java $
 * FieldUtils.java - genericdao - May 19, 2008 10:10:15 PM - azeckoski
 **************************************************************************
 * Copyright (c) 2008 Aaron Zeckoski
 * Licensed under the Apache License, Version 2.0
 * 
 * A copy of the Apache License has been included in this 
 * distribution and is available at: http://www.apache.org/licenses/LICENSE-2.0.txt
 *
 * Aaron Zeckoski (azeckoski @ gmail.com) (aaronz @ vt.edu) (aaron @ caret.cam.ac.uk)
 */

import java.util.Collection;

public class Main {
    /**
     * @param type any class
     * @return true if this class is a collection (e.g. {@link Collection}, {@link HashSet}, {@link Vector})
     */
    public static boolean isClassCollection(Class<?> type) {
        checkNull(type);
        boolean collection = false;
        if (Collection.class.isAssignableFrom(type)) {
            collection = true;
        }
        return collection;
    }

    private static void checkNull(Class<?> type) {
        if (type == null) {
            throw new IllegalArgumentException("class type cannot be null to check the type");
        }
    }
}

Related

  1. isBlank(final Collection collection)
  2. isBlankAll(Collection... collections)
  3. isC2InC1(Collection c1, Collection c2)
  4. isClassCollection(Class c)
  5. isClassCollection(Class c)
  6. isCollection(Class c)
  7. isCollection(Class clazz)
  8. isCollection(Class clazz)
  9. isCollection(Class clazz)