FetchResult.java

  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. package org.eclipse.jgit.transport;

  14. import java.util.ArrayList;
  15. import java.util.Collection;
  16. import java.util.Collections;
  17. import java.util.HashMap;
  18. import java.util.List;
  19. import java.util.Map;

  20. /**
  21.  * Final status after a successful fetch from a remote repository.
  22.  *
  23.  * @see Transport#fetch(org.eclipse.jgit.lib.ProgressMonitor, Collection)
  24.  */
  25. public class FetchResult extends OperationResult {
  26.     private final List<FetchHeadRecord> forMerge;

  27.     private final Map<String, FetchResult> submodules;

  28.     FetchResult() {
  29.         forMerge = new ArrayList<>();
  30.         submodules = new HashMap<>();
  31.     }

  32.     void add(FetchHeadRecord r) {
  33.         if (!r.notForMerge)
  34.             forMerge.add(r);
  35.     }

  36.     /**
  37.      * Add fetch results for a submodule.
  38.      *
  39.      * @param path
  40.      *            the submodule path
  41.      * @param result
  42.      *            the fetch result
  43.      * @since 4.7
  44.      */
  45.     public void addSubmodule(String path, FetchResult result) {
  46.         submodules.put(path, result);
  47.     }

  48.     /**
  49.      * Get fetch results for submodules.
  50.      *
  51.      * @return Fetch results for submodules as a map of submodule paths to fetch
  52.      *         results.
  53.      * @since 4.7
  54.      */
  55.     public Map<String, FetchResult> submoduleResults() {
  56.         return Collections.unmodifiableMap(submodules);
  57.     }
  58. }