Top Fields Constructors Methods
org.glassfish.hk2.utilities.reflection

public Class BeanReflectionHelper

extends Object
Class Inheritance
Imports
java.beans.Introspector, .PropertyChangeEvent, java.lang.reflect.Method, .Modifier, java.util.HashMap, .HashSet, .LinkedList, .Map, .Set, org.glassfish.hk2.utilities.general.GeneralUtilities

Author
jwells

Field Summary

Modifier and TypeField and Description
private static final String
private static final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static Map<String, Object>

Returns:

a possibly zero length but never null bean-like map. All properties of the bean are filled in, even if the value of the property is null
convertJavaBeanToBeanLikeMap
(ClassReflectionHelper
A ClassReflectionHelper to use for analyzing classes
helper
,
Object
a non-null bean to convert
bean
)

Converts a Java bean to a bean-like Map

private static Method
public static String

Returns:

The java-bean version of the property name or null if the method is not a java-bean getter
getBeanPropertyNameFromGetter
(final Method
The method to get the property name from
method
)

Returns the bean version of the property name if the method is a getter, or returns null if the method is not a getter

public static PropertyChangeEvent[]

Returns:

a possibly zero length but never null list of the change events between the two beans
getChangeEvents
(ClassReflectionHelper
A ClassReflectionHelper to use for analyzing classes
helper
,
Object
a non-null current bean
oldBean
,
Object
a non-null new bean
newBean
)

Gets the set of change events by comparing two different beans.

private static PropertyChangeEvent[]
private static Object
private static String

Returns:

The property name or null if not a getter
isAGetter
(MethodWrapper
The method to investigate for being a property
method
)

Returns the property name if this is a getter

private static String

Returns:

The property name or null if not a getter
isAGetter
(Method m)

Returns the property name if this is a getter

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

GETback to summary
private static final String GET
ISback to summary
private static final String IS

Constructor Detail

BeanReflectionHelperback to summary
public BeanReflectionHelper()

Method Detail

convertJavaBeanToBeanLikeMapback to summary
public static Map<String, Object> convertJavaBeanToBeanLikeMap(ClassReflectionHelper helper, Object bean)

Converts a Java bean to a bean-like Map

Parameters
helper:ClassReflectionHelper

A ClassReflectionHelper to use for analyzing classes

bean:Object

a non-null bean to convert

Returns:Map<String, Object>

a possibly zero length but never null bean-like map. All properties of the bean are filled in, even if the value of the property is null

findMethodback to summary
private static Method findMethod(Method m, Class<?> c)
getBeanPropertyNameFromGetterback to summary
public static String getBeanPropertyNameFromGetter(final Method method)

Returns the bean version of the property name if the method is a getter, or returns null if the method is not a getter

Parameters
method:Method

The method to get the property name from

Returns:String

The java-bean version of the property name or null if the method is not a java-bean getter

getChangeEventsback to summary
public static PropertyChangeEvent[] getChangeEvents(ClassReflectionHelper helper, Object oldBean, Object newBean)

Gets the set of change events by comparing two different beans. If the beans implement Map then they are considered to be bean-like maps

Parameters
helper:ClassReflectionHelper

A ClassReflectionHelper to use for analyzing classes

oldBean:Object

a non-null current bean

newBean:Object

a non-null new bean

Returns:PropertyChangeEvent[]

a possibly zero length but never null list of the change events between the two beans

Annotations
@SuppressWarnings:unchecked
getMapChangeEventsback to summary
private static PropertyChangeEvent[] getMapChangeEvents(Map<String, Object> oldBean, Map<String, Object> newBean)
getValueback to summary
private static Object getValue(Object bean, Method m)
isAGetterback to summary
private static String isAGetter(MethodWrapper method)

Returns the property name if this is a getter

Parameters
method:MethodWrapper

The method to investigate for being a property

Returns:String

The property name or null if not a getter

isAGetterback to summary
private static String isAGetter(Method m)

Returns the property name if this is a getter

Returns:String

The property name or null if not a getter