rename org.spearce.egit -> org.eclipse.egit and bump version to 0.5.0
[egit/imyousuf.git] / org.eclipse.egit.core / src / org / eclipse / egit / core / op / PushOperationSpecification.java
blob4139aff97d152f85c3d610e5619ff6544ad043ce
1 /*******************************************************************************
2 * Copyright (C) 2008, Marek Zawirski <marek.zawirski@gmail.com>
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * See LICENSE for the full license text, also available.
7 *******************************************************************************/
8 package org.eclipse.egit.core.op;
10 import java.util.Collection;
11 import java.util.Collections;
12 import java.util.LinkedHashMap;
13 import java.util.Set;
15 import org.spearce.jgit.transport.RemoteRefUpdate;
16 import org.spearce.jgit.transport.URIish;
18 /**
19 * Data class storing push operation update specifications for each remote
20 * repository.
21 * <p>
22 * One instance is dedicated for one push operation: either push to one URI or
23 * to many URIs.
25 * @see PushOperation
27 public class PushOperationSpecification {
28 private LinkedHashMap<URIish, Collection<RemoteRefUpdate>> urisRefUpdates;
30 /**
31 * Create empty instance of specification.
32 * <p>
33 * URIs and ref updates should be configured
34 * {@link #addURIRefUpdates(URIish, Collection)} method.
36 public PushOperationSpecification() {
37 this.urisRefUpdates = new LinkedHashMap<URIish, Collection<RemoteRefUpdate>>();
40 /**
41 * Add remote repository URI with ref updates specification.
42 * <p>
43 * Ref updates are not in constructor - pay attention to not share them
44 * between different URIs ref updates or push operations.
45 * <p>
46 * Note that refUpdates can differ between URIs <b>only</b> by expected old
47 * object id field: {@link RemoteRefUpdate#getExpectedOldObjectId()}.
49 * @param uri
50 * remote repository URI.
51 * @param refUpdates
52 * collection of remote ref updates specifications.
54 public void addURIRefUpdates(final URIish uri,
55 Collection<RemoteRefUpdate> refUpdates) {
56 urisRefUpdates.put(uri, refUpdates);
59 /**
60 * @return set of remote repositories URIish. Set is ordered in addition
61 * sequence.
63 public Set<URIish> getURIs() {
64 return Collections.unmodifiableSet(urisRefUpdates.keySet());
67 /**
68 * @return number of remote repositories URI for this push operation.
70 public int getURIsNumber() {
71 return urisRefUpdates.keySet().size();
74 /**
75 * @param uri
76 * remote repository URI.
77 * @return remote ref updates as specified by user for this URI.
79 public Collection<RemoteRefUpdate> getRefUpdates(final URIish uri) {
80 return Collections.unmodifiableCollection(urisRefUpdates.get(uri));