| 1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2009, 2017 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 |
|
| 15 |
package org.eclipse.equinox.p2.operations; |
| 16 |
|
| 17 |
import org.eclipse.equinox.p2.metadata.IInstallableUnit; |
| 18 |
|
| 19 |
/** |
| 20 |
* A simple data structure describing a possible update. |
| 21 |
* |
| 22 |
* @noextend This class is not intended to be subclassed by clients. |
| 23 |
* @since 2.0 |
| 24 |
*/ |
| 25 |
public class Update { |
| 26 |
|
| 27 |
public IInstallableUnit toUpdate; |
| 28 |
public IInstallableUnit replacement; |
| 29 |
|
| 30 |
/** |
| 31 |
* Creates a new update description. |
| 32 |
* @param toUpdate The installable unit to update |
| 33 |
* @param replacement The replacement installable unit |
| 34 |
*/ |
| 35 |
public Update(IInstallableUnit toUpdate, IInstallableUnit replacement) { |
| 36 |
this.toUpdate = toUpdate; |
| 37 |
this.replacement = replacement; |
| 38 |
} |
| 39 |
|
| 40 |
@Override |
| 41 |
public boolean equals(Object obj) { |
| 42 |
if (this == obj) |
| 43 |
return true; |
| 44 |
if (obj == null) |
| 45 |
return false; |
| 46 |
if (!(obj instanceof Update)) |
| 47 |
return false; |
| 48 |
if (toUpdate == null) |
| 49 |
return false; |
| 50 |
if (replacement == null) |
| 51 |
return false; |
| 52 |
Update other = (Update) obj; |
| 53 |
return toUpdate.equals(other.toUpdate) && replacement.equals(other.replacement); |
| 54 |
} |
| 55 |
|
| 56 |
@Override |
| 57 |
public int hashCode() { |
| 58 |
final int prime = 31; |
| 59 |
int result = 1; |
| 60 |
result = prime * result + ((toUpdate == null) ? 0 : toUpdate.hashCode()); |
| 61 |
result = prime * result + ((replacement == null) ? 0 : replacement.hashCode()); |
| 62 |
return result; |
| 63 |
} |
| 64 |
|
| 65 |
@Override |
| 66 |
public String toString() { |
| 67 |
return "Update " + toUpdate.toString() + " ==> " + replacement.toString(); //$NON-NLS-1$ //$NON-NLS-2$ |
| 68 |
} |
| 69 |
} |