tech.jhipster.lite.module.domain.javabuild.command.AddMavenPluginBuilder Maven / Gradle / Ivy
package tech.jhipster.lite.module.domain.javabuild.command;
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.function.Function;
import tech.jhipster.lite.module.domain.javabuildprofile.BuildProfileId;
import tech.jhipster.lite.module.domain.javadependency.JavaDependencyVersion;
import tech.jhipster.lite.module.domain.mavenplugin.MavenPlugin;
class AddMavenPluginBuilder implements AddMavenPluginPluginBuilder, AddMavenPluginOptionalBuilder {
private final Function, T> factory;
private MavenPlugin plugin;
private JavaDependencyVersion pluginVersion;
private BuildProfileId buildProfile;
private final Collection dependenciesVersions = new LinkedHashSet<>();
AddMavenPluginBuilder(Function, T> factory) {
this.factory = factory;
}
public MavenPlugin plugin() {
return plugin;
}
public JavaDependencyVersion pluginVersion() {
return pluginVersion;
}
public BuildProfileId buildProfile() {
return buildProfile;
}
public Collection dependenciesVersions() {
return dependenciesVersions;
}
@Override
public AddMavenPluginBuilder plugin(MavenPlugin plugin) {
this.plugin = plugin;
return this;
}
@Override
public AddMavenPluginOptionalBuilder pluginVersion(JavaDependencyVersion pluginVersion) {
this.pluginVersion = pluginVersion;
return this;
}
@Override
public AddMavenPluginOptionalBuilder buildProfile(BuildProfileId buildProfile) {
this.buildProfile = buildProfile;
return this;
}
@Override
public AddMavenPluginOptionalBuilder addDependencyVersion(JavaDependencyVersion dependencyVersion) {
this.dependenciesVersions.add(dependencyVersion);
return this;
}
@Override
public T build() {
return factory.apply(this);
}
}