]>
git.argeo.org Git - gpl/argeo-jcr.git/blob - org.argeo.slc.repo/src/org/eclipse/aether/repository/WorkspaceRepository.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
;
13 import java
.util
.UUID
;
16 * A repository backed by an IDE workspace, the output of a build session or similar ad-hoc collection of artifacts. As
17 * far as the repository system is concerned, a workspace repository is read-only, i.e. can only be used for artifact
18 * resolution but not installation/deployment. Note that this class merely describes such a repository, actual access to
19 * the contained artifacts is handled by a {@link WorkspaceReader}.
21 public final class WorkspaceRepository
22 implements ArtifactRepository
25 private final String type
;
27 private final Object key
;
30 * Creates a new workspace repository of type {@code "workspace"} and a random key.
32 public WorkspaceRepository()
38 * Creates a new workspace repository with the specified type and a random key.
40 * @param type The type of the repository, may be {@code null}.
42 public WorkspaceRepository( String type
)
48 * Creates a new workspace repository with the specified type and key. The key is used to distinguish one workspace
49 * from another and should be sensitive to the artifacts that are (potentially) available in the workspace.
51 * @param type The type of the repository, may be {@code null}.
52 * @param key The (comparison) key for the repository, may be {@code null} to generate a unique random key.
54 public WorkspaceRepository( String type
, Object key
)
56 this.type
= ( type
!= null ) ? type
: "";
57 this.key
= ( key
!= null ) ? key
: UUID
.randomUUID().toString().replace( "-", "" );
60 public String
getContentType()
71 * Gets the key of this workspace repository. The key is used to distinguish one workspace from another and should
72 * be sensitive to the artifacts that are (potentially) available in the workspace.
74 * @return The (comparison) key for this workspace repository, never {@code null}.
76 public Object
getKey()
82 public String
toString()
84 return "(" + getContentType() + ")";
88 public boolean equals( Object obj
)
94 if ( obj
== null || !getClass().equals( obj
.getClass() ) )
99 WorkspaceRepository that
= (WorkspaceRepository
) obj
;
101 return getContentType().equals( that
.getContentType() ) && getKey().equals( that
.getKey() );
105 public int hashCode()
108 hash
= hash
* 31 + getKey().hashCode();
109 hash
= hash
* 31 + getContentType().hashCode();