All Downloads are FREE. Search and download functionalities are using the official Maven repository.

tech.jhipster.lite.module.domain.landscape.JHipsterLandscapeFeature Maven / Gradle / Ivy

There is a newer version: 1.22.0
Show newest version
package tech.jhipster.lite.module.domain.landscape;

import java.util.Collection;
import java.util.Optional;
import java.util.stream.Stream;
import tech.jhipster.lite.module.domain.JHipsterFeatureSlug;
import tech.jhipster.lite.module.domain.JHipsterSlug;
import tech.jhipster.lite.shared.error.domain.Assert;

public final class JHipsterLandscapeFeature implements JHipsterLandscapeElement {

  private final JHipsterFeatureSlug slug;
  private final Collection modules;
  private final Optional dependencies;

  public JHipsterLandscapeFeature(JHipsterFeatureSlug slug, Collection modules) {
    Assert.notNull("slug", slug);
    Assert.notNull("modules", modules);

    this.slug = slug;
    this.modules = modules;
    dependencies = buildDependencies();
  }

  private Optional buildDependencies() {
    return JHipsterLandscapeDependencies.of(
      modules()
        .stream()
        .map(JHipsterLandscapeModule::dependencies)
        .flatMap(Optional::stream)
        .flatMap(JHipsterLandscapeDependencies::stream)
        .toList()
    );
  }

  @Override
  public JHipsterFeatureSlug slug() {
    return slug;
  }

  public Collection modules() {
    return modules;
  }

  @Override
  public Optional dependencies() {
    return dependencies;
  }

  @Override
  public Stream allModules() {
    return modules.stream();
  }

  @Override
  public Stream slugs() {
    return Stream.concat(Stream.of(slug()), allModules().map(JHipsterLandscapeModule::slug));
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy