]>
git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.repo/src/org/eclipse/aether/repository/LocalRepository.java
1 /*******************************************************************************
2 * Copyright (c) 2010, 2012 Sonatype, Inc.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
9 * Sonatype, Inc. - initial API and implementation
10 *******************************************************************************/
11 package org
.eclipse
.aether
.repository
;
16 * A repository on the local file system used to cache contents of remote repositories and to store locally installed
17 * artifacts. Note that this class merely describes such a repository, actual access to the contained artifacts is
18 * handled by a {@link LocalRepositoryManager} which is usually determined from the {@link #getContentType() type} of
21 public final class LocalRepository
22 implements ArtifactRepository
25 private final File basedir
;
27 private final String type
;
30 * Creates a new local repository with the specified base directory and unknown type.
32 * @param basedir The base directory of the repository, may be {@code null}.
34 public LocalRepository( String basedir
)
36 this( ( basedir
!= null ) ?
new File( basedir
) : null, "" );
40 * Creates a new local repository with the specified base directory and unknown type.
42 * @param basedir The base directory of the repository, may be {@code null}.
44 public LocalRepository( File basedir
)
50 * Creates a new local repository with the specified properties.
52 * @param basedir The base directory of the repository, may be {@code null}.
53 * @param type The type of the repository, may be {@code null}.
55 public LocalRepository( File basedir
, String type
)
57 this.basedir
= basedir
;
58 this.type
= ( type
!= null ) ? type
: "";
61 public String
getContentType()
72 * Gets the base directory of the repository.
74 * @return The base directory or {@code null} if none.
76 public File
getBasedir()
82 public String
toString()
84 return getBasedir() + " (" + getContentType() + ")";
88 public boolean equals( Object obj
)
94 if ( obj
== null || !getClass().equals( obj
.getClass() ) )
99 LocalRepository that
= (LocalRepository
) obj
;
101 return eq( basedir
, that
.basedir
) && eq( type
, that
.type
);
104 private static <T
> boolean eq( T s1
, T s2
)
106 return s1
!= null ? s1
.equals( s2
) : s2
== null;
110 public int hashCode()
113 hash
= hash
* 31 + hash( basedir
);
114 hash
= hash
* 31 + hash( type
);
118 private static int hash( Object obj
)
120 return obj
!= null ? obj
.hashCode() : 0;