Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 4d850f6d4efcca773d266e8ae0bdabc47b799694 (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
73
74
75
/*******************************************************************************
 * Copyright (c) 2005, 2011 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.compare.internal.core.patch;

import java.util.HashSet;
import java.util.Set;

/**
 * A diff project represents a project that was read from a workspace patch.
 * It contains the set of file diffs that were associated with the project
 * in the patch file.
 */
public class DiffProject {
	private String project;
	private Set<FilePatch2> fDiffs= new HashSet<>();

	/**
	 * Create a diff project for the given workspace project.
	 * @param project a workspace project
	 */
	public DiffProject(String project) {
		this.project= project;
	}

	/**
	 * Add the file diff to this project.
	 * @param diff the file diff.
	 */
	public void add(FilePatch2 diff) {
		this.fDiffs.add(diff);
		if (diff.getProject() != this)
			diff.setProject(this);
	}

	/**
	 * Return the name of this project.
	 * @return the name of this project
	 */
	public String getName() {
		return this.project;
	}

	/**
	 * Remove the file diff from this project.
	 * @param diff the diff to be removed
	 */
	public void remove(FilePatch2 diff) {
		this.fDiffs.remove(diff);
	}

	/**
	 * Return whether this project contains the given diff.
	 * @param diff a file diff
	 * @return whether this project contains the given diff
	 */
	public boolean contains(FilePatch2 diff) {
		return this.fDiffs.contains(diff);
	}

	/**
	 * Return the file diffs associated with this project.
	 * @return the file diffs associated with this project
	 */
	public FilePatch2[] getFileDiffs() {
		return this.fDiffs.toArray(new FilePatch2[this.fDiffs.size()]);
	}
}

Back to the top