Package utils
Class DeepCopier
java.lang.Object
utils.DeepCopier
Utility class providing methods to perform deep copies of objects using either:
- Java Serialization (forced for Attribute trees and preferred for Serializable objects)
- Gson-based JSON serialisation (fallback for non-Attribute, non-Serializable types)
This approach ensures users don't need to register Attribute subclasses for Gson.
-
Method Summary
-
Method Details
-
deepCopy
Creates a deep copy of the given object.Uses Java serialization for Attribute subclasses or Serializable objects. Falls back to Gson if neither applies.
- Type Parameters:
T- the type of the object- Parameters:
original- the object to be copiedclazz- the class of the object (used only for Gson fallback)- Returns:
- a deep copy of the original object
-
deepCopy
Creates a deep copy of the given object using a specifiedType. Always uses Gson (no Attribute handling).- Type Parameters:
T- the type of the object- Parameters:
original- the object to be copiedtypeOfT- the specific type information of the object- Returns:
- a deep copy of the original object
-