class CmsPsuPiisServiceInternal implements CmsPsuPiisService {

    @Override
    public @NotNull Optional<CmsPiisConsent> getConsent(@NotNull PsuIdData psuIdData, @NotNull String consentId, @NotNull String instanceId) {
        return consentJpaRepository.findOne(piisConsentEntitySpecification.byConsentIdAndInstanceId(consentId, instanceId))
                   .filter(con -> isPsuIdDataContentEquals(con, psuIdData))
                   .map(piisConsentLazyMigrationService::migrateIfNeeded)
                   .map(piisConsentMapper::mapToCmsPiisConsent);
    }

}