Package io.github.ai4ci.util
Class Cloner
java.lang.Object
io.github.ai4ci.util.Cloner
Utility for making deep copies (vs. clone()'s shallow copies) of
objects. Objects are first serialized and then deserialized. Error
checking is fairly minimal in this implementation. If an object is
encountered that cannot be serialized (or that references an object
that cannot be serialized) an error is printed to System.err and
null is returned. Depending on your specific application, it might
make more sense to have copy(...) re-throw the exception.
from: https://javatechniques.com/blog/faster-deep-copies-of-java-objects/
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
ByteArrayInputStream implementation that does not synchronize methods.static class
ByteArrayOutputStream implementation that doesn't synchronize methods and doesn't copy the data on toByteArray().static class
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <X extends Serializable>
Xcopy
(X orig) Returns a copy of the object, or null if the object cannot be serialized.static <X extends Serializable>
Xcopy
(X orig, long estimatedSize) static long
estimateSize
(Object obj)
-
Constructor Details
-
Cloner
public Cloner()
-
-
Method Details
-
copy
Returns a copy of the object, or null if the object cannot be serialized. -
copy
-
estimateSize
-