
org.apache.maven.model.PluginContainer 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;
@Generated
public class PluginContainer
extends BaseObject
{
public PluginContainer() {
this(org.apache.maven.api.model.PluginContainer.newInstance());
}
public PluginContainer(org.apache.maven.api.model.PluginContainer delegate) {
this(delegate, null);
}
public PluginContainer(org.apache.maven.api.model.PluginContainer delegate, BaseObject parent) {
super(delegate, parent);
}
public PluginContainer clone(){
return new PluginContainer(getDelegate());
}
public org.apache.maven.api.model.PluginContainer getDelegate() {
return (org.apache.maven.api.model.PluginContainer) super.getDelegate();
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || !(o instanceof PluginContainer)) {
return false;
}
PluginContainer that = (PluginContainer) o;
return Objects.equals(this.delegate, that.delegate);
}
@Override
public int hashCode() {
return getDelegate().hashCode();
}
@Nonnull
public List getPlugins() {
return new WrapperList(
() -> getDelegate().getPlugins(), l -> update(getDelegate().withPlugins(l)),
d -> new Plugin(d, this), Plugin::getDelegate);
}
public void setPlugins(List plugins) {
if (plugins == null) {
plugins = Collections.emptyList();
}
if (!Objects.equals(plugins, getPlugins())) {
update(getDelegate().withPlugins(
plugins.stream().map(c -> c.getDelegate()).collect(Collectors.toList())));
plugins.forEach(e -> e.childrenTracking = this::replace);
}
}
public void addPlugin(Plugin plugin) {
update(getDelegate().withPlugins(
Stream.concat(getDelegate().getPlugins().stream(), Stream.of(plugin.getDelegate()))
.collect(Collectors.toList())));
plugin.childrenTracking = this::replace;
}
public void removePlugin(Plugin plugin) {
update(getDelegate().withPlugins(
getDelegate().getPlugins().stream()
.filter(e -> !Objects.equals(e, plugin))
.collect(Collectors.toList())));
plugin.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.PluginContainer.newBuilder(getDelegate(), true)
.location(key, location.toApiLocation()).build());
}
protected boolean replace(Object oldDelegate, Object newDelegate) {
if (super.replace(oldDelegate, newDelegate)) {
return true;
}
if (getDelegate().getPlugins().contains(oldDelegate)) {
List list = new ArrayList<>(getDelegate().getPlugins());
list.replaceAll(d -> d == oldDelegate ? (org.apache.maven.api.model.Plugin) newDelegate : d);
update(getDelegate().withPlugins(list));
return true;
}
return false;
}
public static List pluginContainerToApiV4(List list) {
return list != null ? new WrapperList<>(list, PluginContainer::getDelegate, PluginContainer::new) : null;
}
public static List pluginContainerToApiV3(List list) {
return list != null ? new WrapperList<>(list, PluginContainer::new, PluginContainer::getDelegate) : null;
}
Map pluginMap;
/**
* Reset the {@code pluginsMap} field to {@code null}
*/
public synchronized void flushPluginMap()
{
this.pluginMap = null;
}
/**
* @return a Map of plugins field with {@code Plugins#getKey()} as key
* @see Plugin#getKey()
*/
public synchronized Map getPluginsAsMap()
{
if ( pluginMap == null )
{
pluginMap = new java.util.LinkedHashMap();
if ( getPlugins() != null )
{
for ( java.util.Iterator it = getPlugins().iterator(); it.hasNext(); )
{
Plugin plugin = (Plugin) it.next();
pluginMap.put( plugin.getKey(), plugin );
}
}
}
return pluginMap;
}
@Override
public String toString()
{
return "PluginContainer {}";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy