Class Populator<O>

java.lang.Object
com.hotels.beans.populator.Populator<O>
Type Parameters:
O - the type of the object to get populated.

public abstract class Populator<O>
extends java.lang.Object
Populator for collection or map objects.
  • Method Summary

    Modifier and Type Method Description
    <K> O getPopulatedObject​(java.lang.Class<K> targetClass, java.lang.String fieldName, O fieldValue)
    Populates the target object with the values into the source object.
    protected abstract O getPopulatedObject​(java.lang.reflect.Field field, O fieldValue)
    Populates the target object with the values into the source object.
    <T,​ K> K transform​(T sourceObj, java.lang.Class<K> targetClass)
    Wrapper method for BeanUtils transform method.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getPopulatedObject

      protected abstract O getPopulatedObject​(java.lang.reflect.Field field, O fieldValue)
      Populates the target object with the values into the source object.
      Parameters:
      field - the field to be populated
      fieldValue - the source object from which extract the values
      Returns:
      a populated list of elements
    • getPopulatedObject

      public final <K> O getPopulatedObject​(java.lang.Class<K> targetClass, java.lang.String fieldName, O fieldValue)
      Populates the target object with the values into the source object.
      Type Parameters:
      K - the target object type
      Parameters:
      targetClass - the destination object class
      fieldName - the field to be populated
      fieldValue - the source object from which extract the values
      Returns:
      a populated list of elements
    • transform

      public final <T,​ K> K transform​(T sourceObj, java.lang.Class<K> targetClass)
      Wrapper method for BeanUtils transform method.
      Type Parameters:
      T - the Source object type
      K - the target object type
      Parameters:
      sourceObj - the source object
      targetClass - the destination object class
      Returns:
      a copy of the source object into the destination object