core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/internal/discovery/ui/p2/FeatureInfo.java
Keeping PlatSim internal only.
/*
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of the License "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:
*
*/
package com.nokia.carbide.internal.discovery.ui.p2;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.Version;
public class FeatureInfo {
private String id;
private Version version;
public FeatureInfo(IInstallableUnit iu) {
this(iu.getId(), iu.getVersion());
}
public FeatureInfo(String id, Version version) {
this.id = id;
this.version = version;
}
public String getId() {
return id;
}
public Version getVersion() {
return version;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((version == null) ? 0 : version.toString().hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
FeatureInfo other = (FeatureInfo) obj;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
if (version == null) {
if (other.version != null)
return false;
} else if (!version.toString().equals(other.version.toString()))
return false;
return true;
}
@Override
public String toString() {
return getId() + " " + getVersion().toString(); //$NON-NLS-1$
}
}