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.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  
20  @Generated
21  public class Build
22      extends BuildBase
23      implements Serializable, Cloneable
24  {
25  
26      public Build() {
27          this(org.apache.maven.api.model.Build.newInstance());
28      }
29  
30      public Build(org.apache.maven.api.model.Build delegate) {
31          this(delegate, null);
32      }
33  
34      public Build(org.apache.maven.api.model.Build delegate, BaseObject parent) {
35          super(delegate, parent);
36      }
37  
38      public Build clone(){
39          return new Build(getDelegate());
40      }
41  
42      @Override
43      public org.apache.maven.api.model.Build getDelegate() {
44          return (org.apache.maven.api.model.Build) super.getDelegate();
45      }
46  
47      @Override
48      public boolean equals(Object o) {
49          if (this == o) {
50              return true;
51          }
52          if (o == null || !(o instanceof Build)) {
53              return false;
54          }
55          Build that = (Build) o;
56          return Objects.equals(this.delegate, that.delegate);
57      }
58  
59      @Override
60      public int hashCode() {
61          return getDelegate().hashCode();
62      }
63  
64      public String getSourceDirectory() {
65          return getDelegate().getSourceDirectory();
66      }
67  
68      public void setSourceDirectory(String sourceDirectory) {
69          if (!Objects.equals(sourceDirectory, getSourceDirectory())) {
70              update(getDelegate().withSourceDirectory(sourceDirectory));
71          }
72      }
73  
74      public String getScriptSourceDirectory() {
75          return getDelegate().getScriptSourceDirectory();
76      }
77  
78      public void setScriptSourceDirectory(String scriptSourceDirectory) {
79          if (!Objects.equals(scriptSourceDirectory, getScriptSourceDirectory())) {
80              update(getDelegate().withScriptSourceDirectory(scriptSourceDirectory));
81          }
82      }
83  
84      public String getTestSourceDirectory() {
85          return getDelegate().getTestSourceDirectory();
86      }
87  
88      public void setTestSourceDirectory(String testSourceDirectory) {
89          if (!Objects.equals(testSourceDirectory, getTestSourceDirectory())) {
90              update(getDelegate().withTestSourceDirectory(testSourceDirectory));
91          }
92      }
93  
94      public String getOutputDirectory() {
95          return getDelegate().getOutputDirectory();
96      }
97  
98      public void setOutputDirectory(String outputDirectory) {
99          if (!Objects.equals(outputDirectory, getOutputDirectory())) {
100             update(getDelegate().withOutputDirectory(outputDirectory));
101         }
102     }
103 
104     public String getTestOutputDirectory() {
105         return getDelegate().getTestOutputDirectory();
106     }
107 
108     public void setTestOutputDirectory(String testOutputDirectory) {
109         if (!Objects.equals(testOutputDirectory, getTestOutputDirectory())) {
110             update(getDelegate().withTestOutputDirectory(testOutputDirectory));
111         }
112     }
113 
114     @Nonnull
115     public List<Extension> getExtensions() {
116         return new WrapperList<Extension, org.apache.maven.api.model.Extension>(
117                     () -> getDelegate().getExtensions(), l -> update(getDelegate().withExtensions(l)),
118                     d -> new Extension(d, this), Extension::getDelegate);
119     }
120 
121     public void setExtensions(List<Extension> extensions) {
122         if (extensions == null) {
123             extensions = Collections.emptyList();
124         }
125         if (!Objects.equals(extensions, getExtensions())) {
126             update(getDelegate().withExtensions(
127                 extensions.stream().map(c -> c.getDelegate()).collect(Collectors.toList())));
128             extensions.forEach(e -> e.childrenTracking = this::replace);
129         }
130     }
131 
132     public void addExtension(Extension extension) {
133         update(getDelegate().withExtensions(
134                Stream.concat(getDelegate().getExtensions().stream(), Stream.of(extension.getDelegate()))
135                         .collect(Collectors.toList())));
136         extension.childrenTracking = this::replace;
137     }
138 
139     public void removeExtension(Extension extension) {
140         update(getDelegate().withExtensions(
141                getDelegate().getExtensions().stream()
142                         .filter(e -> !Objects.equals(e, extension))
143                         .collect(Collectors.toList())));
144         extension.childrenTracking = null;
145     }
146 
147     public InputLocation getLocation(Object key) {
148         org.apache.maven.api.model.InputLocation loc = getDelegate().getLocation(key);
149         return loc != null ? new InputLocation(loc) : null;
150     }
151 
152     public void setLocation(Object key, InputLocation location) {
153         update(org.apache.maven.api.model.Build.newBuilder(getDelegate(), true)
154                         .location(key, location.toApiLocation()).build());
155     }
156 
157     protected boolean replace(Object oldDelegate, Object newDelegate) {
158         if (super.replace(oldDelegate, newDelegate)) {
159             return true;
160         }
161         if (getDelegate().getExtensions().contains(oldDelegate)) {
162             List<org.apache.maven.api.model.Extension> list = new ArrayList<>(getDelegate().getExtensions());
163             list.replaceAll(d -> d == oldDelegate ? (org.apache.maven.api.model.Extension) newDelegate : d);
164             update(getDelegate().withExtensions(list));
165             return true;
166         }
167         return false;
168     }
169 
170     public static List<org.apache.maven.api.model.Build> buildToApiV4(List<Build> list) {
171         return list != null ? new WrapperList<>(list, Build::getDelegate, Build::new) : null;
172     }
173 
174     public static List<Build> buildToApiV3(List<org.apache.maven.api.model.Build> list) {
175         return list != null ? new WrapperList<>(list, Build::new, Build::getDelegate) : null;
176     }
177 
178 
179             
180     /**
181      * @see java.lang.Object#toString()
182      */
183     public String toString()
184     {
185         return "Build {" + super.toString() + "}";
186     }
187             
188           
189 }