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