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