class SW360MetaDataUpdater {

    public SW360Release getOrCreateRelease(SW360Release sw360ReleaseFromArtifact, boolean updateExisting) {
        Optional<SW360SparseRelease> optSparseReleaseByIds =
                releaseClientAdapter.getSparseReleaseByExternalIds(sw360ReleaseFromArtifact.getExternalIds());
        Optional<SW360SparseRelease> optSparseRelease = optSparseReleaseByIds.isPresent() ? optSparseReleaseByIds :
                releaseClientAdapter.getSparseReleaseByNameAndVersion(sw360ReleaseFromArtifact.getName(),
                        sw360ReleaseFromArtifact.getVersion());
        Optional<SW360Release> optRelease = optSparseRelease.flatMap(releaseClientAdapter::enrichSparseRelease)
                .map(sw360ReleaseFromArtifact::mergeWith);

        if (optRelease.isPresent()) {
            SW360Release release = optRelease.get();
            return updateExisting ?
                    releaseClientAdapter.updateRelease(release) : release;
        }
        return releaseClientAdapter.createRelease(sw360ReleaseFromArtifact);
    }

    public  SW360MetaDataUpdater(SW360Connection connection);

}