1
2
3
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 CiManagement
22 extends BaseObject
23 {
24
25 public CiManagement()
26 {
27 this( org.apache.maven.api.model.CiManagement.newInstance() );
28 }
29
30 public CiManagement( org.apache.maven.api.model.CiManagement delegate )
31 {
32 this( delegate, null );
33 }
34
35 public CiManagement( org.apache.maven.api.model.CiManagement delegate, BaseObject parent )
36 {
37 super( delegate, parent );
38 }
39
40 public CiManagement clone()
41 {
42 return new CiManagement( getDelegate() );
43 }
44
45 public org.apache.maven.api.model.CiManagement getDelegate()
46 {
47 return ( org.apache.maven.api.model.CiManagement ) 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 CiManagement ) )
58 {
59 return false;
60 }
61 CiManagement that = ( CiManagement ) 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 public String getSystem()
72 {
73 return getDelegate().getSystem();
74 }
75
76 public void setSystem( String system )
77 {
78 if ( !Objects.equals( system, getDelegate().getSystem() ) )
79 {
80 update( getDelegate().withSystem( system ) );
81 }
82 }
83
84 public String getUrl()
85 {
86 return getDelegate().getUrl();
87 }
88
89 public void setUrl( String url )
90 {
91 if ( !Objects.equals( url, getDelegate().getUrl() ) )
92 {
93 update( getDelegate().withUrl( url ) );
94 }
95 }
96
97 @Nonnull
98 public List<Notifier> getNotifiers()
99 {
100 return new WrapperList<Notifier, org.apache.maven.api.model.Notifier>(
101 () -> getDelegate().getNotifiers(), l -> update( getDelegate().withNotifiers( l ) ),
102 d -> new Notifier( d, this ), Notifier::getDelegate );
103 }
104
105 public void setNotifiers( List<Notifier> notifiers )
106 {
107 if ( !Objects.equals( notifiers, getDelegate().getNotifiers() ) )
108 {
109 update( getDelegate().withNotifiers(
110 notifiers.stream().map( c -> c.getDelegate() ).collect( Collectors.toList() ) ) );
111 notifiers.forEach( e -> e.childrenTracking = this::replace );
112 }
113 }
114
115 public void addNotifier( Notifier notifier )
116 {
117 update( getDelegate().withNotifiers(
118 Stream.concat( getDelegate().getNotifiers().stream(), Stream.of( notifier.getDelegate() ) )
119 .collect( Collectors.toList() ) ) );
120 notifier.childrenTracking = this::replace;
121 }
122
123 public void removeNotifier( Notifier notifier )
124 {
125 update( getDelegate().withNotifiers(
126 getDelegate().getNotifiers().stream()
127 .filter( e -> !Objects.equals( e, notifier ) )
128 .collect( Collectors.toList() ) ) );
129 notifier.childrenTracking = null;
130 }
131
132 public InputLocation getLocation( Object key )
133 {
134 org.apache.maven.api.model.InputLocation loc = getDelegate().getLocation( key );
135 return loc != null ? new InputLocation( loc ) : null;
136 }
137
138 public void setLocation( Object key, InputLocation location )
139 {
140 update( org.apache.maven.api.model.CiManagement.newBuilder( getDelegate(), true )
141 .location( key, location.toApiLocation() ).build() );
142 }
143
144 protected boolean replace( Object oldDelegate, Object newDelegate )
145 {
146 if ( super.replace( oldDelegate, newDelegate ) )
147 {
148 return true;
149 }
150 if ( getDelegate().getNotifiers().contains( oldDelegate ) )
151 {
152 List<org.apache.maven.api.model.Notifier> list = new ArrayList<>( getDelegate().getNotifiers() );
153 list.replaceAll( d -> d == oldDelegate ? ( org.apache.maven.api.model.Notifier ) newDelegate : d );
154 update( getDelegate().withNotifiers( list ) );
155 return true;
156 }
157 return false;
158 }
159
160 public static List<org.apache.maven.api.model.CiManagement> ciManagementToApiV4( List<CiManagement> list )
161 {
162 return list != null ? new WrapperList<>( list, CiManagement::getDelegate, CiManagement::new ) : null;
163 }
164
165 public static List<CiManagement> ciManagementToApiV3( List<org.apache.maven.api.model.CiManagement> list )
166 {
167 return list != null ? new WrapperList<>( list, CiManagement::new, CiManagement::getDelegate ) : null;
168 }
169
170 }