集册 Java实例教程 获取Bean信息

获取Bean信息

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

599
获取Bean信息


import java.beans.BeanInfo;

import java.beans.Introspector;

import java.beans.PropertyDescriptor;
/* 
*来 自
 N o w  J a v a  .   c o m
*/

import java.lang.reflect.Method;

import java.lang.reflect.Type;

import java.util.HashMap;

import java.util.Map;


public class Main{

    public static void main(String[] argv) throws Exception{

        Object value = "nowjava.com";

        System.out.println(getBeanInfo(value));

    }

    public static BeanInfo getBeanInfo(Object value) throws BeanException {

        return (value == null ? null : getBeanInfo(value.getClass()));// from 时 代 J a v a 公 众 号

    }

    public static BeanInfo getBeanInfo(Class<?> type) throws BeanException {

        try {

            
展开阅读全文