tech.jhipster.lite.module.infrastructure.secondary.npm.JHipsterNpmVersions Maven / Gradle / Ivy
package tech.jhipster.lite.module.infrastructure.secondary.npm;
import java.util.Collection;
import java.util.function.Supplier;
import org.springframework.stereotype.Repository;
import tech.jhipster.lite.module.domain.npm.NpmPackagesVersions;
import tech.jhipster.lite.module.domain.npm.NpmVersions;
import tech.jhipster.lite.shared.memoizer.domain.Memoizers;
@Repository
class JHipsterNpmVersions implements NpmVersions {
private final Supplier versions;
public JHipsterNpmVersions(Collection readers) {
versions = Memoizers.of(versionsReader(readers));
}
private Supplier versionsReader(Collection readers) {
return () -> readers.stream().map(NpmVersionsReader::get).reduce(NpmPackagesVersions.EMPTY, NpmPackagesVersions::merge);
}
@Override
public NpmPackagesVersions get() {
return versions.get();
}
}