View Javadoc
1   // =================== DO NOT EDIT THIS FILE ====================
2   //  Generated by Modello Velocity from model-v3.vm
3   //  template, any modifications will be overwritten.
4   // ==============================================================
5   package org.apache.maven.model;
6   
7   import java.io.Serializable;
8   import java.util.AbstractList;
9   import java.util.ArrayList;
10  import java.util.Collections;
11  import java.util.HashMap;
12  import java.util.List;
13  import java.util.Map;
14  import java.util.Objects;
15  import java.util.Set;
16  import java.util.stream.Collectors;
17  import java.util.stream.Stream;
18  import org.apache.maven.api.annotations.Generated;
19  import org.apache.maven.api.annotations.Nonnull;
20  
21  @Generated
22  public class PluginContainer
23      extends BaseObject
24  {
25  
26      public PluginContainer() {
27          this(org.apache.maven.api.model.PluginContainer.newInstance());
28      }
29  
30      public PluginContainer(org.apache.maven.api.model.PluginContainer delegate) {
31          this(delegate, null);
32      }
33  
34      public PluginContainer(org.apache.maven.api.model.PluginContainer delegate, BaseObject parent) {
35          super(delegate, parent);
36      }
37  
38      public PluginContainer clone(){
39          return new PluginContainer(getDelegate());
40      }
41  
42      public org.apache.maven.api.model.PluginContainer getDelegate() {
43          return (org.apache.maven.api.model.PluginContainer) super.getDelegate();
44      }
45  
46      @Override
47      public boolean equals(Object o) {
48          if (this == o) {
49              return true;
50          }
51          if (o == null || !(o instanceof PluginContainer)) {
52              return false;
53          }
54          PluginContainer that = (PluginContainer) o;
55          return Objects.equals(this.delegate, that.delegate);
56      }
57  
58      @Override
59      public int hashCode() {
60          return getDelegate().hashCode();
61      }
62  
63      @Nonnull
64      public List<Plugin> getPlugins() {
65          return new WrapperList<Plugin, org.apache.maven.api.model.Plugin>(
66                      () -> getDelegate().getPlugins(), l -> update(getDelegate().withPlugins(l)),
67                      d -> new Plugin(d, this), Plugin::getDelegate);
68      }
69  
70      public void setPlugins(List<Plugin> plugins) {
71          if (plugins == null) {
72              plugins = Collections.emptyList();
73          }
74          if (!Objects.equals(plugins, getPlugins())) {
75              update(getDelegate().withPlugins(
76                  plugins.stream().map(c -> c.getDelegate()).collect(Collectors.toList())));
77              plugins.forEach(e -> e.childrenTracking = this::replace);
78          }
79      }
80  
81      public void addPlugin(Plugin plugin) {
82          update(getDelegate().withPlugins(
83                 Stream.concat(getDelegate().getPlugins().stream(), Stream.of(plugin.getDelegate()))
84                          .collect(Collectors.toList())));
85          plugin.childrenTracking = this::replace;
86      }
87  
88      public void removePlugin(Plugin plugin) {
89          update(getDelegate().withPlugins(
90                 getDelegate().getPlugins().stream()
91                          .filter(e -> !Objects.equals(e, plugin))
92                          .collect(Collectors.toList())));
93          plugin.childrenTracking = null;
94      }
95  
96      public InputLocation getLocation(Object key) {
97          org.apache.maven.api.model.InputLocation loc = getDelegate().getLocation(key);
98          return loc != null ? new InputLocation(loc) : null;
99      }
100 
101     public void setLocation(Object key, InputLocation location) {
102         update(org.apache.maven.api.model.PluginContainer.newBuilder(getDelegate(), true)
103                         .location(key, location.toApiLocation()).build());
104     }
105 
106     public InputLocation getImportedFrom() {
107         org.apache.maven.api.model.InputLocation loc = getDelegate().getImportedFrom();
108         return loc != null ? new InputLocation(loc) : null;
109     }
110 
111     public void setImportedFrom(InputLocation location) {
112         update(org.apache.maven.api.model.PluginContainer.newBuilder(getDelegate(), true)
113                         .importedFrom(location.toApiLocation()).build());
114     }
115 
116     public Set<Object> getLocationKeys() {
117         return getDelegate().getLocationKeys();
118     }
119 
120     protected boolean replace(Object oldDelegate, Object newDelegate) {
121         if (super.replace(oldDelegate, newDelegate)) {
122             return true;
123         }
124         if (getDelegate().getPlugins().contains(oldDelegate)) {
125             List<org.apache.maven.api.model.Plugin> list = new ArrayList<>(getDelegate().getPlugins());
126             list.replaceAll(d -> d == oldDelegate ? (org.apache.maven.api.model.Plugin) newDelegate : d);
127             update(getDelegate().withPlugins(list));
128             return true;
129         }
130         return false;
131     }
132 
133     public static List<org.apache.maven.api.model.PluginContainer> pluginContainerToApiV4(List<PluginContainer> list) {
134         return list != null ? new WrapperList<>(list, PluginContainer::getDelegate, PluginContainer::new) : null;
135     }
136 
137     public static List<PluginContainer> pluginContainerToApiV3(List<org.apache.maven.api.model.PluginContainer> list) {
138         return list != null ? new WrapperList<>(list, PluginContainer::new, PluginContainer::getDelegate) : null;
139     }
140 
141 
142             
143     /**
144      * Reset the {@code pluginsMap} field to {@code null}
145      */
146     public void flushPluginMap() {
147     }
148 
149     /**
150      * @return a Map of plugins field with {@code Plugins#getKey()} as key
151      * @see Plugin#getKey()
152      */
153     public Map<String, Plugin> getPluginsAsMap() {
154         return getPlugins().stream().collect(Collectors.toMap(plugin -> plugin.getKey(), plugin -> plugin));
155     }
156             
157           
158 
159             
160      @Override
161      public String toString()
162      {
163          return "PluginContainer {}";
164      }
165             
166           
167 }