集册 Java实例教程 递归地进入接口并获取所有已定义的propertyDescriptors

递归地进入接口并获取所有已定义的propertyDescriptors

欢马劈雪     最近更新时间:2020-01-02 10:19:05

491
递归地进入接口并获取所有已定义的propertyDescriptors

/*******************************************************************************

 * Copyright (C) 2011 Angelo Zerr <angelo.zerr@gmail.com>, Pascal Leclercq <pascal.leclercq@gmail.com>

 * All rights reserved. This program and the accompanying materials

 * are made available under the terms of the Eclipse Public License v1.0

 * which accompanies this distribution, and is available at

 * http://www.eclipse.org/legal/epl-v10.html

 *

 * Contributors:

 *     Angelo ZERR - initial API and implementation

 *     Pascal Leclercq - initial API and implementation

 *******************************************************************************/

//package com.nowjava;

import java.beans.BeanInfo;

import java.beans.IntrospectionException;
/*
nowjava 提 供
*/

import java.beans.Introspector;

import java.beans.PropertyDescriptor;


import java.util.List;


public class Main {



    /**

     * Goes recursively into the interface and gets all defined

     * propertyDescriptors

     * 

     * @param propertyDescriptors

     *            The result list of all PropertyDescriptors the given interface

     *            defines (hierarchical)

     * @param iface

     *            The interface to fetch the PropertyDescriptors

     * @throws IntrospectionException

     */

    private static void getInterfacePropertyDescriptors(

            List propertyDescriptors, Class iface)

            throws IntrospectionException {//时代Java公众号

        BeanInfo beanInfo = Introspector.getBeanInfo(iface);

        PropertyDescriptor[] pds = beanInfo.getPropertyDescriptors();

        for (int i = 0; i < pds.length; i++) {

  
展开阅读全文