| 1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2005, 2008 IBM Corporation and others. |
| 3 |
* |
| 4 |
* This program and the accompanying materials |
| 5 |
* are made available under the terms of the Eclipse Public License 2.0 |
| 6 |
* which accompanies this distribution, and is available at |
| 7 |
* https://www.eclipse.org/legal/epl-2.0/ |
| 8 |
* |
| 9 |
* SPDX-License-Identifier: EPL-2.0 |
| 10 |
* |
| 11 |
* Contributors: |
| 12 |
* IBM Corporation - initial API and implementation |
| 13 |
*******************************************************************************/ |
| 14 |
package org.eclipse.equinox.internal.p2.update; |
| 15 |
|
| 16 |
import java.net.URL; |
| 17 |
|
| 18 |
/* |
| 19 |
* Represents a feature entry in a platform.xml file. |
| 20 |
*/ |
| 21 |
public class Feature { |
| 22 |
|
| 23 |
private String id; |
| 24 |
private String url; |
| 25 |
private String version; |
| 26 |
private Site site; |
| 27 |
private String pluginIdentifier; |
| 28 |
private String pluginVersion; |
| 29 |
private String application; |
| 30 |
private URL[] roots; |
| 31 |
private boolean primary = false; |
| 32 |
|
| 33 |
public Feature(Site site) { |
| 34 |
super(); |
| 35 |
if (site == null) |
| 36 |
throw new IllegalArgumentException(Messages.empty_feature_site); |
| 37 |
this.site = site; |
| 38 |
} |
| 39 |
|
| 40 |
public String getApplication() { |
| 41 |
return application; |
| 42 |
} |
| 43 |
|
| 44 |
public String getId() { |
| 45 |
return id; |
| 46 |
} |
| 47 |
|
| 48 |
public String getPluginIdentifier() { |
| 49 |
return pluginIdentifier; |
| 50 |
} |
| 51 |
|
| 52 |
public String getPluginVersion() { |
| 53 |
return pluginVersion; |
| 54 |
} |
| 55 |
|
| 56 |
public URL[] getRoots() { |
| 57 |
return roots; |
| 58 |
} |
| 59 |
|
| 60 |
public Site getSite() { |
| 61 |
return site; |
| 62 |
} |
| 63 |
|
| 64 |
public String getUrl() { |
| 65 |
return url; |
| 66 |
} |
| 67 |
|
| 68 |
public String getVersion() { |
| 69 |
return version; |
| 70 |
} |
| 71 |
|
| 72 |
public boolean isPrimary() { |
| 73 |
return primary; |
| 74 |
} |
| 75 |
|
| 76 |
public void setApplication(String application) { |
| 77 |
this.application = application; |
| 78 |
} |
| 79 |
|
| 80 |
public void setId(String id) { |
| 81 |
this.id = id; |
| 82 |
} |
| 83 |
|
| 84 |
public void setPluginIdentifier(String pluginIdentifier) { |
| 85 |
this.pluginIdentifier = pluginIdentifier; |
| 86 |
} |
| 87 |
|
| 88 |
public void setPluginVersion(String pluginVersion) { |
| 89 |
this.pluginVersion = pluginVersion; |
| 90 |
} |
| 91 |
|
| 92 |
public void setPrimary(boolean primary) { |
| 93 |
this.primary = primary; |
| 94 |
} |
| 95 |
|
| 96 |
public void setRoots(URL[] roots) { |
| 97 |
this.roots = roots; |
| 98 |
} |
| 99 |
|
| 100 |
public void setUrl(String url) { |
| 101 |
this.url = url; |
| 102 |
} |
| 103 |
|
| 104 |
public void setVersion(String version) { |
| 105 |
this.version = version; |
| 106 |
} |
| 107 |
|
| 108 |
@Override |
| 109 |
public boolean equals(Object obj) { |
| 110 |
if (!(obj instanceof Feature)) |
| 111 |
return false; |
| 112 |
Feature other = (Feature) obj; |
| 113 |
if (!equals(getId(), other.getId())) |
| 114 |
return false; |
| 115 |
// shallow equals here. sites should never be null |
| 116 |
if (!equals(getSite().getUrl(), other.getSite().getUrl())) |
| 117 |
return false; |
| 118 |
if (!equals(getUrl(), other.getUrl())) |
| 119 |
return false; |
| 120 |
if (!equals(getVersion(), other.getVersion())) |
| 121 |
return false; |
| 122 |
return true; |
| 123 |
} |
| 124 |
|
| 125 |
private static boolean equals(Object one, Object two) { |
| 126 |
return one == null ? two == null : one.equals(two); |
| 127 |
} |
| 128 |
|
| 129 |
@Override |
| 130 |
public int hashCode() { |
| 131 |
return id.hashCode() + version.hashCode(); |
| 132 |
} |
| 133 |
} |