get Java Bean Property Descriptors - Java Reflection

Java examples for Reflection:Java Bean

Description

get Java Bean Property Descriptors

Demo Code


//package com.java2s;
import java.beans.BeanInfo;

import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;

public class Main {
    public static void main(String[] argv) throws Exception {
        Class clazz = String.class;
        System.out.println(java.util.Arrays
                .toString(getPropertyDescriptors(clazz)));
    }//from   www.  j  a v  a  2  s.  c o m

    public static PropertyDescriptor[] getPropertyDescriptors(Class<?> clazz)
            throws IntrospectionException {
        final BeanInfo info = Introspector.getBeanInfo(clazz);
        return info.getPropertyDescriptors();
    }
}

Related Tutorials