Copyable

interface Copyable<out SOURCE>

Defines a contract for copy operations, allowing objects implementing this interface to create copies of themselves.

This interface provides a type-safe way to duplicate objects, ensuring that modifications to the copy do not affect the original instance. The generic parameter SOURCE represents the type of the source object, which is concretized by implementing classes.

Implementations should create deep copies where appropriate to prevent unintended side effects when the copied object is modified.

Parameters

SOURCE

The type of the source object, specified by the implementing class. This is a covariant generic parameter (declared with 'out') to allow more specific types in implementations while maintaining type safety.

Samples

Inheritors

Functions

Link copied to clipboard
abstract fun copy(): SOURCE

Creates and returns a copy of the current object.