1
2
3
4
5
6
7
8
9
10
11 package org.eclipse.aether.repository;
12
13 import java.io.File;
14
15
16
17
18
19
20
21 public final class LocalRepository
22 implements ArtifactRepository
23 {
24
25 private final File basedir;
26
27 private final String type;
28
29
30
31
32
33
34 public LocalRepository( String basedir )
35 {
36 this( ( basedir != null ) ? new File( basedir ) : null, "" );
37 }
38
39
40
41
42
43
44 public LocalRepository( File basedir )
45 {
46 this( basedir, "" );
47 }
48
49
50
51
52
53
54
55 public LocalRepository( File basedir, String type )
56 {
57 this.basedir = basedir;
58 this.type = ( type != null ) ? type : "";
59 }
60
61 public String getContentType()
62 {
63 return type;
64 }
65
66 public String getId()
67 {
68 return "local";
69 }
70
71
72
73
74
75
76 public File getBasedir()
77 {
78 return basedir;
79 }
80
81 @Override
82 public String toString()
83 {
84 return getBasedir() + " (" + getContentType() + ")";
85 }
86
87 @Override
88 public boolean equals( Object obj )
89 {
90 if ( this == obj )
91 {
92 return true;
93 }
94 if ( obj == null || !getClass().equals( obj.getClass() ) )
95 {
96 return false;
97 }
98
99 LocalRepository that = (LocalRepository) obj;
100
101 return eq( basedir, that.basedir ) && eq( type, that.type );
102 }
103
104 private static <T> boolean eq( T s1, T s2 )
105 {
106 return s1 != null ? s1.equals( s2 ) : s2 == null;
107 }
108
109 @Override
110 public int hashCode()
111 {
112 int hash = 17;
113 hash = hash * 31 + hash( basedir );
114 hash = hash * 31 + hash( type );
115 return hash;
116 }
117
118 private static int hash( Object obj )
119 {
120 return obj != null ? obj.hashCode() : 0;
121 }
122
123 }