Here you can find the source of getInterfaces(Object owner, String[] interfaceStrings)
Parameter | Description |
---|---|
owner | target object |
interfaceStrings | target interface strings |
public static ArrayList<Class<?>> getInterfaces(Object owner, String[] interfaceStrings)
//package com.java2s; /*/*from w w w.ja v a 2 s .c o m*/ * Copyright (C) 2011 Baidu.com Inc * * Licensed under the Apache 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.apache.org/licenses/LICENSE-2.0 * * 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.ArrayList; public class Main { /** * get interface classes which the object implemented * * @param owner * target object * @param interfaceStrings * target interface strings * @return target interface classes */ public static ArrayList<Class<?>> getInterfaces(Object owner, String[] interfaceStrings) { ArrayList<Class<?>> targetInterfaces = new ArrayList<Class<?>>(); Class<?>[] interfaceClasses = owner.getClass().getInterfaces(); for (Class<?> interfaceClass : interfaceClasses) { for (String interfaceName : interfaceStrings) { if (interfaceClass.getName().contains(interfaceName)) { targetInterfaces.add(interfaceClass); } } } return targetInterfaces; } }