Java Class InstanceOf instanceOf(Object o, Class... classes)

Here you can find the source of instanceOf(Object o, Class... classes)

Description

Check whether object o is one of instance in class list classes

License

Open Source License

Parameter

Parameter Description
o a parameter
classes a parameter

Declaration

public static boolean instanceOf(Object o, Class<?>... classes) 

Method Source Code

//package com.java2s;
/**/*from w  ww.ja  v a 2 s  .  c  o m*/
 * This file is part of mycollab-core.
 *
 * mycollab-core is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * mycollab-core is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with mycollab-core.  If not, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    /**
     * Check whether object <code>o</code> is one of instance in class list
     * <code>classes</code>
     *
     * @param o
     * @param classes
     * @return
     */
    public static boolean instanceOf(Object o, Class<?>... classes) {
        for (Class<?> cls : classes) {
            if (cls.isInstance(o)) {
                return true;
            }
        }
        return false;
    }
}

Related

  1. instanceOf(final Class classVerifiable, final Class classAssignable)
  2. instanceOf(final Object a, final Class b)
  3. instanceOf(final Object object, final Class... classes)
  4. instanceOf(Object o, Class clazz)
  5. instanceOf(Object o, Class c)
  6. instanceOf(Object obj, String className)
  7. instanceOf(Object obj, String className)
  8. instanceOf(Object obj, String name)
  9. instanceOf(Object object, Class clazz)