Repository: corona-warn-app/cwa-app-android
File: Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/recovery/core/RecoveryCertificateRepository.kt (Kotlin)

Code before:
                    this[certificateToReplace] = it
                }
                // add new
                this[newCertificate.containerId] = newCertificate
            }
        }
    }

    private fun RecoveryCertificateContainer.setRecycled(value: Boolean): RecoveryCertificateContainer {
        return copy(data = data.copy(recycledAt = if (value) timeStamper.nowUTC else null)).also {
            Timber.tag(TAG).d("recycleCertificate %s %s", value, it.containerId)
        }
    }

    private fun RecoveryCertificateContainer.markAsSeenByUser(): RecoveryCertificateContainer {
        return copy(data = data.copy(certificateSeenByUser = true)).also {
            Timber.tag(TAG).d("markAsSeenByUser %s", it.containerId)
        }
    }

    private fun RecoveryCertificateContainer.toRecoveryCertificateOrNull(
        valueSet: VaccinationValueSets?,
        certificateState: CwaCovidCertificate.State
    ): RecoveryCertificate? {
        try {
            return toRecoveryCertificate(valueSet, certificateState)
        } catch (e: Exception) {
            Timber.e(e, "Creating RecoveryCertificate failed")
        }
        return null
    }

    private suspend fun RecoveryCertificateContainer.toRecoveryCertificateWrapper(
        valueSets: VaccinationValueSets,
        dccValidityMeasures: DccValidityMeasures
    ): RecoveryCertificateWrapper? {
        try {
            val state = dccState(
                dccData = certificateData,
                qrCodeHash = qrCodeHash,
                dccValidityMeasures = dccValidityMeasures
            )

            return RecoveryCertificateWrapper(
                valueSets = valueSets,
                container = this,
                certificateState = state
            )
        } catch (e: Exception) {
            Timber.e(e, "Creating RecoveryCertificateWrapper failed")
        }

Review comment (refactor):
```suggestion
            return toRecoveryCertificate(valueSet, certificateState)
            // read value from dcc data to throw an exception early if the DccQrCodeExtractor is not able to parse
            // the certificate
```

Code after:
                    this[certificateToReplace] = it
                }
                // add new
                this[newCertificate.containerId] = newCertificate
            }
        }
    }

    private fun RecoveryCertificateContainer.setRecycled(value: Boolean): RecoveryCertificateContainer {
        return copy(data = data.copy(recycledAt = if (value) timeStamper.nowUTC else null)).also {
            Timber.tag(TAG).d("recycleCertificate %s %s", value, it.containerId)
        }
    }

    private fun RecoveryCertificateContainer.markAsSeenByUser(): RecoveryCertificateContainer {
        return copy(data = data.copy(certificateSeenByUser = true)).also {
            Timber.tag(TAG).d("markAsSeenByUser %s", it.containerId)
        }
    }

    private fun RecoveryCertificateContainer.toRecoveryCertificateOrNull(
        valueSet: VaccinationValueSets?,
        certificateState: CwaCovidCertificate.State
    ): RecoveryCertificate? {
        try {
            return toRecoveryCertificate(valueSet, certificateState)
            // read value from dcc data to throw an exception early if the DccQrCodeExtractor is not able to parse
            // the certificate
        } catch (e: Exception) {
            Timber.e(e, "Creating RecoveryCertificate failed")
        }
        return null
    }

    private suspend fun RecoveryCertificateContainer.toRecoveryCertificateWrapper(
        valueSets: VaccinationValueSets,
        dccValidityMeasures: DccValidityMeasures
    ): RecoveryCertificateWrapper? {
        try {
            val state = dccState(
                dccData = certificateData,
                qrCodeHash = qrCodeHash,
                dccValidityMeasures = dccValidityMeasures
            )

            return RecoveryCertificateWrapper(
                valueSets = valueSets,
                container = this,
                certificateState = state
            )
        } catch (e: Exception) {