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 PatternSet
22      extends BaseObject
23  {
24  
25      public PatternSet()
26      {
27          this( org.apache.maven.api.model.PatternSet.newInstance() );
28      }
29  
30      public PatternSet( org.apache.maven.api.model.PatternSet delegate )
31      {
32          this( delegate, null );
33      }
34  
35      public PatternSet( org.apache.maven.api.model.PatternSet delegate, BaseObject parent )
36      {
37          super( delegate, parent );
38      }
39  
40      public PatternSet clone()
41      {
42          return new PatternSet( getDelegate() );
43      }
44  
45      public org.apache.maven.api.model.PatternSet getDelegate()
46      {
47          return ( org.apache.maven.api.model.PatternSet ) super.getDelegate();
48      }
49  
50      @Override
51      public boolean equals( Object o )
52      {
53          if ( this == o )
54          {
55              return true;
56          }
57          if ( o == null || !( o instanceof PatternSet ) )
58          {
59              return false;
60          }
61          PatternSet that = ( PatternSet ) o;
62          return Objects.equals( this.delegate, that.delegate );
63      }
64  
65      @Override
66      public int hashCode()
67      {
68          return getDelegate().hashCode();
69      }
70  
71      @Nonnull
72      public List<String> getIncludes()
73      {
74          return new WrapperList<String, String>( () -> getDelegate().getIncludes(), this::setIncludes, s -> s, s -> s );
75      }
76  
77      public void setIncludes( List<String> includes )
78      {
79          if ( !Objects.equals( includes, getDelegate().getIncludes() ) )
80          {
81              update( getDelegate().withIncludes( includes ) );
82          }
83      }
84  
85      public void addInclude( String include )
86      {
87          update( getDelegate().withIncludes(
88                  Stream.concat( getDelegate().getIncludes().stream(), Stream.of( include ) )
89                          .collect( Collectors.toList() ) ) );
90      }
91  
92      public void removeInclude( String include )
93      {
94          update( getDelegate().withIncludes(
95                  getDelegate().getIncludes().stream()
96                          .filter( e -> !Objects.equals( e, include ) )
97                          .collect( Collectors.toList() ) ) );
98      }
99  
100     @Nonnull
101     public List<String> getExcludes()
102     {
103         return new WrapperList<String, String>( () -> getDelegate().getExcludes(), this::setExcludes, s -> s, s -> s );
104     }
105 
106     public void setExcludes( List<String> excludes )
107     {
108         if ( !Objects.equals( excludes, getDelegate().getExcludes() ) )
109         {
110             update( getDelegate().withExcludes( excludes ) );
111         }
112     }
113 
114     public void addExclude( String exclude )
115     {
116         update( getDelegate().withExcludes(
117                 Stream.concat( getDelegate().getExcludes().stream(), Stream.of( exclude ) )
118                         .collect( Collectors.toList() ) ) );
119     }
120 
121     public void removeExclude( String exclude )
122     {
123         update( getDelegate().withExcludes(
124                 getDelegate().getExcludes().stream()
125                         .filter( e -> !Objects.equals( e, exclude ) )
126                         .collect( Collectors.toList() ) ) );
127     }
128 
129     public InputLocation getLocation( Object key )
130     {
131         org.apache.maven.api.model.InputLocation loc = getDelegate().getLocation( key );
132         return loc != null ? new InputLocation( loc ) : null;
133     }
134 
135     public void setLocation( Object key, InputLocation location )
136     {
137         update( org.apache.maven.api.model.PatternSet.newBuilder( getDelegate(), true )
138                         .location( key, location.toApiLocation() ).build() );
139     }
140 
141     protected boolean replace( Object oldDelegate, Object newDelegate )
142     {
143         if ( super.replace( oldDelegate, newDelegate ) )
144         {
145             return true;
146         }
147         return false;
148     }
149 
150     public static List<org.apache.maven.api.model.PatternSet> patternSetToApiV4( List<PatternSet> list )
151     {
152         return list != null ? new WrapperList<>( list, PatternSet::getDelegate, PatternSet::new ) : null;
153     }
154 
155     public static List<PatternSet> patternSetToApiV3( List<org.apache.maven.api.model.PatternSet> list )
156     {
157         return list != null ? new WrapperList<>( list, PatternSet::new, PatternSet::getDelegate ) : null;
158     }
159 
160 
161             
162     /**
163      * @see java.lang.Object#toString()
164      */
165     public String toString()
166     {
167         StringBuilder sb = new StringBuilder( 128 );
168 
169         sb.append("PatternSet [includes: {");
170         for (java.util.Iterator i = getIncludes().iterator(); i.hasNext(); )
171         {
172             String str = (String) i.next();
173             sb.append(str).append(", ");
174         }
175         if (sb.substring(sb.length() - 2).equals(", ")) sb.delete(sb.length() - 2, sb.length());
176 
177         sb.append("}, excludes: {");
178         for (java.util.Iterator i = getExcludes().iterator(); i.hasNext(); )
179         {
180             String str = (String) i.next();
181             sb.append(str).append(", ");
182         }
183         if (sb.substring(sb.length() - 2).equals(", ")) sb.delete(sb.length() - 2, sb.length());
184 
185         sb.append("}]");
186         return sb.toString();
187     }
188             
189           
190 }