summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorIvan Frade <ifrade@google.com>2018-10-15 16:49:13 -0700
committerIvan Frade <ifrade@google.com>2018-10-16 11:11:26 -0700
commitec838fee0c886b395d4fedf4ce77a49b653b4a61 (patch)
tree204597fd2a07c9757e6390e1b6ec8633ce36668e /org.eclipse.jgit
parent1a0b48fecd6ec7654d58b5ca8695b9a346655f04 (diff)
downloadjgit-ec838fee0c886b395d4fedf4ce77a49b653b4a61.tar.gz
jgit-ec838fee0c886b395d4fedf4ce77a49b653b4a61.zip
Mark fetch requests fields as final and @NonNull when possible
Mark reference fields as final, annotate constructor parameters and getters as @NonNull when appropiate and assert the incoming references are non-null. Change-Id: I0ef9a513a99313bf461fe9629ce6cc8b409bdedb Signed-off-by: Ivan Frade <ifrade@google.com>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchRequest.java19
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchV0Request.java13
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchV2Request.java32
3 files changed, 33 insertions, 31 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchRequest.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchRequest.java
index a960b4a4b5..fbb58ccbc8 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchRequest.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchRequest.java
@@ -42,6 +42,8 @@
*/
package org.eclipse.jgit.transport;
+import static java.util.Objects.requireNonNull;
+
import java.util.Set;
import org.eclipse.jgit.annotations.NonNull;
@@ -76,19 +78,14 @@ abstract class FetchRequest {
* @param clientCapabilities
* capabilities sent in the request
*/
- FetchRequest(Set<ObjectId> wantIds, int depth,
- Set<ObjectId> clientShallowCommits, long filterBlobLimit,
- Set<String> clientCapabilities) {
- if (wantIds == null || clientShallowCommits == null
- || clientCapabilities == null) {
- throw new NullPointerException();
- }
-
- this.wantIds = wantIds;
+ FetchRequest(@NonNull Set<ObjectId> wantIds, int depth,
+ @NonNull Set<ObjectId> clientShallowCommits, long filterBlobLimit,
+ @NonNull Set<String> clientCapabilities) {
+ this.wantIds = requireNonNull(wantIds);
this.depth = depth;
- this.clientShallowCommits = clientShallowCommits;
+ this.clientShallowCommits = requireNonNull(clientShallowCommits);
this.filterBlobLimit = filterBlobLimit;
- this.clientCapabilities = clientCapabilities;
+ this.clientCapabilities = requireNonNull(clientCapabilities);
}
/**
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchV0Request.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchV0Request.java
index a40c734718..22ad629e37 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchV0Request.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchV0Request.java
@@ -46,6 +46,7 @@ import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
+import org.eclipse.jgit.annotations.NonNull;
import org.eclipse.jgit.lib.ObjectId;
/**
@@ -53,9 +54,9 @@ import org.eclipse.jgit.lib.ObjectId;
*/
final class FetchV0Request extends FetchRequest {
- FetchV0Request(Set<ObjectId> wantIds, int depth,
- Set<ObjectId> clientShallowCommits, long filterBlobLimit,
- Set<String> clientCapabilities) {
+ FetchV0Request(@NonNull Set<ObjectId> wantIds, int depth,
+ @NonNull Set<ObjectId> clientShallowCommits, long filterBlobLimit,
+ @NonNull Set<String> clientCapabilities) {
super(wantIds, depth, clientShallowCommits, filterBlobLimit,
clientCapabilities);
}
@@ -64,13 +65,13 @@ final class FetchV0Request extends FetchRequest {
int depth;
- Set<ObjectId> wantIds = new HashSet<>();
+ final Set<ObjectId> wantIds = new HashSet<>();
- Set<ObjectId> clientShallowCommits = new HashSet<>();
+ final Set<ObjectId> clientShallowCommits = new HashSet<>();
long filterBlobLimit = -1;
- Set<String> clientCaps = new HashSet<>();
+ final Set<String> clientCaps = new HashSet<>();
/**
* @param objectId
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchV2Request.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchV2Request.java
index 7d84b19a4e..dcca522ae1 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchV2Request.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchV2Request.java
@@ -42,6 +42,8 @@
*/
package org.eclipse.jgit.transport;
+import static java.util.Objects.requireNonNull;
+
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@@ -71,16 +73,18 @@ public final class FetchV2Request extends FetchRequest {
private final boolean doneReceived;
- private FetchV2Request(List<ObjectId> peerHas,
- TreeMap<String, ObjectId> wantedRefs, Set<ObjectId> wantIds,
- Set<ObjectId> clientShallowCommits, int deepenSince,
- List<String> deepenNotRefs, int depth, long filterBlobLimit,
- boolean doneReceived, Set<String> clientCapabilities) {
+ FetchV2Request(@NonNull List<ObjectId> peerHas,
+ @NonNull TreeMap<String, ObjectId> wantedRefs,
+ @NonNull Set<ObjectId> wantIds,
+ @NonNull Set<ObjectId> clientShallowCommits, int deepenSince,
+ @NonNull List<String> deepenNotRefs, int depth,
+ long filterBlobLimit,
+ boolean doneReceived, @NonNull Set<String> clientCapabilities) {
super(wantIds, depth, clientShallowCommits, filterBlobLimit, clientCapabilities);
- this.peerHas = peerHas;
- this.wantedRefs = wantedRefs;
+ this.peerHas = requireNonNull(peerHas);
+ this.wantedRefs = requireNonNull(wantedRefs);
this.deepenSince = deepenSince;
- this.deepenNotRefs = deepenNotRefs;
+ this.deepenNotRefs = requireNonNull(deepenNotRefs);
this.doneReceived = doneReceived;
}
@@ -134,17 +138,17 @@ public final class FetchV2Request extends FetchRequest {
/** A builder for {@link FetchV2Request}. */
static final class Builder {
- List<ObjectId> peerHas = new ArrayList<>();
+ final List<ObjectId> peerHas = new ArrayList<>();
- TreeMap<String, ObjectId> wantedRefs = new TreeMap<>();
+ final TreeMap<String, ObjectId> wantedRefs = new TreeMap<>();
- Set<ObjectId> wantIds = new HashSet<>();
+ final Set<ObjectId> wantIds = new HashSet<>();
- Set<ObjectId> clientShallowCommits = new HashSet<>();
+ final Set<ObjectId> clientShallowCommits = new HashSet<>();
- List<String> deepenNotRefs = new ArrayList<>();
+ final List<String> deepenNotRefs = new ArrayList<>();
- Set<String> clientCapabilities = new HashSet<>();
+ final Set<String> clientCapabilities = new HashSet<>();
int depth;