1 /* 2 * Copyright (C) 2020, Google LLC and others 3 * 4 * This program and the accompanying materials are made available under the 5 * terms of the Eclipse Distribution License v. 1.0 which is available at 6 * https://www.eclipse.org/org/documents/edl-v10.php. 7 * 8 * SPDX-License-Identifier: BSD-3-Clause 9 */ 10 package org.eclipse.jgit.revwalk; 11 12 import java.io.IOException; 13 import java.util.Collection; 14 import java.util.Optional; 15 import java.util.stream.Stream; 16 17 /** 18 * Checks if all objects are reachable from certain starting points. 19 * 20 * This is an expensive check that browses commits, trees, blobs and tags. For 21 * reachability just between commits see {@link ReachabilityChecker} 22 * implementations. 23 * 24 * @since 5.8 25 */ 26 public interface ObjectReachabilityChecker { 27 28 /** 29 * Checks that all targets are reachable from the starters. 30 * 31 * @implSpec Missing or invalid objects are reported as illegal state. 32 * Caller should have found them while translating ObjectIds into 33 * RevObjects. They can only happen here if the caller is mixing 34 * revwalks. 35 * 36 * @param targets 37 * objects to check for reachability from the starters 38 * @param starters 39 * objects known to be reachable to the caller 40 * @return Optional a single unreachable target if there are any (there 41 * could be more). Empty optional means all targets are reachable. 42 * @throws IOException 43 * Cannot access underlying storage 44 */ 45 Optional<RevObject> areAllReachable(Collection<RevObject> targets, 46 Stream<RevObject> starters) throws IOException; 47 48 }