View Javadoc
1   /*
2    * Copyright (C) 2017, 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.internal.storage.reftable;
12  
13  import java.io.IOException;
14  
15  import org.eclipse.jgit.lib.Ref;
16  
17  /**
18   * Iterator over references inside a
19   * {@link org.eclipse.jgit.internal.storage.reftable.Reftable}.
20   */
21  public abstract class RefCursor implements AutoCloseable {
22  	/**
23  	 * Check if another reference is available.
24  	 *
25  	 * @return {@code true} if there is another result.
26  	 * @throws java.io.IOException
27  	 *             references cannot be read.
28  	 */
29  	public abstract boolean next() throws IOException;
30  
31  	/**
32  	 * Get reference at the current position.
33  	 *
34  	 * @return reference at the current position.
35  	 */
36  	public abstract Ref getRef();
37  
38  	/**
39  	 * Whether the current reference was deleted.
40  	 *
41  	 * @return {@code true} if the current reference was deleted.
42  	 */
43  	public boolean wasDeleted() {
44  		Ref r = getRef();
45  		return r.getStorage() == Ref.Storage.NEW && r.getObjectId() == null;
46  	}
47  
48  	/** {@inheritDoc} */
49  	@Override
50  	public abstract void close();
51  }