Class EntityPatcher
java.lang.Object
es.kukenan.smartfi.common.service.mapper.EntityPatcher
Entity patcher utility, see
patch(Object, Object).-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate ObjectinvokeGetter(Object object, Method method) Helper util to invoke a method capturing, controlling and logging any exception thrown.private ObjectinvokeSetter(Object object, String methodName, Object argument) Helper util to invoke a method capturing, controlling and logging any exception thrown.<T> Tpatch(T original, T overrides) Patch a given entity overriding its fields with the non-null values from a second given entity.
-
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
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
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.
-