Class PojoManager

java.lang.Object
org.eclnt.util.valuemgmt.PojoManager

public class PojoManager extends Object
Useful methods around dealing with Pojo objects in a generic way.
  • Constructor Details

    • PojoManager

      public PojoManager()
  • Method Details

    • calculateHashForPojo

      public static String calculateHashForPojo(Object bean)
      Calculates hash code by iterating through properties of bean and calculates the hash code of each individual property - then calculates the whole hash code using the function Objects.hash(Object...).
    • calculateHashForPojo

      public static String calculateHashForPojo(Object bean, boolean withDrillDown)
    • calculateHashForListOfPojos

      public static String calculateHashForListOfPojos(List<?> beanList)
    • transferPojoIntoMap

      public static Map<String,Object> transferPojoIntoMap(Object bean)
      Transfers all simple data type properties of the bean into a map. The key of the map is the name of the property.
    • transferPojoIntoPojo

      public static void transferPojoIntoPojo(Object fromBean, Object bean, boolean withError)
      Convenience method for transferPojoIntoPojo(Object, Object, boolean, boolean, boolean) setting parameters "simpleDataTypeOnly" to false, and "notNullOnly" to false.
    • transferPojoIntoPojo

      public static void transferPojoIntoPojo(Object fromBean, Object bean, boolean simpleDataTypesOnly, boolean notNullOnly, boolean withError)
      Transfers properties from the "fromBean" into the "bean". Properties are checked for same name and assignable type.
      Parameters:
      notNullOnly - If the "fromBean" has a null-value for a property, then this null-value is only set into the other bean if this parameter is set to true. Idea behind: you may decide to only take over properties from the "fromBean" into the "bean" if they are not-null.
      withError - In case some error happens (e.g. when calling the set-ter method of the "bean") then in case of "true" an Error will be thrown - otherwise the error will be ignored.
    • createPojoFromMapData

      public static <OBJTYPE> OBJTYPE createPojoFromMapData(Class<OBJTYPE> clazz, Map<String,?> map, boolean withError)
    • transferObjectMapDataIntoPojo

      public static void transferObjectMapDataIntoPojo(Map<String,?> map, Object bean, boolean withError)
      Transfers the data contained within the map into the corresponding set-ter methods of the "bean" that is passed as parameter. The type of the data must match - there is no type conversion.
    • createPojoFromStringMapData

      public static <OBJTYPE> OBJTYPE createPojoFromStringMapData(Class<OBJTYPE> clazz, Map<String,String> map, boolean withError)
      Creates object and transfers the String values in the Map into the object properties. Implicit conversions from String to the corresponding property data type are executed.
    • transferStringMapDataIntoPojo

      public static void transferStringMapDataIntoPojo(Map<String,String> map, Object bean, boolean withError)
      Transfers data from map into bean. The string is converted into a proper data type before. The conversion is done using the simple data type management of the ValueManager class: ValueManager.convertStringIntoObject(String, Class).
    • transferStringMapDataIntoPojoChangesOnly

      public static void transferStringMapDataIntoPojoChangesOnly(Map<String,String> map, Object bean, boolean withError)
      Extension of transferStringMapDataIntoPojo(Map, Object, boolean, boolean): before calling the set-ter to transfer the value, the get-ter is called to check if the current value is different to the value of the map. Only if there's a difference then the set-ter is called.

      Sometimes the set-ter of a pojo does more than just setting its internal member: it may e.g. register some change within the object. So, here the set-ter is only called when the corresponding property really is to be changed. The comparison is done using the normal "equals" method of objects.
    • transferPojoIntoPojo

      public static void transferPojoIntoPojo(Object fromBean, Object bean, boolean simpleDataTypesOnly, PojoManager.ICheckIfToTransferPropertyValue checker, boolean withError)
    • setPropertyValue

      public static void setPropertyValue(Object bean, String propertyName, Object value)
    • setPropertyValue

      public static void setPropertyValue(Object bean, String propertyName, Object value, boolean withError)
    • getPropertyValue

      public static Object getPropertyValue(Object bean, String propertyName)
    • getPropertyValue

      public static Object getPropertyValue(Object bean, String propertyName, boolean withError)
    • comparePojosOfSameClass

      public static List<PojoManager.PojoPropertyChangeInfo> comparePojosOfSameClass(Object fromBean, Object toBean)