Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 0866b2b9980495b411b5636a4e82a007ea7e1ed0 (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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*******************************************************************************
 *  Copyright (c) 2005, 2008 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
 *******************************************************************************/
package org.eclipse.equinox.internal.p2.update;

import java.net.URL;

/*
 * Represents a feature entry in a platform.xml file.
 */
public class Feature {

	private String id;
	private String url;
	private String version;
	private Site site;
	private String pluginIdentifier;
	private String pluginVersion;
	private String application;
	private URL[] roots;
	private boolean primary = false;

	public Feature(Site site) {
		super();
		if (site == null)
			throw new IllegalArgumentException(Messages.empty_feature_site);
		this.site = site;
	}

	public String getApplication() {
		return application;
	}

	public String getId() {
		return id;
	}

	public String getPluginIdentifier() {
		return pluginIdentifier;
	}

	public String getPluginVersion() {
		return pluginVersion;
	}

	public URL[] getRoots() {
		return roots;
	}

	public Site getSite() {
		return site;
	}

	public String getUrl() {
		return url;
	}

	public String getVersion() {
		return version;
	}

	public boolean isPrimary() {
		return primary;
	}

	public void setApplication(String application) {
		this.application = application;
	}

	public void setId(String id) {
		this.id = id;
	}

	public void setPluginIdentifier(String pluginIdentifier) {
		this.pluginIdentifier = pluginIdentifier;
	}

	public void setPluginVersion(String pluginVersion) {
		this.pluginVersion = pluginVersion;
	}

	public void setPrimary(boolean primary) {
		this.primary = primary;
	}

	public void setRoots(URL[] roots) {
		this.roots = roots;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public void setVersion(String version) {
		this.version = version;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	public boolean equals(Object obj) {
		if (!(obj instanceof Feature))
			return false;
		Feature other = (Feature) obj;
		if (!equals(getId(), other.getId()))
			return false;
		// shallow equals here. sites should never be null
		if (!equals(getSite().getUrl(), other.getSite().getUrl()))
			return false;
		if (!equals(getUrl(), other.getUrl()))
			return false;
		if (!equals(getVersion(), other.getVersion()))
			return false;
		return true;
	}

	private boolean equals(Object one, Object two) {
		return one == null ? two == null : one.equals(two);
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
		return id.hashCode() + version.hashCode();
	}
}

Back to the top