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
;
16 import org
.eclipse
.jgit
.transport
.RemoteRefUpdate
;
17 import org
.eclipse
.jgit
.transport
.URIish
;
20 * Data class storing push operation update specifications for each remote
23 * One instance is dedicated for one push operation: either push to one URI or
28 public class PushOperationSpecification
{
29 private LinkedHashMap
<URIish
, Collection
<RemoteRefUpdate
>> urisRefUpdates
;
32 * Create empty instance of specification.
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
>>();
42 * Add remote repository URI with ref updates specification.
44 * Ref updates are not in constructor - pay attention to not share them
45 * between different URIs ref updates or push operations.
47 * Note that refUpdates can differ between URIs <b>only</b> by expected old
48 * object id field: {@link RemoteRefUpdate#getExpectedOldObjectId()}.
51 * remote repository URI.
53 * collection of remote ref updates specifications.
55 public void addURIRefUpdates(final URIish uri
,
56 Collection
<RemoteRefUpdate
> refUpdates
) {
57 urisRefUpdates
.put(uri
, refUpdates
);
61 * @return set of remote repositories URIish. Set is ordered in addition
64 public Set
<URIish
> getURIs() {
65 return Collections
.unmodifiableSet(urisRefUpdates
.keySet());
69 * @return number of remote repositories URI for this push operation.
71 public int getURIsNumber() {
72 return urisRefUpdates
.keySet().size();
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
));