From 608b6b03b1182329ae6f76a4c3938874dcc9c210 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Tue, 9 Oct 2018 15:48:16 -0700 Subject: [PATCH] Format @Nullable on return value as method annotation For example, instead of using public @Nullable String getMyFavoriteString() { ... } use @Nullable public String getMyFavoriteString() { ... } This makes the style more consistent (the existing JGit code base tends to lean toward the second style) and makes the source code better reflect how the annotation is parsed, as a METHOD annotation. Longer term, we should switch to a TYPE_USE annotation and switch to the first style. Noticed using a style checker that follows https://google.github.io/styleguide/javaguide.html#s4.8.5-annotations Change-Id: I07f4e67cc149fb8007f696a4663e10d4bfc57e3a Reported-by: Ivan Frade Signed-off-by: Jonathan Nieder --- .../org/eclipse/jgit/lfs/server/LargeFileRepository.java | 3 ++- .../org/eclipse/jgit/lfs/server/fs/FileLfsRepository.java | 3 ++- .../src/org/eclipse/jgit/lfs/BuiltinLFS.java | 3 ++- .../eclipse/jgit/lfs/internal/AtomicObjectOutputStream.java | 3 ++- .../src/org/eclipse/jgit/transport/TransferConfig.java | 3 ++- org.eclipse.jgit/src/org/eclipse/jgit/util/LfsFactory.java | 6 ++++-- .../src/org/eclipse/jgit/util/RawParseUtils.java | 3 ++- 7 files changed, 16 insertions(+), 8 deletions(-) diff --git a/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/LargeFileRepository.java b/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/LargeFileRepository.java index cfa53af9c..4cb0277b6 100644 --- a/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/LargeFileRepository.java +++ b/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/LargeFileRepository.java @@ -82,7 +82,8 @@ public interface LargeFileRepository { * @return Action for verifying the object, or {@code null} if the server * doesn't support or require verification */ - public @Nullable Response.Action getVerifyAction(AnyLongObjectId id); + @Nullable + public Response.Action getVerifyAction(AnyLongObjectId id); /** * Get size of an object diff --git a/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/fs/FileLfsRepository.java b/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/fs/FileLfsRepository.java index 55d909324..0a7c37ca5 100644 --- a/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/fs/FileLfsRepository.java +++ b/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/fs/FileLfsRepository.java @@ -99,7 +99,8 @@ public Action getUploadAction(AnyLongObjectId id, long size) { /** {@inheritDoc} */ @Override - public @Nullable Action getVerifyAction(AnyLongObjectId id) { + @Nullable + public Action getVerifyAction(AnyLongObjectId id) { return null; } diff --git a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/BuiltinLFS.java b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/BuiltinLFS.java index 415caa985..56e3a12dd 100644 --- a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/BuiltinLFS.java +++ b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/BuiltinLFS.java @@ -99,7 +99,8 @@ public LfsInputStream applyCleanFilter(Repository db, InputStream input, } @Override - public @Nullable PrePushHook getPrePushHook(Repository repo, + @Nullable + public PrePushHook getPrePushHook(Repository repo, PrintStream outputStream) { if (isEnabled(repo)) { return new LfsPrePushHook(repo, outputStream); diff --git a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/internal/AtomicObjectOutputStream.java b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/internal/AtomicObjectOutputStream.java index 0762ac5f1..317d68a98 100644 --- a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/internal/AtomicObjectOutputStream.java +++ b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/internal/AtomicObjectOutputStream.java @@ -106,7 +106,8 @@ public AtomicObjectOutputStream(Path path) throws IOException { * stream. May return {@code null} if called before closing this * stream. */ - public @Nullable AnyLongObjectId getId() { + @Nullable + public AnyLongObjectId getId() { return id; } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransferConfig.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransferConfig.java index 6b8d5c598..4f2ea64e1 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransferConfig.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransferConfig.java @@ -106,7 +106,8 @@ enum ProtocolVersion { this.name = name; } - static @Nullable ProtocolVersion parse(@Nullable String name) { + @Nullable + static ProtocolVersion parse(@Nullable String name) { if (name == null) { return null; } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/LfsFactory.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/LfsFactory.java index 8c6cc5280..96636b799 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/LfsFactory.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/LfsFactory.java @@ -152,7 +152,8 @@ public ObjectLoader applySmudgeFilter(Repository db, * @param outputStream * @return a {@link PrePushHook} implementation or null */ - public @Nullable PrePushHook getPrePushHook(Repository repo, + @Nullable + public PrePushHook getPrePushHook(Repository repo, PrintStream outputStream) { return null; } @@ -163,7 +164,8 @@ public ObjectLoader applySmudgeFilter(Repository db, * * @return a command to install LFS support. */ - public @Nullable LfsInstallCommand getInstallCommand() { + @Nullable + public LfsInstallCommand getInstallCommand() { return null; } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/RawParseUtils.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/RawParseUtils.java index 28f406a49..bbb1645c5 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/RawParseUtils.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/RawParseUtils.java @@ -729,7 +729,8 @@ public static final IntList lineMapOrBinary(byte[] buf, int ptr, int end) return map; } - private static @Nullable IntList lineMapOrNull(byte[] buf, int ptr, int end) { + @Nullable + private static IntList lineMapOrNull(byte[] buf, int ptr, int end) { // Experimentally derived from multiple source repositories // the average number of bytes/line is 36. Its a rough guess // to initially size our map close to the target.