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
;
15 import org
.spearce
.jgit
.transport
.RemoteRefUpdate
;
16 import org
.spearce
.jgit
.transport
.URIish
;
19 * Data class storing push operation update specifications for each remote
22 * One instance is dedicated for one push operation: either push to one URI or
27 public class PushOperationSpecification
{
28 private LinkedHashMap
<URIish
, Collection
<RemoteRefUpdate
>> urisRefUpdates
;
31 * Create empty instance of specification.
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
>>();
41 * Add remote repository URI with ref updates specification.
43 * Ref updates are not in constructor - pay attention to not share them
44 * between different URIs ref updates or push operations.
46 * Note that refUpdates can differ between URIs <b>only</b> by expected old
47 * object id field: {@link RemoteRefUpdate#getExpectedOldObjectId()}.
50 * remote repository URI.
52 * collection of remote ref updates specifications.
54 public void addURIRefUpdates(final URIish uri
,
55 Collection
<RemoteRefUpdate
> refUpdates
) {
56 urisRefUpdates
.put(uri
, refUpdates
);
60 * @return set of remote repositories URIish. Set is ordered in addition
63 public Set
<URIish
> getURIs() {
64 return Collections
.unmodifiableSet(urisRefUpdates
.keySet());
68 * @return number of remote repositories URI for this push operation.
70 public int getURIsNumber() {
71 return urisRefUpdates
.keySet().size();
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
));