Upgrade google-java-format to 1.7

This new version has the nice feature of putting multiple chained method
calls before a .stream() on a single line. The diff is a bit large but
it's removing a lot of newlines which is nice.

Change-Id: I260b620aa6a1bc77b06be9672a1f281ab0d0d0f8
This commit is contained in:
Dave Borowitz
2019-01-28 07:21:29 -08:00
committed by David Pursehouse
parent 83fab68dc5
commit 3efa1058b2
47 changed files with 65 additions and 170 deletions

View File

@@ -153,7 +153,7 @@ Guide].
To format Java source code, Gerrit uses the To format Java source code, Gerrit uses the
link:https://github.com/google/google-java-format[`google-java-format`] link:https://github.com/google/google-java-format[`google-java-format`]
tool (version 1.6), and to format Bazel BUILD, WORKSPACE and .bzl files the tool (version 1.7), and to format Bazel BUILD, WORKSPACE and .bzl files the
link:https://github.com/bazelbuild/buildtools/tree/master/buildifier[`buildifier`] link:https://github.com/bazelbuild/buildtools/tree/master/buildifier[`buildifier`]
tool (version 0.20.0). tool (version 0.20.0).
These tools automatically apply format according to the style guides; this These tools automatically apply format according to the style guides; this

View File

@@ -47,7 +47,7 @@ Filters on a folder, they will be overwritten the next time you run
To format source code, Gerrit uses the To format source code, Gerrit uses the
link:https://github.com/google/google-java-format[`google-java-format`] link:https://github.com/google/google-java-format[`google-java-format`]
tool (version 1.3), which automatically formats code to follow the tool (version 1.7), which automatically formats code to follow the
style guide. See link:dev-contributing.html#style[Code Style] for the style guide. See link:dev-contributing.html#style[Code Style] for the
instruction how to set up command line tool that uses this formatter. instruction how to set up command line tool that uses this formatter.
The Eclipse plugin is provided that allows to format with the same The Eclipse plugin is provided that allows to format with the same

View File

