Class EntityPatcher

java.lang.Object
es.kukenan.smartfi.common.service.mapper.EntityPatcher

@Component public class EntityPatcher extends Object
Entity patcher utility, see patch(Object, Object).
  • Constructor Details

    • EntityPatcher

      public EntityPatcher()
  • Method Details

    • patch

      public <T> T patch(T original, T overrides)
      Patch a given entity overriding its fields with the non-null values from a second given entity.
      Type Parameters:
      T - Entity type.
      Parameters:
      original - the entity to patch.
      overrides - the entity with the values to override in the origin entity.
      Returns:
      the patched entity (the same object instance as the original argument).
    • invokeGetter

      private Object invokeGetter(Object object, Method method)
      Helper util to invoke a method capturing, controlling and logging any exception thrown.
      Parameters:
      object - the object which method will be invoked.
      method - the method.
      Returns:
      the method invocation result or null if any exception is captured.
    • invokeSetter

      private Object invokeSetter(Object object, String methodName, Object argument)
      Helper util to invoke a method capturing, controlling and logging any exception thrown.
      Parameters:
      object - the object which method will be invoked.
      methodName - the name of the method to invoke.
      argument - the setter argument.
      Returns:
      the method invocation result or null if any exception is captured.