Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 562aab22290c8726fda2cf4bae51d499da6c1bb8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*******************************************************************************
 *  Copyright (c) 2008, 2010 IBM Corporation and others.
 *  All rights reserved. This program and the accompanying materials
 *  are made available under the terms of the Eclipse Public License v1.0
 *  which accompanies this distribution, and is available at
 *  http://www.eclipse.org/legal/epl-v10.html
 * 
 *  Contributors:
 *     IBM Corporation - initial API and implementation
 *     Cloudsmith Inc - public API
 *******************************************************************************/
package org.eclipse.equinox.p2.repository.spi;

import java.net.URI;
import org.eclipse.equinox.p2.repository.IRepository;
import org.eclipse.equinox.p2.repository.IRepositoryReference;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;

/**
 * Concrete implementation of a repository reference. This class can be used
 * by clients to define new repository references.
 * @see IMetadataRepository#addReferences(java.util.Collection)
 * @since 2.0
 * @noextend This class is not intended to be subclassed by clients.
 */
public class RepositoryReference implements IRepositoryReference {
	private final URI location;
	private final int type;
	private final int options;
	private final String nickname;

	/**
	 * Creates a reference to another repository.
	 *
	 * The {@link IRepository#ENABLED} option flag controls whether the 
	 * referenced repository should be marked as enabled when added to the repository
	 * manager. If this flag is set, the repository will be marked as enabled when
	 * added to the repository manager. If this flag is missing, the repository will
	 * be marked as disabled.
	 * 
	 * @param location the location of the repository to add
	 * @param nickname The nickname of the repository, or <code>null</code>
	 * @param type the repository type (currently either {@link IRepository#TYPE_METADATA}
	 * or {@link IRepository#TYPE_ARTIFACT}).
	 * @param options bit-wise or of option constants (currently either 
	 * {@link IRepository#ENABLED} or {@link IRepository#NONE}).
	 * @see IMetadataRepositoryManager#setEnabled(URI, boolean)
	 */
	public RepositoryReference(URI location, String nickname, int type, int options) {
		this.location = location;
		this.type = type;
		this.options = options;
		this.nickname = nickname;
	}

	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!(obj instanceof IRepositoryReference))
			return false;
		IRepositoryReference other = (IRepositoryReference) obj;
		if (location == null) {
			if (other.getLocation() != null)
				return false;
		} else if (!location.equals(other.getLocation()))
			return false;
		if (type != other.getType())
			return false;
		return true;
	}

	public URI getLocation() {
		return location;
	}

	public int getType() {
		return type;
	}

	public int getOptions() {
		return options;
	}

	public String getNickname() {
		return nickname;
	}

	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((location == null) ? 0 : location.hashCode());
		result = prime * result + type;
		return result;
	}

}

Back to the top