Java Collection Check isa(Collection> types, Class type)

Here you can find the source of isa(Collection> types, Class type)

Description

isa

License

Educational Community License

Parameter

Parameter Description
types class tokens to check against
type class token

Return

true if the given Class is assignable from one of the classes in the given Class[]

Declaration

private static boolean isa(Collection<Class<?>> types, Class<?> type) 

Method Source Code

//package com.java2s;
/**/*from   ww w . ja v  a 2s .c om*/
 * Copyright 2005-2015 The Kuali Foundation
 *
 * Licensed under the Educational Community License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.opensource.org/licenses/ecl2.php
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.util.Collection;

public class Main {
    /**
     * @param types class tokens to check against
     * @param type class token
     * @return true if the given Class is assignable from one of the classes in
     *         the given Class[]
     */
    private static boolean isa(Collection<Class<?>> types, Class<?> type) {
        for (Class<?> cur : types) {
            if (cur.isAssignableFrom(type)) {
                return true;
            }
        }
        return false;
    }
}

Related

  1. isACollection(Object input)
  2. isAllFalse(Collection booleans)
  3. isArrayOrCollection(Class clazz)
  4. isArrayOrCollection(Object paramObj)