
org.apache.maven.model.Plugin Maven / Gradle / Ivy
// =================== DO NOT EDIT THIS FILE ====================
// Generated by Modello Velocity from model-v3.vm
// template, any modifications will be overwritten.
// ==============================================================
package org.apache.maven.model;
import java.io.Serializable;
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.maven.api.annotations.Generated;
import org.apache.maven.api.annotations.Nonnull;
import org.codehaus.plexus.util.xml.Xpp3Dom;
@Generated
public class Plugin
extends ConfigurationContainer
implements Serializable, Cloneable
{
public Plugin() {
this(org.apache.maven.api.model.Plugin.newInstance());
}
public Plugin(org.apache.maven.api.model.Plugin delegate) {
this(delegate, null);
}
public Plugin(org.apache.maven.api.model.Plugin delegate, BaseObject parent) {
super(delegate, parent);
}
public Plugin clone(){
return new Plugin(getDelegate());
}
@Override
public org.apache.maven.api.model.Plugin getDelegate() {
return (org.apache.maven.api.model.Plugin) super.getDelegate();
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || !(o instanceof Plugin)) {
return false;
}
Plugin that = (Plugin) o;
return Objects.equals(this.delegate, that.delegate);
}
@Override
public int hashCode() {
return getDelegate().hashCode();
}
public String getGroupId() {
return getDelegate().getGroupId();
}
public void setGroupId(String groupId) {
if (!Objects.equals(groupId, getGroupId())) {
update(getDelegate().withGroupId(groupId));
}
}
public String getArtifactId() {
return getDelegate().getArtifactId();
}
public void setArtifactId(String artifactId) {
if (!Objects.equals(artifactId, getArtifactId())) {
update(getDelegate().withArtifactId(artifactId));
}
}
public String getVersion() {
return getDelegate().getVersion();
}
public void setVersion(String version) {
if (!Objects.equals(version, getVersion())) {
update(getDelegate().withVersion(version));
}
}
public String getExtensions() {
return getDelegate().getExtensions();
}
public void setExtensions(String extensions) {
if (!Objects.equals(extensions, getExtensions())) {
update(getDelegate().withExtensions(extensions));
}
}
@Nonnull
public List getExecutions() {
return new WrapperList(
() -> getDelegate().getExecutions(), l -> update(getDelegate().withExecutions(l)),
d -> new PluginExecution(d, this), PluginExecution::getDelegate);
}
public void setExecutions(List executions) {
if (executions == null) {
executions = Collections.emptyList();
}
if (!Objects.equals(executions, getExecutions())) {
update(getDelegate().withExecutions(
executions.stream().map(c -> c.getDelegate()).collect(Collectors.toList())));
executions.forEach(e -> e.childrenTracking = this::replace);
}
}
public void addExecution(PluginExecution execution) {
update(getDelegate().withExecutions(
Stream.concat(getDelegate().getExecutions().stream(), Stream.of(execution.getDelegate()))
.collect(Collectors.toList())));
execution.childrenTracking = this::replace;
}
public void removeExecution(PluginExecution execution) {
update(getDelegate().withExecutions(
getDelegate().getExecutions().stream()
.filter(e -> !Objects.equals(e, execution))
.collect(Collectors.toList())));
execution.childrenTracking = null;
}
@Nonnull
public List getDependencies() {
return new WrapperList(
() -> getDelegate().getDependencies(), l -> update(getDelegate().withDependencies(l)),
d -> new Dependency(d, this), Dependency::getDelegate);
}
public void setDependencies(List dependencies) {
if (dependencies == null) {
dependencies = Collections.emptyList();
}
if (!Objects.equals(dependencies, getDependencies())) {
update(getDelegate().withDependencies(
dependencies.stream().map(c -> c.getDelegate()).collect(Collectors.toList())));
dependencies.forEach(e -> e.childrenTracking = this::replace);
}
}
public void addDependency(Dependency dependency) {
update(getDelegate().withDependencies(
Stream.concat(getDelegate().getDependencies().stream(), Stream.of(dependency.getDelegate()))
.collect(Collectors.toList())));
dependency.childrenTracking = this::replace;
}
public void removeDependency(Dependency dependency) {
update(getDelegate().withDependencies(
getDelegate().getDependencies().stream()
.filter(e -> !Objects.equals(e, dependency))
.collect(Collectors.toList())));
dependency.childrenTracking = null;
}
public InputLocation getLocation(Object key) {
org.apache.maven.api.model.InputLocation loc = getDelegate().getLocation(key);
return loc != null ? new InputLocation(loc) : null;
}
public void setLocation(Object key, InputLocation location) {
update(org.apache.maven.api.model.Plugin.newBuilder(getDelegate(), true)
.location(key, location.toApiLocation()).build());
}
protected boolean replace(Object oldDelegate, Object newDelegate) {
if (super.replace(oldDelegate, newDelegate)) {
return true;
}
if (getDelegate().getExecutions().contains(oldDelegate)) {
List list = new ArrayList<>(getDelegate().getExecutions());
list.replaceAll(d -> d == oldDelegate ? (org.apache.maven.api.model.PluginExecution) newDelegate : d);
update(getDelegate().withExecutions(list));
return true;
}
if (getDelegate().getDependencies().contains(oldDelegate)) {
List list = new ArrayList<>(getDelegate().getDependencies());
list.replaceAll(d -> d == oldDelegate ? (org.apache.maven.api.model.Dependency) newDelegate : d);
update(getDelegate().withDependencies(list));
return true;
}
return false;
}
public static List pluginToApiV4(List list) {
return list != null ? new WrapperList<>(list, Plugin::getDelegate, Plugin::new) : null;
}
public static List pluginToApiV3(List list) {
return list != null ? new WrapperList<>(list, Plugin::new, Plugin::getDelegate) : null;
}
public boolean isExtensions() {
return (getExtensions() != null) ? Boolean.parseBoolean(getExtensions()) : false;
}
public void setExtensions(boolean extensions) {
setExtensions(String.valueOf(extensions));
}
private Map executionMap = null;
/**
* Reset the {@code executionMap} field to {@code null}
*/
public void flushExecutionMap() {
this.executionMap = null;
}
/**
* @return a Map of executions field with {@code PluginExecution#getId()} as key
* @see PluginExecution#getId()
*/
public Map getExecutionsAsMap() {
if (executionMap == null) {
executionMap = new java.util.LinkedHashMap();
for (java.util.Iterator i = getExecutions().iterator(); i.hasNext();) {
PluginExecution exec = (PluginExecution) i.next();
if (executionMap.containsKey(exec.getId())) {
throw new IllegalStateException("You cannot have two plugin executions with the same (or missing) elements.\nOffending execution\n\nId: \'" + exec.getId() + "\'\nPlugin:\'" + getKey() + "\'\n\n");
}
executionMap.put(exec.getId(), exec);
}
}
return executionMap;
}
/**
* Gets the identifier of the plugin.
*
* @return the plugin id in the form {@code ::}, never {@code null}
*/
public String getId() {
return new StringBuilder(128)
.append((getGroupId() == null) ? "[unknown-group-id]" : getGroupId())
.append(":")
.append((getArtifactId() == null) ? "[unknown-artifact-id]" : getArtifactId())
.append(":")
.append((getVersion() == null) ? "[unknown-version]" : getVersion())
.toString();
}
/**
* @return the key of the plugin, ie {@code groupId:artifactId}
*/
public String getKey() {
return constructKey(getGroupId(), getArtifactId());
}
/**
* @param groupId the group ID of the plugin in the repository
* @param artifactId the artifact ID of the reporting plugin in the repository
* @return the key of the plugin, ie {@code groupId:artifactId}
*/
public static String constructKey(String groupId, String artifactId) {
return groupId + ":" + artifactId;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy