From 830117e761bddc182e4dc57150ca661976868203 Mon Sep 17 00:00:00 2001 From: Andrey Loskutov Date: Wed, 25 Nov 2015 21:19:05 +0100 Subject: [PATCH] Null-annotated RefDatabase class No other code changes except adding nullness annotations. Change-Id: If2606fb208f6690bd4fd7ad953e709a3ebd6398c Signed-off-by: Andrey Loskutov --- .../src/org/eclipse/jgit/lib/RefDatabase.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java index b62033cbd2..986666f2f4 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefDatabase.java @@ -51,6 +51,9 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.eclipse.jgit.annotations.NonNull; +import org.eclipse.jgit.annotations.Nullable; + /** * Abstraction of name to {@link ObjectId} mapping. *

@@ -132,6 +135,7 @@ public abstract class RefDatabase { * @since 2.3 * @see #isNameConflicting(String) */ + @NonNull public Collection getConflictingNames(String name) throws IOException { Map allRefs = getRefs(ALL); @@ -169,6 +173,7 @@ public abstract class RefDatabase { * @throws IOException * the reference space cannot be accessed. */ + @NonNull public abstract RefUpdate newUpdate(String name, boolean detach) throws IOException; @@ -183,6 +188,7 @@ public abstract class RefDatabase { * @throws IOException * the reference space cannot be accessed. */ + @NonNull public abstract RefRename newRename(String fromName, String toName) throws IOException; @@ -193,6 +199,7 @@ public abstract class RefDatabase { * * @return a new batch update object. */ + @NonNull public BatchRefUpdate newBatchUpdate() { return new BatchRefUpdate(this); } @@ -223,6 +230,7 @@ public abstract class RefDatabase { * @throws IOException * the reference space cannot be accessed. */ + @Nullable public abstract Ref getRef(String name) throws IOException; /** @@ -238,6 +246,7 @@ public abstract class RefDatabase { * the reference space cannot be accessed. * @since 4.1 */ + @Nullable public Ref exactRef(String name) throws IOException { Ref ref = getRef(name); if (ref == null || !name.equals(ref.getName())) { @@ -261,6 +270,7 @@ public abstract class RefDatabase { * the reference space cannot be accessed. * @since 4.1 */ + @NonNull public Map exactRef(String... refs) throws IOException { Map result = new HashMap<>(refs.length); for (String name : refs) { @@ -285,6 +295,7 @@ public abstract class RefDatabase { * the reference space cannot be accessed. * @since 4.1 */ + @Nullable public Ref firstExactRef(String... refs) throws IOException { for (String name : refs) { Ref ref = exactRef(name); @@ -308,6 +319,7 @@ public abstract class RefDatabase { * @throws IOException * the reference space cannot be accessed. */ + @NonNull public abstract Map getRefs(String prefix) throws IOException; /** @@ -322,6 +334,7 @@ public abstract class RefDatabase { * @throws IOException * the reference space cannot be accessed. */ + @NonNull public abstract List getAdditionalRefs() throws IOException; /** @@ -338,10 +351,11 @@ public abstract class RefDatabase { * @return {@code ref} if {@code ref.isPeeled()} is true; otherwise a new * Ref object representing the same data as Ref, but isPeeled() will * be true and getPeeledObjectId() will contain the peeled object - * (or null). + * (or {@code null}). * @throws IOException * the reference space or object space cannot be accessed. */ + @NonNull public abstract Ref peel(Ref ref) throws IOException; /** @@ -365,9 +379,10 @@ public abstract class RefDatabase { * @param name * short name of ref to find, e.g. "master" to find * "refs/heads/master" in map. - * @return The first ref matching the name, or null if not found. + * @return The first ref matching the name, or {@code null} if not found. * @since 3.4 */ + @Nullable public static Ref findRef(Map map, String name) { for (String prefix : SEARCH_PATH) { String fullname = prefix + name; -- 2.39.5