|
1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 package com.nokia.carbide.internal.discovery.ui.p2; |
|
18 |
|
19 import org.eclipse.equinox.p2.metadata.IInstallableUnit; |
|
20 import org.eclipse.equinox.p2.metadata.Version; |
|
21 |
|
22 public class FeatureInfo { |
|
23 private String id; |
|
24 private Version version; |
|
25 |
|
26 public FeatureInfo(IInstallableUnit iu) { |
|
27 this(iu.getId(), iu.getVersion()); |
|
28 } |
|
29 |
|
30 public FeatureInfo(String id, Version version) { |
|
31 this.id = id; |
|
32 this.version = version; |
|
33 } |
|
34 |
|
35 public String getId() { |
|
36 return id; |
|
37 } |
|
38 |
|
39 public Version getVersion() { |
|
40 return version; |
|
41 } |
|
42 |
|
43 @Override |
|
44 public int hashCode() { |
|
45 final int prime = 31; |
|
46 int result = 1; |
|
47 result = prime * result + ((id == null) ? 0 : id.hashCode()); |
|
48 result = prime * result + ((version == null) ? 0 : version.toString().hashCode()); |
|
49 return result; |
|
50 } |
|
51 |
|
52 @Override |
|
53 public boolean equals(Object obj) { |
|
54 if (this == obj) |
|
55 return true; |
|
56 if (obj == null) |
|
57 return false; |
|
58 if (getClass() != obj.getClass()) |
|
59 return false; |
|
60 FeatureInfo other = (FeatureInfo) obj; |
|
61 if (id == null) { |
|
62 if (other.id != null) |
|
63 return false; |
|
64 } else if (!id.equals(other.id)) |
|
65 return false; |
|
66 if (version == null) { |
|
67 if (other.version != null) |
|
68 return false; |
|
69 } else if (!version.toString().equals(other.version.toString())) |
|
70 return false; |
|
71 return true; |
|
72 } |
|
73 |
|
74 @Override |
|
75 public String toString() { |
|
76 return getId() + " " + getVersion().toString(); //$NON-NLS-1$ |
|
77 } |
|
78 } |