tech.jhipster.lite.module.domain.packagejson.JHipsterModulePackageJson Maven / Gradle / Ivy
package tech.jhipster.lite.module.domain.packagejson;
import java.util.*;
import java.util.stream.Stream;
import tech.jhipster.lite.module.domain.JHipsterModule.JHipsterModuleBuilder;
import tech.jhipster.lite.shared.error.domain.Assert;
/**
* This class represents the {@code package.json} configurations for a JHipster module.
* It includes scripts, dependencies, development dependencies, and configurations
* for removing unnecessary dependencies.
*/
public final class JHipsterModulePackageJson {
private final Scripts scripts;
private final PackageJsonDependencies dependencies;
private final PackageNames dependenciesToRemove;
private final PackageJsonDependencies devDependencies;
private final PackageNames devDependenciesToRemove;
private final Optional nodeModuleFormat;
private JHipsterModulePackageJson(JHipsterModulePackageJsonBuilder builder) {
scripts = new Scripts(builder.scripts);
dependencies = new PackageJsonDependencies(builder.dependencies);
dependenciesToRemove = new PackageNames(builder.dependenciesToRemove);
devDependencies = new PackageJsonDependencies(builder.devDependencies);
devDependenciesToRemove = new PackageNames(builder.devDependenciesToRemove);
nodeModuleFormat = Optional.ofNullable(builder.nodeModuleFormat);
}
public static JHipsterModulePackageJsonBuilder builder(JHipsterModuleBuilder module) {
return new JHipsterModulePackageJsonBuilder(module);
}
public boolean isEmpty() {
return (
nodeModuleFormat.isEmpty() &&
scripts.isEmpty() &&
dependencies.isEmpty() &&
devDependencies.isEmpty() &&
dependenciesToRemove.isEmpty() &&
devDependenciesToRemove.isEmpty()
);
}
public Scripts scripts() {
return scripts;
}
public PackageJsonDependencies devDependencies() {
return devDependencies;
}
public PackageJsonDependencies dependencies() {
return dependencies;
}
public PackageNames devDependenciesToRemove() {
return devDependenciesToRemove;
}
public PackageNames dependenciesToRemove() {
return dependenciesToRemove;
}
public Optional nodeModuleFormat() {
return nodeModuleFormat;
}
public static final class JHipsterModulePackageJsonBuilder {
private final JHipsterModuleBuilder module;
private final Collection