View Javadoc
1   /*
2    * Copyright (C) 2010, Google Inc. 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  
11  package org.eclipse.jgit.transport;
12  
13  import java.util.Map;
14  
15  import org.eclipse.jgit.lib.Ref;
16  
17  /**
18   * Filters the list of refs that are advertised to the client.
19   * <p>
20   * The filter is called by {@link org.eclipse.jgit.transport.ReceivePack} and
21   * {@link org.eclipse.jgit.transport.UploadPack} to ensure that the refs are
22   * filtered before they are advertised to the client.
23   * <p>
24   * This can be used by applications to control visibility of certain refs based
25   * on a custom set of rules.
26   */
27  public interface RefFilter {
28  	/**
29  	 * The default filter, allows all refs to be shown.
30  	 */
31  	RefFilter DEFAULT = (Map<String, Ref> refs) -> refs;
32  
33  	/**
34  	 * Filters a {@code Map} of refs before it is advertised to the client.
35  	 *
36  	 * @param refs
37  	 *            the refs which this method need to consider.
38  	 * @return
39  	 *            the filtered map of refs.
40  	 */
41  	Map<String, Ref> filter(Map<String, Ref> refs);
42  }