Created
January 7, 2012 16:52
-
-
Save alf239/1575293 to your computer and use it in GitHub Desktop.
Chained method invocation VS JavaBeans introspection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.acm.afilippov; | |
import java.beans.IntrospectionException; | |
import java.beans.Introspector; | |
import java.beans.PropertyDescriptor; | |
public class Chain { | |
private int i; | |
public int getI() { | |
return i; | |
} | |
public Chain setI(int i) { | |
this.i = i; | |
return this; | |
} | |
public static void main(String[] args) throws IntrospectionException { | |
PropertyDescriptor[] propertyDescriptors = Introspector.getBeanInfo(Chain.class).getPropertyDescriptors(); | |
for (PropertyDescriptor propertyDescriptor : propertyDescriptors) { | |
System.out.println("property = " + propertyDescriptor.getDisplayName()); | |
System.out.println("read = " + propertyDescriptor.getReadMethod()); | |
System.out.println("write = " + propertyDescriptor.getWriteMethod()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment