Skip to content

Commit fed04ca

Browse files
committed
replaced static collection constructors from Google with standard Java ones
1 parent 5f76cde commit fed04ca

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

src/main/java/pl/project13/jgit/DescribeResult.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@
2727
import org.jetbrains.annotations.Nullable;
2828

2929
import java.io.IOException;
30+
import java.util.ArrayList;
31+
import java.util.Arrays;
32+
import java.util.Collections;
3033
import java.util.List;
3134

32-
import static com.google.common.collect.Lists.newArrayList;
33-
3435
/**
3536
* Represents the result of a <code>git describe</code> command.
3637
*
@@ -134,9 +135,9 @@ public String toString() {
134135
List<String> parts;
135136

136137
if (abbrevZeroHidesCommitsPartOfDescribe()) {
137-
parts = newArrayList(tag());
138+
parts = new ArrayList<>(Collections.singletonList(tag()));
138139
} else {
139-
parts = newArrayList(tag(), commitsAwayFromTag(), prefixedCommitId());
140+
parts = new ArrayList<>(Arrays.asList(tag(), commitsAwayFromTag(), prefixedCommitId()));
140141
}
141142

142143
return Joiner.on("-").skipNulls().join(parts) + dirtyMarker(); // like in the describe spec the entire "-dirty" is configurable (incl. "-")

src/main/java/pl/project13/jgit/JGitCommon.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717

1818
package pl.project13.jgit;
1919

20-
import static com.google.common.collect.Lists.newArrayList;
21-
import static com.google.common.collect.Maps.newHashMap;
22-
2320
import java.io.IOException;
2421
import java.util.*;
2522
import java.util.regex.Pattern;
@@ -108,7 +105,7 @@ public String getClosestTagCommitCount(@NotNull Repository repo, RevCommit headC
108105
}
109106

110107
private Map<ObjectId, List<DatedRevTag>> getClosestTagAsMap(@NotNull Repository repo){
111-
Map<ObjectId, List<DatedRevTag>> mapWithClosestTagOnly = newHashMap();
108+
Map<ObjectId, List<DatedRevTag>> mapWithClosestTagOnly = new HashMap<>();
112109
String matchPattern = ".*";
113110
Map<ObjectId, List<DatedRevTag>> commitIdsToTags = getCommitIdsToTags(repo, true, matchPattern);
114111
LinkedHashMap<ObjectId, List<DatedRevTag>> sortedCommitIdsToTags = sortByDatedRevTag(commitIdsToTags);
@@ -144,7 +141,7 @@ public int compare(Map.Entry<ObjectId, List<DatedRevTag>> m1, Map.Entry<ObjectId
144141
}
145142

146143
protected Map<ObjectId, List<DatedRevTag>> getCommitIdsToTags(@NotNull Repository repo, boolean includeLightweightTags, String matchPattern){
147-
Map<ObjectId, List<DatedRevTag>> commitIdsToTags = newHashMap();
144+
Map<ObjectId, List<DatedRevTag>> commitIdsToTags = new HashMap<>();
148145

149146
try (RevWalk walk = new RevWalk(repo)) {
150147
walk.markStart(walk.parseCommit(repo.resolve("HEAD")));
@@ -176,7 +173,7 @@ protected Map<ObjectId, List<DatedRevTag>> getCommitIdsToTags(@NotNull Repositor
176173
if (commitIdsToTags.containsKey(taggedCommitId)) {
177174
commitIdsToTags.get(taggedCommitId).add(new DatedRevTag(revTag));
178175
} else {
179-
commitIdsToTags.put(taggedCommitId, newArrayList(new DatedRevTag(revTag)));
176+
commitIdsToTags.put(taggedCommitId, new ArrayList<>(Collections.singletonList(new DatedRevTag(revTag))));
180177
}
181178

182179
} catch (IncorrectObjectTypeException ex) {
@@ -190,7 +187,7 @@ protected Map<ObjectId, List<DatedRevTag>> getCommitIdsToTags(@NotNull Repositor
190187
if (commitIdsToTags.containsKey(resolvedCommitId)) {
191188
commitIdsToTags.get(resolvedCommitId).add(datedRevTag);
192189
} else {
193-
commitIdsToTags.put(resolvedCommitId, newArrayList(datedRevTag));
190+
commitIdsToTags.put(resolvedCommitId, new ArrayList<>(Collections.singletonList(datedRevTag)));
194191
}
195192
}
196193
} catch (Exception ignored) {
@@ -214,7 +211,7 @@ private boolean isTagId(ObjectId objectId) {
214211
}
215212

216213
protected HashMap<ObjectId, List<String>> transformRevTagsMapToDateSortedTagNames(Map<ObjectId, List<DatedRevTag>> commitIdsToTags) {
217-
HashMap<ObjectId, List<String>> commitIdsToTagNames = newHashMap();
214+
HashMap<ObjectId, List<String>> commitIdsToTagNames = new HashMap<>();
218215
for (Map.Entry<ObjectId, List<DatedRevTag>> objectIdListEntry : commitIdsToTags.entrySet()) {
219216
List<String> tagNames = transformRevTagsMapEntryToDateSortedTagNames(objectIdListEntry);
220217

@@ -226,7 +223,7 @@ protected HashMap<ObjectId, List<String>> transformRevTagsMapToDateSortedTagName
226223
private List<String> transformRevTagsMapEntryToDateSortedTagNames(Map.Entry<ObjectId, List<DatedRevTag>> objectIdListEntry) {
227224
List<DatedRevTag> tags = objectIdListEntry.getValue();
228225

229-
List<DatedRevTag> newTags = newArrayList(tags);
226+
List<DatedRevTag> newTags = new ArrayList<>(tags);
230227
Collections.sort(newTags, datedRevTagComparator());
231228

232229
List<String> tagNames = Lists.transform(newTags, new Function<DatedRevTag, String>() {
@@ -341,4 +338,4 @@ private void seeAllParents(@NotNull RevWalk revWalk, RevCommit child, @NotNull S
341338
}
342339
}
343340

344-
}
341+
}

0 commit comments

Comments
 (0)