@@ -2663,9 +2663,7 @@ public class ChangeIT extends AbstractDaemonTest {
throws Exception { throws Exception {
ChangeInfo c = gApi.changes().id(changeId).get(EnumSet.of(ListChangesOption.DETAILED_LABELS)); ChangeInfo c = gApi.changes().id(changeId).get(EnumSet.of(ListChangesOption.DETAILED_LABELS));
Set<ReviewerState> states = Set<ReviewerState> states =
c.reviewers c.reviewers.entrySet().stream()
.entrySet()
.stream()
.filter(e -> e.getValue().stream().anyMatch(a -> a._accountId == accountId.get())) .filter(e -> e.getValue().stream().anyMatch(a -> a._accountId == accountId.get()))
.map(e -> e.getKey()) .map(e -> e.getKey())
.collect(toSet()); .collect(toSet());

View File

@@ -206,11 +206,7 @@ public class RevisionIT extends AbstractDaemonTest {
setApiUser(admin); setApiUser(admin);
gApi.changes().id(changeId).reviewer(user.username).deleteVote("Code-Review"); gApi.changes().id(changeId).reviewer(user.username).deleteVote("Code-Review");
Optional<ApprovalInfo> crUser = Optional<ApprovalInfo> crUser =
get(changeId, DETAILED_LABELS) get(changeId, DETAILED_LABELS).labels.get("Code-Review").all.stream()
.labels
.get("Code-Review")
.all
.stream()
.filter(a -> a._accountId == user.id.get()) .filter(a -> a._accountId == user.id.get())
.findFirst(); .findFirst();
assertThat(crUser.isPresent()).isTrue(); assertThat(crUser.isPresent()).isTrue();
@@ -225,13 +221,8 @@ public class RevisionIT extends AbstractDaemonTest {
revision(r).review(in); revision(r).review(in);
ApprovalInfo cr = ApprovalInfo cr =
gApi.changes() gApi.changes().id(changeId).get(EnumSet.of(ListChangesOption.DETAILED_LABELS)).labels
.id(changeId) .get("Code-Review").all.stream()
.get(EnumSet.of(ListChangesOption.DETAILED_LABELS))
.labels
.get("Code-Review")
.all
.stream()
.filter(a -> a._accountId == user.getId().get()) .filter(a -> a._accountId == user.getId().get())
.findFirst() .findFirst()
.get(); .get();

View File

@@ -66,11 +66,7 @@ public abstract class AbstractReindexTests extends StandaloneSiteTest {
.containsExactly(adminId.get()); .containsExactly(adminId.get());
// Query group index // Query group index
assertThat( assertThat(
gApi.groups() gApi.groups().query("Group").withOption(MEMBERS).get().stream()
.query("Group")
.withOption(MEMBERS)
.get()
.stream()
.flatMap(g -> g.members.stream()) .flatMap(g -> g.members.stream())
.map(a -> a._accountId)) .map(a -> a._accountId))
.containsExactly(adminId.get()); .containsExactly(adminId.get());

View File

@@ -310,8 +310,7 @@ public class DraftChangeIT extends AbstractDaemonTest {
// Change status in NoteDb. // Change status in NoteDb.
PatchSetState patchSetState = draftStatus ? PatchSetState.DRAFT : PatchSetState.PUBLISHED; PatchSetState patchSetState = draftStatus ? PatchSetState.DRAFT : PatchSetState.PUBLISHED;
patchSets patchSets.stream()
.stream()
.map(PatchSet::getId) .map(PatchSet::getId)
.map(ctx::getUpdate) .map(ctx::getUpdate)
.forEach(changeUpdate -> changeUpdate.setPatchSetState(patchSetState)); .forEach(changeUpdate -> changeUpdate.setPatchSetState(patchSetState));

View File

@@ -451,8 +451,7 @@ public class SuggestReviewersIT extends AbstractDaemonTest {
List<TestAccount> expectedUsers, List<TestAccount> expectedUsers,
List<AccountGroup> expectedGroups) { List<AccountGroup> expectedGroups) {
List<Integer> actualAccountIds = List<Integer> actualAccountIds =
actual actual.stream()
.stream()
.filter(i -> i.account != null) .filter(i -> i.account != null)
.map(i -> i.account._accountId) .map(i -> i.account._accountId)
.collect(toList()); .collect(toList());

View File

@@ -35,8 +35,7 @@ public class KillTaskIT extends AbstractDaemonTest {
r.consume(); r.consume();
Optional<String> id = Optional<String> id =
result result.stream()
.stream()
.filter(t -> "Log File Compressor".equals(t.command)) .filter(t -> "Log File Compressor".equals(t.command))
.map(t -> t.id) .map(t -> t.id)
.findFirst(); .findFirst();

View File

@@ -270,8 +270,7 @@ public class NoteDbPrimaryIT extends AbstractDaemonTest {
assert_().fail("expected read-only exception"); assert_().fail("expected read-only exception");
} catch (RestApiException e) { } catch (RestApiException e) {
Optional<Throwable> oe = Optional<Throwable> oe =
Throwables.getCausalChain(e) Throwables.getCausalChain(e).stream()
.stream()
.filter(x -> x instanceof OrmRuntimeException) .filter(x -> x instanceof OrmRuntimeException)
.findFirst(); .findFirst();
assertThat(oe.isPresent()).named("OrmRuntimeException in causal chain of " + e).isTrue(); assertThat(oe.isPresent()).named("OrmRuntimeException in causal chain of " + e).isTrue();
@@ -523,12 +522,7 @@ public class NoteDbPrimaryIT extends AbstractDaemonTest {
} }
private List<Account.Id> getReviewers(Change.Id id) throws Exception { private List<Account.Id> getReviewers(Change.Id id) throws Exception {
return gApi.changes() return gApi.changes().id(id.get()).get().reviewers.values().stream()
.id(id.get())
.get()
.reviewers
.values()
.stream()
.flatMap(Collection::stream) .flatMap(Collection::stream)
.map(a -> new Account.Id(a._accountId)) .map(a -> new Account.Id(a._accountId))
.collect(toList()); .collect(toList());

View File

@@ -55,11 +55,8 @@ class ElasticIndexVersionDiscovery {
} }
return new JsonParser() return new JsonParser()
.parse(AbstractElasticIndex.getContent(response)) .parse(AbstractElasticIndex.getContent(response)).getAsJsonObject().entrySet().stream()
.getAsJsonObject() .map(e -> e.getKey().replace(name, ""))
.entrySet() .collect(toList());
.stream()
.map(e -> e.getKey().replace(name, ""))
.collect(toList());
} }
} }

View File

@@ -589,8 +589,7 @@ public class LuceneChangeIndex implements ChangeIndex {
} }
private static List<byte[]> copyAsBytes(Collection<IndexableField> fields) { private static List<byte[]> copyAsBytes(Collection<IndexableField> fields) {
return fields return fields.stream()
.stream()
.map( .map(
f -> { f -> {
BytesRef ref = f.binaryValue(); BytesRef ref = f.binaryValue();

View File

@@ -27,8 +27,7 @@ public class ModuleOverloader {
// group candidates by annotation existence // group candidates by annotation existence
Map<Boolean, List<Module>> grouped = Map<Boolean, List<Module>> grouped =
overrideCandidates overrideCandidates.stream()
.stream()
.collect( .collect(
Collectors.groupingBy(m -> m.getClass().getAnnotation(ModuleImpl.class) != null)); Collectors.groupingBy(m -> m.getClass().getAnnotation(ModuleImpl.class) != null));
@@ -44,16 +43,14 @@ public class ModuleOverloader {
} }
// swipe cache implementation with alternative provided in lib // swipe cache implementation with alternative provided in lib
return modules return modules.stream()
.stream()
.map( .map(
m -> { m -> {
ModuleImpl a = m.getClass().getAnnotation(ModuleImpl.class); ModuleImpl a = m.getClass().getAnnotation(ModuleImpl.class);
if (a == null) { if (a == null) {
return m; return m;
} }
return overrides return overrides.stream()
.stream()
.filter( .filter(
o -> o ->
o.getClass() o.getClass()

View File

@@ -182,9 +182,7 @@ public class ReviewerRecommender {
// Sort results // Sort results
Stream<Entry<Account.Id, MutableDouble>> sorted = Stream<Entry<Account.Id, MutableDouble>> sorted =
reviewerScores reviewerScores.entrySet().stream()
.entrySet()
.stream()
.sorted(Collections.reverseOrder(Map.Entry.comparingByValue())); .sorted(Collections.reverseOrder(Map.Entry.comparingByValue()));
List<Account.Id> sortedSuggestions = sorted.map(Map.Entry::getKey).collect(toList()); List<Account.Id> sortedSuggestions = sorted.map(Map.Entry::getKey).collect(toList());
return sortedSuggestions; return sortedSuggestions;

View File

@@ -223,8 +223,7 @@ public class ReviewersUtil {
throws OrmException { throws OrmException {
try (Timer0.Context ctx = metrics.loadAccountsLatency.start()) { try (Timer0.Context ctx = metrics.loadAccountsLatency.start()) {
List<SuggestedReviewerInfo> reviewer = List<SuggestedReviewerInfo> reviewer =
accountIds accountIds.stream()
.stream()
.map(accountLoader::get) .map(accountLoader::get)
.filter(Objects::nonNull) .filter(Objects::nonNull)
.map( .map(

View File

@@ -269,8 +269,7 @@ public class StarredChangesUtil {
public Set<Account.Id> byChange(final Change.Id changeId, final String label) public Set<Account.Id> byChange(final Change.Id changeId, final String label)
throws OrmException { throws OrmException {
try (Repository repo = repoManager.openRepository(allUsers)) { try (Repository repo = repoManager.openRepository(allUsers)) {
return getRefNames(repo, RefNames.refsStarredChangesPrefix(changeId)) return getRefNames(repo, RefNames.refsStarredChangesPrefix(changeId)).stream()
.stream()
.map(Account.Id::parse) .map(Account.Id::parse)
.filter(accountId -> hasStar(repo, changeId, accountId, label)) .filter(accountId -> hasStar(repo, changeId, accountId, label))
.collect(toSet()); .collect(toSet());
@@ -285,8 +284,7 @@ public class StarredChangesUtil {
public Set<Change.Id> byAccount(final Account.Id accountId, final String label) public Set<Change.Id> byAccount(final Account.Id accountId, final String label)
throws OrmException { throws OrmException {
try (Repository repo = repoManager.openRepository(allUsers)) { try (Repository repo = repoManager.openRepository(allUsers)) {
return getRefNames(repo, RefNames.REFS_STARRED_CHANGES) return getRefNames(repo, RefNames.REFS_STARRED_CHANGES).stream()
.stream()
.filter(refPart -> refPart.endsWith("/" + accountId.get())) .filter(refPart -> refPart.endsWith("/" + accountId.get()))
.map(Change.Id::fromRefPart) .map(Change.Id::fromRefPart)
.filter(changeId -> hasStar(repo, changeId, accountId, label)) .filter(changeId -> hasStar(repo, changeId, accountId, label))

View File

@@ -94,9 +94,7 @@ public class AccountByEmailCacheImpl implements AccountByEmailCache {
r.add(a.getId()); r.add(a.getId());
} }
for (AccountState accountState : accountQueryProvider.get().byEmailPrefix(email)) { for (AccountState accountState : accountQueryProvider.get().byEmailPrefix(email)) {
if (accountState if (accountState.getExternalIds().stream()
.getExternalIds()
.stream()
.filter(e -> email.equals(e.email())) .filter(e -> email.equals(e.email()))
.findAny() .findAny()
.isPresent()) { .isPresent()) {

View File

@@ -185,9 +185,7 @@ public class AccountControl {
} }
private Set<AccountGroup.UUID> groupsOf(IdentifiedUser user) { private Set<AccountGroup.UUID> groupsOf(IdentifiedUser user) {
return user.getEffectiveGroups() return user.getEffectiveGroups().getKnownGroups().stream()
.getKnownGroups()
.stream()
.filter(a -> !SystemGroupBackend.isSystemGroup(a)) .filter(a -> !SystemGroupBackend.isSystemGroup(a))
.collect(toSet()); .collect(toSet());
} }

View File

@@ -395,15 +395,13 @@ public class AccountManager {
throws OrmException, AccountException, IOException { throws OrmException, AccountException, IOException {
try (ReviewDb db = schema.open()) { try (ReviewDb db = schema.open()) {
Collection<ExternalId> filteredExtIdsByScheme = Collection<ExternalId> filteredExtIdsByScheme =
ExternalId.from(db.accountExternalIds().byAccount(to).toList()) ExternalId.from(db.accountExternalIds().byAccount(to).toList()).stream()
.stream()
.filter(e -> e.isScheme(who.getExternalIdKey().scheme())) .filter(e -> e.isScheme(who.getExternalIdKey().scheme()))
.collect(toSet()); .collect(toSet());
if (!filteredExtIdsByScheme.isEmpty() if (!filteredExtIdsByScheme.isEmpty()
&& (filteredExtIdsByScheme.size() > 1 && (filteredExtIdsByScheme.size() > 1
|| !filteredExtIdsByScheme || !filteredExtIdsByScheme.stream()
.stream()
.filter(e -> e.key().equals(who.getExternalIdKey())) .filter(e -> e.key().equals(who.getExternalIdKey()))
.findAny() .findAny()
.isPresent())) { .isPresent())) {

View File

@@ -178,10 +178,7 @@ public class AccountResolver {
// At this point we have no clue. Just perform a whole bunch of suggestions // At this point we have no clue. Just perform a whole bunch of suggestions
// and pray we come up with a reasonable result list. // and pray we come up with a reasonable result list.
return accountQueryProvider return accountQueryProvider.get().byDefault(nameOrEmail).stream()
.get()
.byDefault(nameOrEmail)
.stream()
.map(a -> a.getAccount().getId()) .map(a -> a.getAccount().getId())
.collect(toSet()); .collect(toSet());
} }

View File

@@ -74,8 +74,7 @@ public class ChangeUserName implements Callable<VoidResult> {
throws OrmException, NameAlreadyUsedException, InvalidUserNameException, IOException, throws OrmException, NameAlreadyUsedException, InvalidUserNameException, IOException,
ConfigInvalidException { ConfigInvalidException {
Collection<ExternalId> old = Collection<ExternalId> old =
ExternalId.from(db.accountExternalIds().byAccount(user.getAccountId()).toList()) ExternalId.from(db.accountExternalIds().byAccount(user.getAccountId()).toList()).stream()
.stream()
.filter(e -> e.isScheme(SCHEME_USERNAME)) .filter(e -> e.isScheme(SCHEME_USERNAME))
.collect(toSet()); .collect(toSet());
if (!old.isEmpty()) { if (!old.isEmpty()) {

View File

@@ -75,12 +75,7 @@ public class DeleteEmail implements RestModifyView<AccountResource.Email, Input>
} }
Set<ExternalId> extIds = Set<ExternalId> extIds =
dbProvider dbProvider.get().accountExternalIds().byAccount(user.getAccountId()).toList().stream()
.get()
.accountExternalIds()
.byAccount(user.getAccountId())
.toList()
.stream()
.map(ExternalId::from) .map(ExternalId::from)
.filter(e -> email.equals(e.email())) .filter(e -> email.equals(e.email()))
.collect(toSet()); .collect(toSet());

View File

@@ -70,11 +70,7 @@ public class DeleteExternalIds implements RestModifyView<AccountResource, List<S
Account.Id accountId = resource.getUser().getAccountId(); Account.Id accountId = resource.getUser().getAccountId();
Map<ExternalId.Key, ExternalId> externalIdMap = Map<ExternalId.Key, ExternalId> externalIdMap =
dbProvider dbProvider.get().accountExternalIds().byAccount(resource.getUser().getAccountId()).toList()
.get()
.accountExternalIds()
.byAccount(resource.getUser().getAccountId())
.toList()
.stream() .stream()
.map(ExternalId::from) .map(ExternalId::from)
.collect(toMap(i -> i.key(), i -> i)); .collect(toMap(i -> i.key(), i -> i));

View File

@@ -63,8 +63,7 @@ public class DeleteWatchedProjects
Account.Id accountId = rsrc.getUser().getAccountId(); Account.Id accountId = rsrc.getUser().getAccountId();
watchConfig.deleteProjectWatches( watchConfig.deleteProjectWatches(
accountId, accountId,
input input.stream()
.stream()
.map(w -> ProjectWatchKey.create(new Project.NameKey(w.project), w.filter)) .map(w -> ProjectWatchKey.create(new Project.NameKey(w.project), w.filter))
.collect(toList())); .collect(toList()));
accountCache.evict(accountId); accountCache.evict(accountId);

View File

@@ -65,9 +65,7 @@ public class InternalGroupBackend implements GroupBackend {
@Override @Override
public Collection<GroupReference> suggest(final String name, final ProjectControl project) { public Collection<GroupReference> suggest(final String name, final ProjectControl project) {
return groupCache return groupCache.all().stream()
.all()
.stream()
.filter( .filter(
group -> group ->
// startsWithIgnoreCase && isVisible // startsWithIgnoreCase && isVisible

View File

@@ -222,8 +222,7 @@ public class UniversalGroupBackend implements GroupBackend {
@Override @Override
public void check() throws StartupException { public void check() throws StartupException {
String invalid = String invalid =
cfg.getSubsections("groups") cfg.getSubsections("groups").stream()
.stream()
.filter( .filter(
sub -> { sub -> {
AccountGroup.UUID uuid = new AccountGroup.UUID(sub); AccountGroup.UUID uuid = new AccountGroup.UUID(sub);

View File

@@ -412,8 +412,7 @@ public class ChangeInserter implements InsertChangeOp {
private Set<Account.Id> filterOnChangeVisibility( private Set<Account.Id> filterOnChangeVisibility(
final ReviewDb db, final ChangeNotes notes, Set<Account.Id> accounts) { final ReviewDb db, final ChangeNotes notes, Set<Account.Id> accounts) {
return accounts return accounts.stream()
.stream()
.filter( .filter(
accountId -> { accountId -> {
try { try {

View File

@@ -771,9 +771,7 @@ public class ChangeJson {
Maps.newHashMapWithExpectedSize(permittedLabels.size()); Maps.newHashMapWithExpectedSize(permittedLabels.size());
for (String label : permittedLabels.keySet()) { for (String label : permittedLabels.keySet()) {
List<Integer> permittedVotingRange = List<Integer> permittedVotingRange =
permittedLabels permittedLabels.get(label).stream()
.get(label)
.stream()
.map(this::parseRangeValue) .map(this::parseRangeValue)
.filter(java.util.Objects::nonNull) .filter(java.util.Objects::nonNull)
.sorted() .sorted()
@@ -867,9 +865,7 @@ public class ChangeJson {
} }
if (detailed) { if (detailed) {
labels labels.entrySet().stream()
.entrySet()
.stream()
.filter(e -> labelTypes.byLabel(e.getKey()) != null) .filter(e -> labelTypes.byLabel(e.getKey()) != null)
.forEach(e -> setLabelValues(labelTypes.byLabel(e.getKey()), e.getValue())); .forEach(e -> setLabelValues(labelTypes.byLabel(e.getKey()), e.getValue()));
} }
@@ -1090,8 +1086,7 @@ public class ChangeJson {
} }
private Collection<AccountInfo> toAccountInfo(Collection<Account.Id> accounts) { private Collection<AccountInfo> toAccountInfo(Collection<Account.Id> accounts) {
return accounts return accounts.stream()
.stream()
.map(accountLoader::get) .map(accountLoader::get)
.sorted(AccountInfoComparator.ORDER_NULLS_FIRST) .sorted(AccountInfoComparator.ORDER_NULLS_FIRST)
.collect(toList()); .collect(toList());

View File

@@ -897,17 +897,13 @@ public class PostReview implements RestModifyView<RevisionResource, ReviewInput>
} }
private Set<CommentSetEntry> readExistingComments(ChangeContext ctx) throws OrmException { private Set<CommentSetEntry> readExistingComments(ChangeContext ctx) throws OrmException {
return commentsUtil return commentsUtil.publishedByChange(ctx.getDb(), ctx.getNotes()).stream()
.publishedByChange(ctx.getDb(), ctx.getNotes())
.stream()
.map(CommentSetEntry::create) .map(CommentSetEntry::create)
.collect(toSet()); .collect(toSet());
} }
private Set<CommentSetEntry> readExistingRobotComments(ChangeContext ctx) throws OrmException { private Set<CommentSetEntry> readExistingRobotComments(ChangeContext ctx) throws OrmException {
return commentsUtil return commentsUtil.robotCommentsByChange(ctx.getNotes()).stream()
.robotCommentsByChange(ctx.getNotes())
.stream()
.map(CommentSetEntry::create) .map(CommentSetEntry::create)
.collect(toSet()); .collect(toSet());
} }
@@ -1166,8 +1162,7 @@ public class PostReview implements RestModifyView<RevisionResource, ReviewInput>
if (!reduced.isEmpty()) { if (!reduced.isEmpty()) {
throw new ResourceConflictException( throw new ResourceConflictException(
"Cannot reduce vote on labels for closed change: " "Cannot reduce vote on labels for closed change: "
+ reduced + reduced.stream()
.stream()
.map(p -> p.getLabel()) .map(p -> p.getLabel())
.distinct() .distinct()
.sorted() .sorted()

View File

@@ -695,9 +695,7 @@ public class ReceiveCommits {
} }
List<ReplaceRequest> updated = List<ReplaceRequest> updated =
replaceByChange replaceByChange.values().stream()
.values()
.stream()
.filter(r -> !r.skip && r.inputCommand.getResult() == OK) .filter(r -> !r.skip && r.inputCommand.getResult() == OK)
.sorted(comparingInt(r -> r.notes.getChangeId().get())) .sorted(comparingInt(r -> r.notes.getChangeId().get()))
.collect(toList()); .collect(toList());

View File

@@ -563,8 +563,7 @@ public class ChangeField {
@VisibleForTesting @VisibleForTesting
static List<SubmitRecord> parseSubmitRecords(Collection<String> values) { static List<SubmitRecord> parseSubmitRecords(Collection<String> values) {
return values return values.stream()
.stream()
.map(v -> GSON.fromJson(v, StoredSubmitRecord.class).toSubmitRecord()) .map(v -> GSON.fromJson(v, StoredSubmitRecord.class).toSubmitRecord())
.collect(toList()); .collect(toList());
} }

View File

@@ -181,8 +181,7 @@ public class MailProcessor {
// comments from the outbound email. // comments from the outbound email.
// TODO(hiesel) Also filter by original comment author. // TODO(hiesel) Also filter by original comment author.
Collection<Comment> comments = Collection<Comment> comments =
cd.publishedComments() cd.publishedComments().stream()
.stream()
.filter(c -> (c.writtenOn.getTime() / 1000) == (metadata.timestamp.getTime() / 1000)) .filter(c -> (c.writtenOn.getTime() / 1000) == (metadata.timestamp.getTime() / 1000))
.sorted(CommentsUtil.COMMENT_ORDER) .sorted(CommentsUtil.COMMENT_ORDER)
.collect(toList()); .collect(toList());
@@ -349,8 +348,7 @@ public class MailProcessor {
private Set<String> existingMessageIds(ChangeData cd) throws OrmException { private Set<String> existingMessageIds(ChangeData cd) throws OrmException {
Set<String> existingMessageIds = new HashSet<>(); Set<String> existingMessageIds = new HashSet<>();
cd.messages() cd.messages().stream()
.stream()
.forEach( .forEach(
m -> { m -> {
String messageId = CommentsUtil.extractMessageId(m.getTag()); String messageId = CommentsUtil.extractMessageId(m.getTag());
@@ -358,8 +356,7 @@ public class MailProcessor {
existingMessageIds.add(messageId); existingMessageIds.add(messageId);
} }
}); });
cd.publishedComments() cd.publishedComments().stream()
.stream()
.forEach( .forEach(
c -> { c -> {
String messageId = CommentsUtil.extractMessageId(c.tag); String messageId = CommentsUtil.extractMessageId(c.tag);

View File

@@ -86,10 +86,7 @@ public class RawMailParser {
} }
// Add additional headers // Add additional headers
mimeMessage mimeMessage.getHeader().getFields().stream()
.getHeader()
.getFields()
.stream()
.filter(f -> !MAIN_HEADERS.contains(f.getName().toLowerCase())) .filter(f -> !MAIN_HEADERS.contains(f.getName().toLowerCase()))
.forEach(f -> messageBuilder.addAdditionalHeader(f.getName() + ": " + f.getBody())); .forEach(f -> messageBuilder.addAdditionalHeader(f.getName() + ": " + f.getBody()));

View File

@@ -522,8 +522,7 @@ public class CommentSender extends ReplyToChangeSender {
} }
private List<Map<String, Object>> commentBlocksToSoyData(List<CommentFormatter.Block> blocks) { private List<Map<String, Object>> commentBlocksToSoyData(List<CommentFormatter.Block> blocks) {
return blocks return blocks.stream()
.stream()
.map( .map(
b -> { b -> {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();

View File

@@ -705,9 +705,7 @@ public class ChangeBundle {
private static boolean createdOnIsMonotonic( private static boolean createdOnIsMonotonic(
Map<?, PatchSet> patchSets, Set<PatchSet.Id> limitToIds) { Map<?, PatchSet> patchSets, Set<PatchSet.Id> limitToIds) {
List<PatchSet> orderedById = List<PatchSet> orderedById =
patchSets patchSets.values().stream()
.values()
.stream()
.filter(ps -> limitToIds.contains(ps.getId())) .filter(ps -> limitToIds.contains(ps.getId()))
.sorted(ChangeUtil.PS_ID_ORDER) .sorted(ChangeUtil.PS_ID_ORDER)
.collect(toList()); .collect(toList());

View File

@@ -409,9 +409,7 @@ public class ChangeRebuilderImpl extends ChangeRebuilder {
private static List<Comment> getComments( private static List<Comment> getComments(
ChangeBundle bundle, String serverId, PatchLineComment.Status status, PatchSet ps) { ChangeBundle bundle, String serverId, PatchLineComment.Status status, PatchSet ps) {
return bundle return bundle.getPatchLineComments().stream()
.getPatchLineComments()
.stream()
.filter(c -> c.getPatchSetId().equals(ps.getId()) && c.getStatus() == status) .filter(c -> c.getPatchSetId().equals(ps.getId()) && c.getStatus() == status)
.map(plc -> plc.asComment(serverId)) .map(plc -> plc.asComment(serverId))
.sorted(CommentsUtil.COMMENT_ORDER) .sorted(CommentsUtil.COMMENT_ORDER)

View File

@@ -180,8 +180,7 @@ public class DeleteRef {
List<String> refs = List<String> refs =
prefix == null prefix == null
? refsToDelete ? refsToDelete
: refsToDelete : refsToDelete.stream()
.stream()
.map(ref -> ref.startsWith(prefix) ? ref : prefix + ref) .map(ref -> ref.startsWith(prefix) ? ref : prefix + ref)
.collect(toList()); .collect(toList());
for (String ref : refs) { for (String ref : refs) {

View File

@@ -216,8 +216,7 @@ public class ProjectCacheImpl implements ProjectCache {
@Override @Override
public Set<AccountGroup.UUID> guessRelevantGroupUUIDs() { public Set<AccountGroup.UUID> guessRelevantGroupUUIDs() {
return all() return all().stream()
.stream()
.map(n -> byName.getIfPresent(n.get())) .map(n -> byName.getIfPresent(n.get()))
.filter(Objects::nonNull) .filter(Objects::nonNull)
.flatMap(p -> p.getConfig().getAllGroupUUIDs().stream()) .flatMap(p -> p.getConfig().getAllGroupUUIDs().stream())

View File

@@ -937,8 +937,7 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
@Operator @Operator
public Predicate<ChangeData> reviewer(String who) throws QueryParseException, OrmException { public Predicate<ChangeData> reviewer(String who) throws QueryParseException, OrmException {
return Predicate.or( return Predicate.or(
parseAccount(who) parseAccount(who).stream()
.stream()
.map(id -> ReviewerPredicate.reviewer(args, id)) .map(id -> ReviewerPredicate.reviewer(args, id))
.collect(toList())); .collect(toList()));
} }
@@ -1135,11 +1134,7 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
private Set<Account.Id> getMembers(AccountGroup.UUID g) throws OrmException { private Set<Account.Id> getMembers(AccountGroup.UUID g) throws OrmException {
Set<Account.Id> accounts; Set<Account.Id> accounts;
Set<Account.Id> allMembers = Set<Account.Id> allMembers =
args.listMembers args.listMembers.get().setRecursive(true).apply(g).stream()
.get()
.setRecursive(true)
.apply(g)
.stream()
.map(a -> new Account.Id(a._accountId)) .map(a -> new Account.Id(a._accountId))
.collect(toSet()); .collect(toSet());
int maxTerms = args.indexConfig.maxTerms(); int maxTerms = args.indexConfig.maxTerms();

View File

@@ -31,8 +31,7 @@ class SubmitRecordPredicate extends ChangeIndexPredicate {
return new SubmitRecordPredicate(status.name() + ',' + lowerLabel); return new SubmitRecordPredicate(status.name() + ',' + lowerLabel);
} }
return Predicate.or( return Predicate.or(
accounts accounts.stream()
.stream()
.map(a -> new SubmitRecordPredicate(status.name() + ',' + lowerLabel + ',' + a.get())) .map(a -> new SubmitRecordPredicate(status.name() + ',' + lowerLabel + ',' + a.get()))
.collect(toList())); .collect(toList()));
} }

View File

@@ -28,8 +28,7 @@ class SubmittablePredicate extends ChangeIndexPredicate {
@Override @Override
public boolean match(ChangeData cd) throws OrmException { public boolean match(ChangeData cd) throws OrmException {
return cd.submitRecords(ChangeField.SUBMIT_RULE_OPTIONS_STRICT) return cd.submitRecords(ChangeField.SUBMIT_RULE_OPTIONS_STRICT).stream()
.stream()
.anyMatch(r -> r.status == status); .anyMatch(r -> r.status == status);
} }

View File

@@ -76,11 +76,8 @@ public class Schema_135 extends SchemaVersion {
Set<GroupReference> groups = Set<GroupReference> groups =
Stream.concat( Stream.concat(
config config.getAccessSection(AccessSection.GLOBAL_CAPABILITIES, true)
.getAccessSection(AccessSection.GLOBAL_CAPABILITIES, true) .getPermission(GlobalCapability.ADMINISTRATE_SERVER, true).getRules().stream()
.getPermission(GlobalCapability.ADMINISTRATE_SERVER, true)
.getRules()
.stream()
.map(PermissionRule::getGroup), .map(PermissionRule::getGroup),
Stream.of(systemGroupBackend.getGroup(PROJECT_OWNERS))) Stream.of(systemGroupBackend.getGroup(PROJECT_OWNERS)))
.filter(g -> createRefsMetaConfigPermission.getRule(g) == null) .filter(g -> createRefsMetaConfigPermission.getRule(g) == null)

View File

@@ -109,8 +109,7 @@ public class ChangeFieldTest extends GerritBaseTests {
private static void assertStoredRecordRoundTrip(SubmitRecord... records) { private static void assertStoredRecordRoundTrip(SubmitRecord... records) {
List<SubmitRecord> recordList = ImmutableList.copyOf(records); List<SubmitRecord> recordList = ImmutableList.copyOf(records);
List<String> stored = List<String> stored =
ChangeField.storedSubmitRecords(recordList) ChangeField.storedSubmitRecords(recordList).stream()
.stream()
.map(s -> new String(s, UTF_8)) .map(s -> new String(s, UTF_8))
.collect(toList()); .collect(toList());
assertThat(ChangeField.parseSubmitRecords(stored)) assertThat(ChangeField.parseSubmitRecords(stored))

View File

@@ -1772,10 +1772,7 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
gApi.groups().id(group).addMembers(user2.toString(), user3.toString()); gApi.groups().id(group).addMembers(user2.toString(), user3.toString());
List<String> members = List<String> members =
gApi.groups() gApi.groups().id(group).members().stream()
.id(group)
.members()
.stream()
.map(a -> a._accountId.toString()) .map(a -> a._accountId.toString())
.collect(toList()); .collect(toList());
assertThat(members).contains(user2.toString()); assertThat(members).contains(user2.toString());
@@ -2075,8 +2072,7 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
expectedStates.add("All-Users:refs/draft-comments/" + cs + "/" + u); expectedStates.add("All-Users:refs/draft-comments/" + cs + "/" + u);
} }
assertThat( assertThat(
cd.getRefStates() cd.getRefStates().stream()
.stream()
.map(String::new) .map(String::new)
// Omit SHA-1, we're just concerned with the project/ref names. // Omit SHA-1, we're just concerned with the project/ref names.
.map(s -> s.substring(0, s.lastIndexOf(':'))) .map(s -> s.substring(0, s.lastIndexOf(':')))

View File

@@ -134,8 +134,7 @@ public class FakeEmailSender implements EmailSender {
public List<Message> getMessages(String changeId, String type) { public List<Message> getMessages(String changeId, String type) {
final String idFooter = "\nGerrit-Change-Id: " + changeId + "\n"; final String idFooter = "\nGerrit-Change-Id: " + changeId + "\n";
final String typeFooter = "\nGerrit-MessageType: " + type + "\n"; final String typeFooter = "\nGerrit-MessageType: " + type + "\n";
return getMessages() return getMessages().stream()
.stream()
.filter(in -> in.body().contains(idFooter) && in.body().contains(typeFooter)) .filter(in -> in.body().contains(idFooter) && in.body().contains(typeFooter))
.collect(toList()); .collect(toList());
} }

View File

@@ -102,9 +102,7 @@ public class ChangeArgumentParser {
private List<ChangeControl> changeFromNotesFactory(String id, CurrentUser currentUser) private List<ChangeControl> changeFromNotesFactory(String id, CurrentUser currentUser)
throws OrmException, UnloggedFailure { throws OrmException, UnloggedFailure {
return changeNotesFactory return changeNotesFactory.create(db, parseId(id)).stream()
.create(db, parseId(id))
.stream()
.map(changeNote -> controlForChange(changeNote, currentUser)) .map(changeNote -> controlForChange(changeNote, currentUser))
.filter(changeControl -> changeControl.isPresent()) .filter(changeControl -> changeControl.isPresent())
.map(changeControl -> changeControl.get()) .map(changeControl -> changeControl.get())

View File

@@ -128,8 +128,7 @@ public class SetMembersCommand extends SshCommand {
String action, GroupResource group, List<Account.Id> accountIdList) String action, GroupResource group, List<Account.Id> accountIdList)
throws UnsupportedEncodingException, IOException { throws UnsupportedEncodingException, IOException {
String names = String names =
accountIdList accountIdList.stream()
.stream()
.map( .map(
accountId -> accountId ->
MoreObjects.firstNonNull( MoreObjects.firstNonNull(

View File

@@ -17,7 +17,7 @@
set -eu set -eu
# Keep this version in sync with dev-contributing.txt. # Keep this version in sync with dev-contributing.txt.
VERSION=${1:-1.6} VERSION=${1:-1.7}
case "$VERSION" in case "$VERSION" in
1.3) 1.3)