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