cloner 1.0.4
cloner: ^1.0.4 copied to clipboard
Utilities for deep cloning collections and custom types with flexible extension points and optional circular reference detection.
1.0.4 #
Added #
SetClonewrapper for typed nested set cloning that enables safe deep cloning of nested sets while preserving both the element type and the runtime set implementation. UseSetClonefor cases where you need to clone nested typed sets and retain their concrete collection type- IRestorable interface: Added
IRestorable, which provides areset()method for cloners that maintain internal state. BothCountedClonerandHashedClonernow implementIRestorable, allowing their internal counters or hash tracking to be reset between clone operations
Fixed #
cloneValueforICloneablenow correctly passes the cloner instance- Preservation of set and map concrete types:
SetCloneandMapClonenow more reliably preserve the underlying collection implementation (e.g.,LinkedHashSet,HashSet) during cloning and copying
1.0.3 #
Added #
- Serialization support for cloner builders: Major cloner builders (
BaseClonerBuilder,CountedClonerBuilder,HashedClonerBuilder) now implementISerializable, allowing serialization and deserialization of builder configuration to/from strings. This enables saving and restoring cloner settings (can be handy for isolates) - Builder serialization helpers
serializeBaseFlaganddeserializeBaseFlagfor encoding/decoding cloner configuration flags - Exception hierarchy: Introduced
ACloneExceptionandASerializationExceptionas base classes for cloning and serialization errors, respectively. Specific exceptions (e.g.,UnsupportedTypedCloneException,LimitExceededException,CircularReferenceCloneException,DeserializationFormatException) now extend these bases
Changed #
ICloneable<T>.clone()method now accepts an optionalICloningparameter, allowing custom clone logic to receive the current cloner instance
Deprecations
replicate()method has been removed. Use the builder pattern (*Builder().build()) for cloner instantiation and configurationCloner.referenceproperty is removed. UseCloner.builderandCloner.instance()for global cloner configuration and access.
1.0.2 #
Added #
- Builder pattern for cloners: All cloner implementations (
BaseCloner,CountedCloner,HashedCloner) now have corresponding*Builderclasses (e.g.,BaseClonerBuilder) for configuration and instantiation. This enables more flexible and idiomatic cloner construction - AdaptiveCloner: New
AdaptiveClonerandAdaptiveClonerBuilderfor dispatching cloning operations to different delegate cloners based on configuration (e.g., AOT/JIT, collection type) MClonerLoggingmixin: AddMClonerLoggingfor logging clone operations, with log history and optional printing.- Extensions accept custom cloner: Collection extension methods (
clone,cloneDynamic) now accept an optionalclonerparameter for explicit cloner usage
Changed #
- Global cloner API:
Cloner.referenceis deprecated in favor ofCloner.builder(to leverage aforementioned builder pattern for global cloner configuration) Cloner.instancenow uses the builder- DEPRECATED
replicate(): Thereplicate()method on cloners is deprecated and will be removed in a future release - Extensions: Collection extensions now use the builder-based cloner and allow passing a custom cloner
Fixed #
CountedClonernesting depth limit now takes in account only collections (cloneValue()is excluded)
1.0.1 #
Added #
- New
CountedClonerandHashedClonerimplementations:CountedClonerenforces recursion depth and total clone count limits to prevent stack overflows and runaway cloning.HashedClonerprovides circular reference detection for collections, throwingCircularReferenceCloneExceptionon cycles.
LimitExceededExceptionfor reporting exceeded size/nesting limits during cloning.- Benchmarks and performance recommendations for different cloner implementations (see doc/benchmarks)
Changed #
Clonernow usesCountedCloneras the default global cloner instead ofBaseClonerICloning.replicatesignature simplified: removeddoCircRefCheckparameter (circular reference detection is now handled byHashedCloner)- Collection extension methods (
clone,cloneDynamic) no longer acceptdoCircRefCheckparameter - Improved documentation and README with new "Benchmarks" and "Worth Noting" sections
Fixed #
- Improved test coverage for circular reference and limit enforcement scenarios
1.0.0 #
Initial version #
ICloneableandICopyablecontracts for custom deep/shallow copy supportClonerfacade with pluggable backendBaseClonerdefault implementation andICloninginterface for custom cloners- Element/value-wise deep cloning for
List,Set, andMap - Optional circular-reference detection
- Element/value-wise deep cloning for
- Collection extensions:
List.clone()/Set.clone()/Map.clone() MapClonetyped map wrapper for safe nested typed map cloning andcopy()/clone()helpers- Typed-clone safety checks and
UnsupportedTypedCloneExceptionfor unsupported typed scenarios - Preserves common concrete collection implementations (
LinkedHashMap,HashMap) where possible