Package io.github.connellite.cloner
Class ReflectionCloning
java.lang.Object
io.github.connellite.cloner.ReflectionCloning
Deep / shallow cloning via reflection. Instances are created with the no-arg constructor
(see
ReflectionUtil.getInstance(Class)); classes without one cannot be cloned this way.
Common immutable JDK types (including String) are not traversed: the same instance is reused.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Tclone(T original) Deep clone: copies the object graph; shared references become shared in the clone unless broken by cycle handling.static <T> TshallowClone(T original) Shallow clone: new outer instance; field values are the same references as in the original.
-
Constructor Details
-
ReflectionCloning
public ReflectionCloning()
-
-
Method Details
-
clone
public static <T> T clone(T original) Deep clone: copies the object graph; shared references become shared in the clone unless broken by cycle handling. -
shallowClone
public static <T> T shallowClone(T original) Shallow clone: new outer instance; field values are the same references as in the original.
-