Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 3a071c3d573fce88fd851f7a14ad1829eb7268b7 (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
/*******************************************************************************
 * Copyright (c) 2009, 2010 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.p2.operations;

import org.eclipse.equinox.p2.metadata.IInstallableUnit;

/**
 * A simple data structure describing a possible update.
 * 
 * @noextend This class is not intended to be subclassed by clients.
 * @since 2.0
 */
public class Update {

	public IInstallableUnit toUpdate;
	public IInstallableUnit replacement;

	/**
	 * Creates a new update description.
	 * @param toUpdate The installable unit to update
	 * @param replacement The replacement installable unit
	 */
	public Update(IInstallableUnit toUpdate, IInstallableUnit replacement) {
		this.toUpdate = toUpdate;
		this.replacement = replacement;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof Update))
			return false;
		if (toUpdate == null)
			return false;
		if (replacement == null)
			return false;
		Update other = (Update) obj;
		return toUpdate.equals(other.toUpdate) && replacement.equals(other.replacement);
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((toUpdate == null) ? 0 : toUpdate.hashCode());
		result = prime * result + ((replacement == null) ? 0 : replacement.hashCode());
		return result;
	}

	/*(non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return "Update " + toUpdate.toString() + " ==> " + replacement.toString(); //$NON-NLS-1$ //$NON-NLS-2$
	}
}

Back to the top