Initial EGit contribution to eclipse.org
[egit.git] / org.eclipse.egit.core / src / org / eclipse / egit / core / op / PushOperationSpecification.java
blob6369f5a530910c349d3afb6db251fd9711026012
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 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *******************************************************************************/
9 package org.eclipse.egit.core.op;
11 import java.util.Collection;
12 import java.util.Collections;
13 import java.util.LinkedHashMap;
14 import java.util.Set;
16 import org.eclipse.jgit.transport.RemoteRefUpdate;
17 import org.eclipse.jgit.transport.URIish;
19 /**
20 * Data class storing push operation update specifications for each remote
21 * repository.
22 * <p>
23 * One instance is dedicated for one push operation: either push to one URI or
24 * to many URIs.
26 * @see PushOperation
28 public class PushOperationSpecification {
29 private LinkedHashMap<URIish, Collection<RemoteRefUpdate>> urisRefUpdates;
31 /**
32 * Create empty instance of specification.
33 * <p>
34 * URIs and ref updates should be configured
35 * {@link #addURIRefUpdates(URIish, Collection)} method.
37 public PushOperationSpecification() {
38 this.urisRefUpdates = new LinkedHashMap<URIish, Collection<RemoteRefUpdate>>();
41 /**
42 * Add remote repository URI with ref updates specification.
43 * <p>
44 * Ref updates are not in constructor - pay attention to not share them
45 * between different URIs ref updates or push operations.
46 * <p>
47 * Note that refUpdates can differ between URIs <b>only</b> by expected old
48 * object id field: {@link RemoteRefUpdate#getExpectedOldObjectId()}.
50 * @param uri
51 * remote repository URI.
52 * @param refUpdates
53 * collection of remote ref updates specifications.
55 public void addURIRefUpdates(final URIish uri,
56 Collection<RemoteRefUpdate> refUpdates) {
57 urisRefUpdates.put(uri, refUpdates);
60 /**
61 * @return set of remote repositories URIish. Set is ordered in addition
62 * sequence.
64 public Set<URIish> getURIs() {
65 return Collections.unmodifiableSet(urisRefUpdates.keySet());
68 /**
69 * @return number of remote repositories URI for this push operation.
71 public int getURIsNumber() {
72 return urisRefUpdates.keySet().size();
75 /**
76 * @param uri
77 * remote repository URI.
78 * @return remote ref updates as specified by user for this URI.
80 public Collection<RemoteRefUpdate> getRefUpdates(final URIish uri) {
81 return Collections.unmodifiableCollection(urisRefUpdates.get(uri));