View Javadoc
1   package org.eclipse.aether.internal.impl;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   * 
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   * 
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.util.ArrayList;
23  import java.util.Collections;
24  import java.util.List;
25  
26  import org.eclipse.aether.RepositoryEvent;
27  import org.eclipse.aether.RepositoryListener;
28  
29  import static java.util.Objects.requireNonNull;
30  
31  /**
32   * Collects observed repository events for later inspection.
33   */
34  class RecordingRepositoryListener
35      implements RepositoryListener
36  {
37  
38      private List<RepositoryEvent> events = Collections.synchronizedList( new ArrayList<RepositoryEvent>() );
39  
40      public List<RepositoryEvent> getEvents()
41      {
42          return events;
43      }
44  
45      public void clear()
46      {
47          events.clear();
48      }
49  
50      public void artifactDescriptorInvalid( RepositoryEvent event )
51      {
52          requireNonNull( event, "event cannot be null" );
53          events.add( event );
54      }
55  
56      public void artifactDescriptorMissing( RepositoryEvent event )
57      {
58          requireNonNull( event, "event cannot be null" );
59          events.add( event );
60      }
61  
62      public void metadataInvalid( RepositoryEvent event )
63      {
64          requireNonNull( event, "event cannot be null" );
65          events.add( event );
66      }
67  
68      public void artifactResolving( RepositoryEvent event )
69      {
70          requireNonNull( event, "event cannot be null" );
71          events.add( event );
72      }
73  
74      public void artifactResolved( RepositoryEvent event )
75      {
76          requireNonNull( event, "event cannot be null" );
77          events.add( event );
78      }
79  
80      public void artifactDownloading( RepositoryEvent event )
81      {
82          requireNonNull( event, "event cannot be null" );
83          events.add( event );
84      }
85  
86      public void artifactDownloaded( RepositoryEvent event )
87      {
88          requireNonNull( event, "event cannot be null" );
89          events.add( event );
90      }
91  
92      public void metadataDownloaded( RepositoryEvent event )
93      {
94          requireNonNull( event, "event cannot be null" );
95          events.add( event );
96      }
97  
98      public void metadataDownloading( RepositoryEvent event )
99      {
100         requireNonNull( event, "event cannot be null" );
101         events.add( event );
102     }
103 
104     public void metadataResolving( RepositoryEvent event )
105     {
106         requireNonNull( event, "event cannot be null" );
107         events.add( event );
108     }
109 
110     public void metadataResolved( RepositoryEvent event )
111     {
112         requireNonNull( event, "event cannot be null" );
113         events.add( event );
114     }
115 
116     public void artifactInstalling( RepositoryEvent event )
117     {
118         requireNonNull( event, "event cannot be null" );
119         events.add( event );
120     }
121 
122     public void artifactInstalled( RepositoryEvent event )
123     {
124         requireNonNull( event, "event cannot be null" );
125         events.add( event );
126     }
127 
128     public void metadataInstalling( RepositoryEvent event )
129     {
130         requireNonNull( event, "event cannot be null" );
131         events.add( event );
132     }
133 
134     public void metadataInstalled( RepositoryEvent event )
135     {
136         requireNonNull( event, "event cannot be null" );
137         events.add( event );
138     }
139 
140     public void artifactDeploying( RepositoryEvent event )
141     {
142         requireNonNull( event, "event cannot be null" );
143         events.add( event );
144     }
145 
146     public void artifactDeployed( RepositoryEvent event )
147     {
148         requireNonNull( event, "event cannot be null" );
149         events.add( event );
150     }
151 
152     public void metadataDeploying( RepositoryEvent event )
153     {
154         requireNonNull( event, "event cannot be null" );
155         events.add( event );
156     }
157 
158     public void metadataDeployed( RepositoryEvent event )
159     {
160         requireNonNull( event, "event cannot be null" );
161         events.add( event );
162     }
163 
164 }