1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package org.codehaus.mojo.flatten.model.resolution; |
20 | |
|
21 | |
import com.google.common.base.Objects; |
22 | |
import org.apache.maven.project.MavenProject; |
23 | |
|
24 | |
import java.io.File; |
25 | |
import java.util.HashMap; |
26 | |
import java.util.List; |
27 | |
import java.util.Map; |
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | 1 | class ReactorModelPool |
35 | |
{ |
36 | |
|
37 | 1 | private Map<Coordinates, File> models = new HashMap<Coordinates, File>(); |
38 | |
|
39 | |
public File find( String groupId, String artifactId, String version ) |
40 | |
{ |
41 | 0 | return models.get( new Coordinates( groupId, artifactId, version ) ); |
42 | |
} |
43 | |
|
44 | |
public void addProjects( List<MavenProject> projects ) |
45 | |
{ |
46 | 1 | for ( MavenProject project : projects ) |
47 | |
{ |
48 | 0 | addProject( project ); |
49 | 0 | } |
50 | 1 | } |
51 | |
|
52 | |
public void addProject( MavenProject project ) |
53 | |
{ |
54 | 0 | Coordinates coordinates = new Coordinates( project.getGroupId(), project.getArtifactId(), |
55 | 0 | project.getVersion() ); |
56 | 0 | models.put( coordinates, project.getFile() ); |
57 | 0 | } |
58 | |
|
59 | |
private static final class Coordinates |
60 | |
{ |
61 | |
final String groupId; |
62 | |
final String artifactId; |
63 | |
final String version; |
64 | |
|
65 | 0 | Coordinates( String groupId, String artifactId, String version ) { |
66 | 0 | this.groupId = groupId; |
67 | 0 | this.artifactId = artifactId; |
68 | 0 | this.version = version; |
69 | 0 | } |
70 | |
|
71 | |
@Override |
72 | |
public boolean equals(Object obj) { |
73 | 0 | if (obj == this) { |
74 | 0 | return true; |
75 | |
} |
76 | 0 | if (obj instanceof Coordinates) { |
77 | 0 | Coordinates other = (Coordinates) obj; |
78 | 0 | return artifactId.equals(other.artifactId) && groupId.equals(other.groupId) |
79 | 0 | && version.equals(other.version); |
80 | |
} |
81 | 0 | return false; |
82 | |
} |
83 | |
|
84 | |
@Override |
85 | |
public int hashCode() { |
86 | 0 | return Objects.hashCode(artifactId, groupId, version); |
87 | |
} |
88 | |
|
89 | |
} |
90 | |
|
91 | |
} |