1 /*
2 * Copyright (C) 2009, Google Inc.
3 * Copyright (C) 2008, Marek Zawirski <marek.zawirski@gmail.com>
4 * Copyright (C) 2007, Robin Rosenberg <robin.rosenberg@dewire.com>
5 * Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org> and others
6 *
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Distribution License v. 1.0 which is available at
9 * https://www.eclipse.org/org/documents/edl-v10.php.
10 *
11 * SPDX-License-Identifier: BSD-3-Clause
12 */
13
14 package org.eclipse.jgit.transport;
15
16 import java.util.ArrayList;
17 import java.util.Collection;
18 import java.util.Collections;
19 import java.util.HashMap;
20 import java.util.List;
21 import java.util.Map;
22
23 /**
24 * Final status after a successful fetch from a remote repository.
25 *
26 * @see Transport#fetch(org.eclipse.jgit.lib.ProgressMonitor, Collection)
27 */
28 public class FetchResult extends OperationResult {
29 private final List<FetchHeadRecord> forMerge;
30
31 private final Map<String, FetchResult> submodules;
32
33 FetchResult() {
34 forMerge = new ArrayList<>();
35 submodules = new HashMap<>();
36 }
37
38 void add(FetchHeadRecord r) {
39 if (!r.notForMerge)
40 forMerge.add(r);
41 }
42
43 /**
44 * Add fetch results for a submodule.
45 *
46 * @param path
47 * the submodule path
48 * @param result
49 * the fetch result
50 * @since 4.7
51 */
52 public void addSubmodule(String path, FetchResult result) {
53 submodules.put(path, result);
54 }
55
56 /**
57 * Get fetch results for submodules.
58 *
59 * @return Fetch results for submodules as a map of submodule paths to fetch
60 * results.
61 * @since 4.7
62 */
63 public Map<String, FetchResult> submoduleResults() {
64 return Collections.unmodifiableMap(submodules);
65 }
66 }