Here you can find the source of instanceOf(Object o, Class>... classes)
o
is one of instance in class list classes
Parameter | Description |
---|---|
o | a parameter |
classes | a parameter |
public static boolean instanceOf(Object o, Class<?>... classes)
//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; } }