Package org.genesys.blocks.model
Interface Copyable<T>
-
- Type Parameters:
T- the generic type
public interface Copyable<T>The Interface Copyable.
-
-
Field Summary
Fields Modifier and Type Field Description static org.springframework.util.ReflectionUtils.FieldFilterCOPYABLE_FIELDSPre-built FieldFilter that matches all non-static, non-final, non-Collection fields.
-
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default Tapply(T source)Apply values from source to this object.default Tcopy()Make a deep copy of the object, with all new instances.default <R extends Copyable<R>>
List<R>copyList(List<R> source, Consumer<? super R> action)Utility method that makes a deep copy ofCopyableelements.
-
-
-
Method Detail
-
copy
default T copy()
Make a deep copy of the object, with all new instances. Implementations should useapply(Object)to apply this values to the new instance. Default implementation returns null.@Override public Budget copy() { final Budget copy = new Budget(); copy.apply(this); return copy; }- Returns:
- a deep copy
-
apply
default T apply(T source)
Apply values from source to this object. It should not handle lists, sets and other complicated things. The default implementation is based onReflectionUtils.shallowCopyFieldState(Object, Object)but it only uses accessible fields and ignores Collections.- Parameters:
source- the source- Returns:
- the t
-
-