fun deepCopy()

in core/package/src/main/kotlin/io/klibs/core/pckg/entity/PackageEntity.kt [121:170]


    fun deepCopy(
        id: Long? = this.id,
        projectId: Int? = this.projectId,
        repo: ScraperType = this.repo,
        groupId: String = this.groupId,
        artifactId: String = this.artifactId,
        version: String = this.version,
        releaseTs: Instant = this.releaseTs,
        name: String = this.name,
        description: String? = this.description,
        url: String? = this.url,
        scmUrl: String? = this.scmUrl,
        buildTool: String = this.buildTool,
        buildToolVersion: String = this.buildToolVersion,
        kotlinVersion: String = this.kotlinVersion,
        developers: List<PackageDeveloper> = this.developers,
        licenses: List<PackageLicense> = this.licenses,
        configuration: Configuration? = this.configuration,
        generatedDescription: Boolean = this.generatedDescription
    ): PackageEntity {
        // Create a copy of the entity with specified fields changed
        val copy = PackageEntity(
            id = id,
            projectId = projectId,
            repo = repo,
            groupId = groupId,
            artifactId = artifactId,
            version = version,
            releaseTs = releaseTs,
            name = name,
            description = description,
            url = url,
            scmUrl = scmUrl,
            buildTool = buildTool,
            buildToolVersion = buildToolVersion,
            kotlinVersion = kotlinVersion,
            developers = developers,
            licenses = licenses,
            configuration = configuration,
            generatedDescription = generatedDescription
        )

        // Create new copies of each target and attach them to the new entity
        this.targets.forEach { target ->
            val targetCopy = target.copy(packageEntity = null)
            copy.addTarget(targetCopy)
        }

        return copy
    }