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.toolchain.model;
6   
7   import java.io.Serializable;
8   import java.util.AbstractList;
9   import java.util.Collections;
10  import java.util.HashMap;
11  import java.util.List;
12  import java.util.Map;
13  import java.util.Objects;
14  import java.util.Properties;
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  import org.codehaus.plexus.util.xml.Xpp3Dom;
21  
22  @Generated
23  public class ToolchainModel
24      extends TrackableBase
25      implements Serializable, Cloneable
26  {
27  
28      public ToolchainModel() {
29          this(org.apache.maven.api.toolchain.ToolchainModel.newInstance());
30      }
31  
32      public ToolchainModel(org.apache.maven.api.toolchain.ToolchainModel delegate) {
33          this(delegate, null);
34      }
35  
36      public ToolchainModel(org.apache.maven.api.toolchain.ToolchainModel delegate, BaseObject parent) {
37          super(delegate, parent);
38      }
39  
40      public ToolchainModel clone(){
41          return new ToolchainModel(getDelegate());
42      }
43  
44      @Override
45      public org.apache.maven.api.toolchain.ToolchainModel getDelegate() {
46          return (org.apache.maven.api.toolchain.ToolchainModel) super.getDelegate();
47      }
48  
49      @Override
50      public boolean equals(Object o) {
51          if (this == o) {
52              return true;
53          }
54          if (o == null || !(o instanceof ToolchainModel)) {
55              return false;
56          }
57          ToolchainModel that = (ToolchainModel) o;
58          return Objects.equals(this.delegate, that.delegate);
59      }
60  
61      @Override
62      public int hashCode() {
63          return getDelegate().hashCode();
64      }
65  
66      public String getType() {
67          return getDelegate().getType();
68      }
69  
70      public void setType(String type) {
71          if (!Objects.equals(type, getType())) {
72              update(getDelegate().withType(type));
73          }
74      }
75  
76      @Nonnull
77      public Properties getProvides() {
78          return new WrapperProperties(() -> getDelegate().getProvides(), this::setProvides);
79      }
80  
81      public void setProvides(Properties provides) {
82          Map<String, String> map = provides.entrySet().stream()
83                  .collect(Collectors.toMap(e -> e.getKey().toString(), e -> e.getValue().toString()));
84          if (!Objects.equals(map, getDelegate().getProvides())) {
85              update(getDelegate().withProvides(map));
86          }
87      }
88  
89      public void addProvide(String key, String value) {
90          getProvides().put(key, value);
91      }
92  
93      public Object getConfiguration() {
94          return getDelegate().getConfiguration() != null ? new Xpp3Dom(getDelegate().getConfiguration(), this::replace) : null;
95      }
96  
97      public void setConfiguration(Object configuration) {
98          if (configuration instanceof Xpp3Dom) {
99              if (!Objects.equals(((Xpp3Dom) configuration).getDom(), getDelegate().getConfiguration())) {
100                 update(getDelegate().withConfiguration(((Xpp3Dom) configuration).getDom()));
101                 ((Xpp3Dom) configuration).setChildrenTracking(this::replace);
102             }
103         } else if (configuration == null) {
104             if (getDelegate().getConfiguration() != null) {
105                 update(getDelegate().withConfiguration(null));
106             }
107         } else {
108             throw new IllegalArgumentException("Expected an Xpp3Dom object but received a " + configuration.getClass() + ": " + configuration);
109         }
110     }
111 
112     protected boolean replace(Object oldDelegate, Object newDelegate) {
113         if (super.replace(oldDelegate, newDelegate)) {
114             return true;
115         }
116         if (getDelegate().getConfiguration() == oldDelegate) {
117             update(getDelegate().withConfiguration((org.apache.maven.api.xml.XmlNode) newDelegate));
118         }
119         return false;
120     }
121 
122     public static List<org.apache.maven.api.toolchain.ToolchainModel> toolchainModelToApiV4(List<ToolchainModel> list) {
123         return list != null ? new WrapperList<>(list, ToolchainModel::getDelegate, ToolchainModel::new) : null;
124     }
125 
126     public static List<ToolchainModel> toolchainModelToApiV3(List<org.apache.maven.api.toolchain.ToolchainModel> list) {
127         return list != null ? new WrapperList<>(list, ToolchainModel::new, ToolchainModel::getDelegate) : null;
128     }
129 
130 }