Class BeanReflectionHelper


  • public class BeanReflectionHelper
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.lang.String GET  
      private static java.lang.String IS  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.Map<java.lang.String,​java.lang.Object> convertJavaBeanToBeanLikeMap​(ClassReflectionHelper helper, java.lang.Object bean)
      Converts a Java bean to a bean-like Map
      private static java.lang.reflect.Method findMethod​(java.lang.reflect.Method m, java.lang.Class<?> c)  
      static java.lang.String getBeanPropertyNameFromGetter​(java.lang.reflect.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
      static java.beans.PropertyChangeEvent[] getChangeEvents​(ClassReflectionHelper helper, java.lang.Object oldBean, java.lang.Object newBean)
      Gets the set of change events by comparing two different beans.
      private static java.beans.PropertyChangeEvent[] getMapChangeEvents​(java.util.Map<java.lang.String,​java.lang.Object> oldBean, java.util.Map<java.lang.String,​java.lang.Object> newBean)  
      private static java.lang.Object getValue​(java.lang.Object bean, java.lang.reflect.Method m)  
      private static java.lang.String isAGetter​(java.lang.reflect.Method m)
      Returns the property name if this is a getter
      private static java.lang.String isAGetter​(MethodWrapper method)
      Returns the property name if this is a getter
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BeanReflectionHelper

        public BeanReflectionHelper()
    • Method Detail

      • getBeanPropertyNameFromGetter

        public static java.lang.String getBeanPropertyNameFromGetter​(java.lang.reflect.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 - The method to get the property name from
        Returns:
        The java-bean version of the property name or null if the method is not a java-bean getter
      • isAGetter

        private static java.lang.String isAGetter​(MethodWrapper method)
        Returns the property name if this is a getter
        Parameters:
        method - The method to investigate for being a property
        Returns:
        The property name or null if not a getter
      • isAGetter

        private static java.lang.String isAGetter​(java.lang.reflect.Method m)
        Returns the property name if this is a getter
        Parameters:
        method - The method to investigate for being a property
        Returns:
        The property name or null if not a getter
      • findMethod

        private static java.lang.reflect.Method findMethod​(java.lang.reflect.Method m,
                                                           java.lang.Class<?> c)
      • getValue

        private static java.lang.Object getValue​(java.lang.Object bean,
                                                 java.lang.reflect.Method m)
      • getMapChangeEvents

        private static java.beans.PropertyChangeEvent[] getMapChangeEvents​(java.util.Map<java.lang.String,​java.lang.Object> oldBean,
                                                                           java.util.Map<java.lang.String,​java.lang.Object> newBean)
      • getChangeEvents

        public static java.beans.PropertyChangeEvent[] getChangeEvents​(ClassReflectionHelper helper,
                                                                       java.lang.Object oldBean,
                                                                       java.lang.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 - A ClassReflectionHelper to use for analyzing classes
        oldBean - a non-null current bean
        newBean - a non-null new bean
        Returns:
        a possibly zero length but never null list of the change events between the two beans
      • convertJavaBeanToBeanLikeMap

        public static java.util.Map<java.lang.String,​java.lang.Object> convertJavaBeanToBeanLikeMap​(ClassReflectionHelper helper,
                                                                                                          java.lang.Object bean)
        Converts a Java bean to a bean-like Map
        Parameters:
        helper - A ClassReflectionHelper to use for analyzing classes
        bean - a non-null bean to convert
        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