Merge branch 'stable-2.15' into stable-2.16

* stable-2.15:
  Upgrade google-java-format to 1.7

Change-Id: Ia7383822ef59fb60bb5559956a065ae46b2e4f4a
This commit is contained in:
David Pursehouse
2019-03-14 09:01:59 +09:00
149 changed files with 225 additions and 604 deletions

View File

@@ -164,7 +164,7 @@ Guide].
To format Java source code, Gerrit uses the
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`]
tool (version 0.20.0).
These tools automatically apply format according to the style guides; this

View File

@@ -68,7 +68,7 @@ Java 8 is still the default:
To format source code, Gerrit uses the
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
instruction how to set up command line tool that uses this formatter.
The Eclipse plugin is provided that allows to format with the same

View File

@@ -140,8 +140,7 @@ class Labels extends Grid {
void set(ChangeInfo info) {
List<String> names =
info.labels()
.stream()
info.labels().stream()
.sorted()
.collect(collectingAndThen(toList(), Collections::unmodifiableList));
Set<Integer> removable = info.removableReviewerIds();

View File

@@ -126,9 +126,7 @@ public class ReplyBox extends Composite {
initWidget(uiBinder.createAndBindUi(this));
List<String> names =
permitted
.keySet()
.stream()
permitted.keySet().stream()
.sorted()
.collect(collectingAndThen(toList(), Collections::unmodifiableList));
if (names.isEmpty()) {
@@ -446,8 +444,7 @@ public class ReplyBox extends Composite {
}
List<String> paths =
m.keySet()
.stream()
m.keySet().stream()
.sorted()
.collect(collectingAndThen(toList(), Collections::unmodifiableList));

View File

@@ -116,9 +116,7 @@ public abstract class AbstractNotificationTest extends AbstractDaemonTest {
recipients.put(CC, parseAddresses(message, "Cc"));
recipients.put(
BCC,
message
.rcpt()
.stream()
message.rcpt().stream()
.map(Address::getEmail)
.filter(e -> !recipients.get(TO).contains(e) && !recipients.get(CC).contains(e))
.collect(toList()));

View File

@@ -65,8 +65,7 @@ public class HttpResponse {
}
public ImmutableList<String> getHeaders(String name) {
return Arrays.asList(response.getHeaders(name))
.stream()
return Arrays.asList(response.getHeaders(name)).stream()
.map(Header::getValue)
.collect(toImmutableList());
}

View File

@@ -260,9 +260,7 @@ public class ProjectResetter implements AutoCloseable {
refsPatternByProject.asMap().entrySet()) {
try (Repository repo = repoManager.openRepository(e.getKey())) {
Collection<Ref> nonRestoredRefs =
repo.getRefDatabase()
.getRefs()
.stream()
repo.getRefDatabase().getRefs().stream()
.filter(
r ->
!keptRefsByProject.containsEntry(e.getKey(), r.getName())
@@ -315,9 +313,7 @@ public class ProjectResetter implements AutoCloseable {
private Set<Project.NameKey> projectsWithConfigChanges(
Multimap<Project.NameKey, String> projects) {
return projects
.entries()
.stream()
return projects.entries().stream()
.filter(e -> e.getValue().equals(RefNames.REFS_CONFIG))
.map(Map.Entry::getKey)
.collect(toSet());

View File

@@ -42,9 +42,7 @@ public class ReindexProjectsAtStartup implements LifecycleListener {
@Override
public void start() {
repoMgr
.list()
.stream()
repoMgr.list().stream()
.forEach(
projectName -> {
try {

View File

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

View File

@@ -226,8 +226,7 @@ public class DynamicSet<T> implements Iterable<T> {
* @return sorted set of active plugins that supply at least one item.
*/
public ImmutableSortedSet<String> plugins() {
return items
.stream()
return items.stream()
.map(i -> i.get().getPluginName())
.collect(toImmutableSortedSet(naturalOrder()));
}
@@ -239,8 +238,7 @@ public class DynamicSet<T> implements Iterable<T> {
* @return items exported by a plugin.
*/
public ImmutableSet<Provider<T>> byPlugin(String pluginName) {
return items
.stream()
return items.stream()
.filter(i -> i.get().getPluginName().equals(pluginName))
.map(i -> i.get().getProvider())
.collect(toImmutableSet());

View File

@@ -61,9 +61,7 @@ public class ProjectField {
storedOnly("ref_state")
.buildRepeatable(
projectData ->
projectData
.tree()
.stream()
projectData.tree().stream()
.filter(p -> p.getProject().getConfigRefState() != null)
.map(p -> toRefState(p.getProject()))
.collect(toImmutableList()));

View File

@@ -373,8 +373,7 @@ public abstract class QueryProcessor<T> {
}
private static Optional<QueryParseException> findQueryParseException(Throwable t) {
return Throwables.getCausalChain(t)
.stream()
return Throwables.getCausalChain(t).stream()
.filter(c -> c instanceof QueryParseException)
.map(QueryParseException.class::cast)
.findFirst();

View File

@@ -626,9 +626,7 @@ public final class GerritLauncher {
* @return true if any thread has a stack frame in {@code org.eclipse.jdt}.
*/
public static boolean isRunningInEclipse() {
return Thread.getAllStackTraces()
.values()
.stream()
return Thread.getAllStackTraces().values().stream()
.flatMap(Arrays::stream)
.anyMatch(e -> e.getClassName().startsWith("org.eclipse.jdt."));
}

View File

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

View File

@@ -78,8 +78,7 @@ public class HtmlParser {
for (Element e : d.body().getAllElements()) {
String elementName = e.tagName();
boolean isInBlockQuote =
e.parents()
.stream()
e.parents().stream()
.anyMatch(
p ->
p.tagName().equals("blockquote")

View File

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

View File

@@ -53,8 +53,7 @@ public class InitLogging implements InitStep {
}
private static boolean isSet(List<String> javaOptions, String javaOptionName) {
return javaOptions
.stream()
return javaOptions.stream()
.anyMatch(
o ->
o.startsWith("-D" + javaOptionName + "=")

View File

@@ -221,8 +221,7 @@ public class CommentsUtil {
}
return c;
}
return draftByChangeAuthor(db, notes, user.getAccountId())
.stream()
return draftByChangeAuthor(db, notes, user.getAccountId()).stream()
.filter(c -> key.equals(c.key))
.findFirst();
}

View File

@@ -107,9 +107,7 @@ public class CreateGroupPermissionSyncer implements ChangeMergedListener {
config.getAccessSection(RefNames.REFS_GROUPS + "*", true);
if (createGroupsGlobal.isEmpty()) {
createGroupAccessSection.setPermissions(
createGroupAccessSection
.getPermissions()
.stream()
createGroupAccessSection.getPermissions().stream()
.filter(p -> !Permission.CREATE.equals(p.getName()))
.collect(toList()));
config.replace(createGroupAccessSection);

View File

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

View File

@@ -298,9 +298,7 @@ public class StarredChangesUtil {
private static Set<String> getRefNames(Repository repo, String prefix) throws IOException {
RefDatabase refDb = repo.getRefDatabase();
return refDb
.getRefsByPrefix(prefix)
.stream()
return refDb.getRefsByPrefix(prefix).stream()
.map(r -> r.getName().substring(prefix.length()))
.collect(toSet());
}
@@ -425,8 +423,7 @@ public class StarredChangesUtil {
}
public static Set<Integer> getStarredPatchSets(Set<String> labels, String label) {
return labels
.stream()
return labels.stream()
.filter(l -> l.startsWith(label + "/"))
.filter(l -> Ints.tryParse(l.substring(label.length() + 1)) != null)
.map(l -> Integer.valueOf(l.substring(label.length() + 1)))

View File

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

View File

@@ -456,8 +456,7 @@ public class AccountManager {
}
if (filteredExtIdsByScheme.size() > 1
|| !filteredExtIdsByScheme
.stream()
|| !filteredExtIdsByScheme.stream()
.anyMatch(e -> e.key().equals(who.getExternalIdKey()))) {
u.deleteExternalIds(filteredExtIdsByScheme);
}
@@ -514,8 +513,7 @@ public class AccountManager {
(a, u) -> {
u.deleteExternalIds(extIds);
if (a.getAccount().getPreferredEmail() != null
&& extIds
.stream()
&& extIds.stream()
.anyMatch(e -> a.getAccount().getPreferredEmail().equals(e.email()))) {
u.setPreferredEmail(null);
}

View File

@@ -205,10 +205,7 @@ public class AccountResolver {
// and pray we come up with a reasonable result list.
// TODO(dborowitz): This doesn't match the documentation; consider whether it's possible to be
// more strict here.
return accountQueryProvider
.get()
.byDefault(nameOrEmail)
.stream()
return accountQueryProvider.get().byDefault(nameOrEmail).stream()
.map(a -> a.getAccount().getId())
.collect(toSet());
}

View File

@@ -140,9 +140,7 @@ public class Accounts {
}
public static Stream<Account.Id> readUserRefs(Repository repo) throws IOException {
return repo.getRefDatabase()
.getRefsByPrefix(RefNames.REFS_USERS)
.stream()
return repo.getRefDatabase().getRefsByPrefix(RefNames.REFS_USERS).stream()
.map(r -> Account.Id.fromRef(r.getName()))
.filter(Objects::nonNull);
}

View File

@@ -37,9 +37,7 @@ public class AccountsConsistencyChecker {
for (AccountState accountState : accounts.all()) {
Account account = accountState.getAccount();
if (account.getPreferredEmail() != null) {
if (!accountState
.getExternalIds()
.stream()
if (!accountState.getExternalIds().stream()
.anyMatch(e -> account.getPreferredEmail().equals(e.email()))) {
addError(
String.format(

View File

@@ -462,9 +462,7 @@ public class AccountsUpdate {
}
private static Set<Account.Id> getUpdatedAccounts(BatchRefUpdate batchRefUpdate) {
return batchRefUpdate
.getCommands()
.stream()
return batchRefUpdate.getCommands().stream()
.map(c -> Account.Id.fromRef(c.getRefName()))
.filter(Objects::nonNull)
.collect(toSet());

View File

@@ -85,10 +85,7 @@ public class Emails {
public ImmutableSetMultimap<String, Account.Id> getAccountsFor(String... emails)
throws IOException, OrmException {
ImmutableSetMultimap.Builder<String, Account.Id> builder = ImmutableSetMultimap.builder();
externalIds
.byEmails(emails)
.entries()
.stream()
externalIds.byEmails(emails).entries().stream()
.forEach(e -> builder.put(e.getKey(), e.getValue().accountId()));
executeIndexQuery(() -> queryProvider.get().byPreferredEmail(emails).entries().stream())
.forEach(e -> builder.put(e.getKey(), e.getValue().getAccount().getId()));

View File

@@ -154,10 +154,7 @@ public class GroupIncludeCacheImpl implements GroupIncludeCache {
@Override
public ImmutableSet<AccountGroup.UUID> load(Account.Id memberId) throws OrmException {
try (TraceTimer timer = TraceContext.newTimer("Loading groups with member %s", memberId)) {
return groupQueryProvider
.get()
.byMember(memberId)
.stream()
return groupQueryProvider.get().byMember(memberId).stream()
.map(InternalGroup::getGroupUUID)
.collect(toImmutableSet());
}
@@ -176,10 +173,7 @@ public class GroupIncludeCacheImpl implements GroupIncludeCache {
@Override
public ImmutableList<AccountGroup.UUID> load(AccountGroup.UUID key) throws OrmException {
try (TraceTimer timer = TraceContext.newTimer("Loading parent groups of %s", key)) {
return groupQueryProvider
.get()
.bySubgroup(key)
.stream()
return groupQueryProvider.get().bySubgroup(key).stream()
.map(InternalGroup::getGroupUUID)
.collect(toImmutableList());
}

View File

@@ -127,9 +127,7 @@ public class GroupMembers {
GroupControl groupControl = groupControlFactory.controlFor(new InternalGroupDescription(group));
Set<Account> directMembers =
group
.getMembers()
.stream()
group.getMembers().stream()
.filter(groupControl::canSeeMember)
.map(accountCache::get)
.flatMap(Streams::stream)

View File

@@ -202,9 +202,7 @@ public class ProjectWatches {
private static ImmutableMap<ProjectWatchKey, ImmutableSet<NotifyType>> immutableCopyOf(
Map<ProjectWatchKey, Set<NotifyType>> projectWatches) {
ImmutableMap.Builder<ProjectWatchKey, ImmutableSet<NotifyType>> b = ImmutableMap.builder();
projectWatches
.entrySet()
.stream()
projectWatches.entrySet().stream()
.forEach(e -> b.put(e.getKey(), ImmutableSet.copyOf(e.getValue())));
return b.build();
}

View File

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

View File

@@ -45,8 +45,7 @@ public abstract class AllExternalIds {
private static ImmutableSetMultimap<String, ExternalId> byEmailCopy(
Collection<ExternalId> externalIds) {
return externalIds
.stream()
return externalIds.stream()
.filter(e -> !Strings.isNullOrEmpty(e.email()))
.collect(toImmutableSetMultimap(e -> e.email(), e -> e));
}
@@ -62,10 +61,7 @@ public abstract class AllExternalIds {
public byte[] serialize(AllExternalIds object) {
ObjectIdConverter idConverter = ObjectIdConverter.create();
AllExternalIdsProto.Builder allBuilder = AllExternalIdsProto.newBuilder();
object
.byAccount()
.values()
.stream()
object.byAccount().values().stream()
.map(extId -> toProto(idConverter, extId))
.forEach(allBuilder::addExternalId);
return ProtoCacheSerializers.toByteArray(allBuilder.build());
@@ -92,8 +88,7 @@ public abstract class AllExternalIds {
public AllExternalIds deserialize(byte[] in) {
ObjectIdConverter idConverter = ObjectIdConverter.create();
return create(
ProtoCacheSerializers.parseUnchecked(AllExternalIdsProto.parser(), in)
.getExternalIdList()
ProtoCacheSerializers.parseUnchecked(AllExternalIdsProto.parser(), in).getExternalIdList()
.stream()
.map(proto -> toExternalId(idConverter, proto))
.collect(toList()));

View File

@@ -82,8 +82,7 @@ public abstract class ExternalId implements Serializable {
* ExternalId#SCHEME_USERNAME} scheme
*/
public static Optional<String> getUserName(Collection<ExternalId> extIds) {
return extIds
.stream()
return extIds.stream()
.filter(e -> e.isScheme(SCHEME_USERNAME))
.map(e -> e.key().id())
.filter(u -> !Strings.isNullOrEmpty(u))

View File

@@ -762,8 +762,7 @@ public class ExternalIdNotes extends VersionedMetaData {
noteMapUpdates.clear();
if (!footers.isEmpty()) {
commit.setMessage(
footers
.stream()
footers.stream()
.sorted()
.collect(joining("\n", commit.getMessage().trim() + "\n\n", "")));
}

View File

@@ -71,8 +71,7 @@ public class ExternalIds {
/** Returns the external IDs of the specified account that have the given scheme. */
public Set<ExternalId> byAccount(Account.Id accountId, String scheme) throws IOException {
return byAccount(accountId)
.stream()
return byAccount(accountId).stream()
.filter(e -> e.key().isScheme(scheme))
.collect(toImmutableSet());
}
@@ -85,8 +84,7 @@ public class ExternalIds {
/** Returns the external IDs of the specified account that have the given scheme. */
public Set<ExternalId> byAccount(Account.Id accountId, String scheme, ObjectId rev)
throws IOException {
return byAccount(accountId, rev)
.stream()
return byAccount(accountId, rev).stream()
.filter(e -> e.key().isScheme(scheme))
.collect(toImmutableSet());
}

View File

@@ -93,10 +93,7 @@ public class ExternalIdsConsistencyChecker {
}
}
emails
.asMap()
.entrySet()
.stream()
emails.asMap().entrySet().stream()
.filter(e -> e.getValue().size() > 1)
.forEach(
e ->
@@ -104,8 +101,7 @@ public class ExternalIdsConsistencyChecker {
String.format(
"Email '%s' is not unique, it's used by the following external IDs: %s",
e.getKey(),
e.getValue()
.stream()
e.getValue().stream()
.map(k -> "'" + k.get() + "'")
.sorted()
.collect(joining(", "))),

View File

@@ -345,8 +345,7 @@ public class H2CacheImpl<K, V> extends AbstractLoadingCache<K, V> implements Per
}
}
} catch (Exception e) {
if (Throwables.getCausalChain(e)
.stream()
if (Throwables.getCausalChain(e).stream()
.anyMatch(InvalidClassException.class::isInstance)) {
// If deserialization failed using default Java serialization, this means we are using
// the old serialVersionUID-based invalidation strategy. In that case, authors are

View File

@@ -81,8 +81,7 @@ public class SerializedClassSubject extends Subject<SerializedClassSubject, Clas
public void hasFields(Map<String, Type> expectedFields) {
isConcrete();
assertThat(
FieldUtils.getAllFieldsList(actual())
.stream()
FieldUtils.getAllFieldsList(actual()).stream()
.filter(f -> !Modifier.isStatic(f.getModifiers()))
.collect(toImmutableMap(Field::getName, Field::getGenericType)))
.containsExactlyEntriesIn(expectedFields);

View File

@@ -263,8 +263,7 @@ public class AddReviewersOp implements BatchUpdateOp {
!change.isWorkInProgress());
if (!addedReviewers.isEmpty()) {
List<AccountState> reviewers =
addedReviewers
.stream()
addedReviewers.stream()
.map(r -> accountCache.get(r.getAccountId()))
.flatMap(Streams::stream)
.collect(toList());

View File

@@ -480,9 +480,7 @@ public class ChangeInserter implements InsertChangeOp {
cm.setNotify(notify);
cm.setAccountsToNotify(accountsToNotify);
cm.addReviewers(
reviewerAdditions
.flattenResults(AddReviewersOp.Result::addedReviewers)
.stream()
reviewerAdditions.flattenResults(AddReviewersOp.Result::addedReviewers).stream()
.map(PatchSetApproval::getAccountId)
.collect(toImmutableSet()));
cm.addReviewersByEmail(

View File

@@ -613,8 +613,7 @@ public class ChangeJson {
if (has(TRACKING_IDS)) {
ListMultimap<String, String> set = trackingFooters.extract(cd.commitFooters());
out.trackingIds =
set.entries()
.stream()
set.entries().stream()
.map(e -> new TrackingIdInfo(e.getKey(), e.getValue()))
.collect(toList());
}
@@ -754,16 +753,14 @@ public class ChangeJson {
}
private Collection<AccountInfo> toAccountInfo(Collection<Account.Id> accounts) {
return accounts
.stream()
return accounts.stream()
.map(accountLoader::get)
.sorted(AccountInfoComparator.ORDER_NULLS_FIRST)
.collect(toList());
}
private Collection<AccountInfo> toAccountInfoByEmail(Collection<Address> addresses) {
return addresses
.stream()
return addresses.stream()
.map(a -> new AccountInfo(a.getName(), a.getEmail()))
.sorted(AccountInfoComparator.ORDER_NULLS_FIRST)
.collect(toList());

View File

@@ -154,9 +154,7 @@ public class ChangeResource implements RestResource, HasETag {
accounts.add(getChange().getAssignee());
}
try {
patchSetUtil
.byChange(db.get(), notes)
.stream()
patchSetUtil.byChange(db.get(), notes).stream()
.map(PatchSet::getUploader)
.forEach(accounts::add);

View File

@@ -173,8 +173,7 @@ public class IncludedInResolver {
*/
private static ImmutableSortedSet<String> getMatchingRefNames(
Set<String> matchingRefs, Collection<Ref> allRefs) {
return allRefs
.stream()
return allRefs.stream()
.map(Ref::getName)
.filter(matchingRefs::contains)
.map(Repository::shortenRefName)

View File

@@ -326,9 +326,7 @@ public class LabelsJson {
}
if (detailed) {
labels
.entrySet()
.stream()
labels.entrySet().stream()
.filter(e -> labelTypes.byLabel(e.getKey()) != null)
.forEach(e -> setLabelValues(labelTypes.byLabel(e.getKey()), e.getValue()));
}
@@ -524,9 +522,7 @@ public class LabelsJson {
Maps.newHashMapWithExpectedSize(permittedLabels.size());
for (String label : permittedLabels.keySet()) {
List<Integer> permittedVotingRange =
permittedLabels
.get(label)
.stream()
permittedLabels.get(label).stream()
.map(this::parseRangeValue)
.filter(java.util.Objects::nonNull)
.sorted()

View File

@@ -608,8 +608,7 @@ public class ReviewerAdder {
}
public ImmutableList<ReviewerAddition> getFailures() {
return additions
.stream()
return additions.stream()
.filter(a -> a.isFailure() && !a.isIgnorableFailure())
.collect(toImmutableList());
}
@@ -639,8 +638,7 @@ public class ReviewerAdder {
a ->
checkArgument(
a.op != null && a.op.getResult() != null, "missing result on %s", a));
return additions()
.stream()
return additions().stream()
.map(a -> a.op.getResult())
.map(func)
.flatMap(Collection::stream)
@@ -648,8 +646,7 @@ public class ReviewerAdder {
}
private ImmutableList<ReviewerAddition> additions() {
return additions
.stream()
return additions.stream()
.filter(
a -> {
if (a.isFailure()) {

View File

@@ -97,8 +97,7 @@ public class ConfigUpdatedEvent {
private Multimap<UpdateResult, ConfigUpdateEntry> createUpdate(
Set<ConfigKey> entries, UpdateResult updateResult) {
Multimap<UpdateResult, ConfigUpdateEntry> updates = ArrayListMultimap.create();
entries
.stream()
entries.stream()
.filter(this::isValueUpdated)
.map(e -> new ConfigUpdateEntry(e, getString(e, oldConfig), getString(e, newConfig)))
.forEach(e -> updates.put(updateResult, e));

View File

@@ -61,8 +61,7 @@ public class RepositoryConfig {
}
public ImmutableList<Path> getAllBasePaths() {
return cfg.getSubsections(SECTION_NAME)
.stream()
return cfg.getSubsections(SECTION_NAME).stream()
.map(sub -> cfg.getString(SECTION_NAME, sub, BASE_PATH_NAME))
.filter(Objects::nonNull)
.map(Paths::get)
@@ -90,8 +89,7 @@ public class RepositoryConfig {
*/
@Nullable
private String findSubSection(String project) {
return cfg.getSubsections(SECTION_NAME)
.stream()
return cfg.getSubsections(SECTION_NAME).stream()
.filter(ss -> isMatch(ss, project))
.max(comparing(String::length))
.orElse(null);

View File

@@ -36,9 +36,7 @@ public class LockFailureException extends IOException {
public LockFailureException(String message, BatchRefUpdate batchRefUpdate) {
super(message);
refs =
batchRefUpdate
.getCommands()
.stream()
batchRefUpdate.getCommands().stream()
.filter(c -> c.getResult() == ReceiveCommand.Result.LOCK_FAILURE)
.map(ReceiveCommand::getRefName)
.collect(toImmutableList());

View File

@@ -291,9 +291,7 @@ public class MergeUtil {
((ResolveMerger) m).getMergeResults();
filesWithGitConflicts =
mergeResults
.entrySet()
.stream()
mergeResults.entrySet().stream()
.filter(e -> e.getValue().containsConflicts())
.map(Map.Entry::getKey)
.collect(toImmutableSet());

View File

@@ -700,9 +700,7 @@ class ReceiveCommits {
List<CreateRequest> created =
newChanges.stream().filter(r -> r.change != null).collect(toList());
List<ReplaceRequest> updated =
replaceByChange
.values()
.stream()
replaceByChange.values().stream()
.filter(r -> r.inputCommand.getResult() == OK)
.sorted(comparingInt(r -> r.notes.getChangeId().get()))
.collect(toList());
@@ -812,9 +810,7 @@ class ReceiveCommits {
throw INSERT_EXCEPTION.apply(e);
}
replaceByChange
.values()
.stream()
replaceByChange.values().stream()
.forEach(req -> resultChangeIds.add(Key.REPLACED, req.ontoChange));
newChanges.stream().forEach(req -> resultChangeIds.add(Key.CREATED, req.changeId));

View File

@@ -383,13 +383,9 @@ public class ReplaceOp implements BatchUpdateOp {
inputs =
Streams.concat(
inputs,
magicBranch
.getCombinedReviewers(fromFooters)
.stream()
magicBranch.getCombinedReviewers(fromFooters).stream()
.map(r -> newAddReviewerInput(r, ReviewerState.REVIEWER)),
magicBranch
.getCombinedCcs(fromFooters)
.stream()
magicBranch.getCombinedCcs(fromFooters).stream()
.map(r -> newAddReviewerInput(r, ReviewerState.CC)));
}
return inputs.collect(toImmutableList());
@@ -582,9 +578,7 @@ public class ReplaceOp implements BatchUpdateOp {
cm.addReviewers(
Streams.concat(
oldRecipients.getReviewers().stream(),
reviewerAdditions
.flattenResults(AddReviewersOp.Result::addedReviewers)
.stream()
reviewerAdditions.flattenResults(AddReviewersOp.Result::addedReviewers).stream()
.map(PatchSetApproval::getAccountId))
.collect(toImmutableSet()));
cm.addExtraCC(

View File

@@ -114,9 +114,7 @@ public class AccountValidator {
accountConfig.load(allUsersName, rw, commit);
if (messages != null) {
messages.addAll(
accountConfig
.getValidationErrors()
.stream()
accountConfig.getValidationErrors().stream()
.map(ValidationError::getMessage)
.collect(toSet()));
}

View File

@@ -699,8 +699,7 @@ public class CommitValidators {
List<ConsistencyProblemInfo> problems =
externalIdsConsistencyChecker.check(receiveEvent.commit);
List<CommitValidationMessage> msgs =
problems
.stream()
problems.stream()
.map(
p ->
new CommitValidationMessage(
@@ -766,8 +765,7 @@ public class CommitValidators {
if (!errorMessages.isEmpty()) {
throw new CommitValidationException(
"invalid account configuration",
errorMessages
.stream()
errorMessages.stream()
.map(m -> new CommitValidationMessage(m, Type.ERROR))
.collect(toList()));
}

View File

@@ -125,8 +125,7 @@ public class PeriodicGroupIndexer implements Runnable {
public synchronized void run() {
try (Repository allUsers = repoManager.openRepository(allUsersName)) {
ImmutableSet<AccountGroup.UUID> newGroupUuids =
GroupNameNotes.loadAllGroups(allUsers)
.stream()
GroupNameNotes.loadAllGroups(allUsers).stream()
.map(GroupReference::getUUID)
.collect(toImmutableSet());
GroupIndexer groupIndexer = groupIndexerProvider.get();

View File

@@ -107,13 +107,11 @@ class GroupConfigCommitMessage {
Function<T, String> toString = element -> toParsableString.apply(auditLogFormatter, element);
Stream<String> removedElements =
Sets.difference(oldElements, newElements)
.stream()
Sets.difference(oldElements, newElements).stream()
.map(toString)
.map((removalFooterKey.getName() + ": ")::concat);
Stream<String> addedElements =
Sets.difference(newElements, oldElements)
.stream()
Sets.difference(newElements, oldElements).stream()
.map(toString)
.map((additionFooterKey.getName() + ": ")::concat);
return Stream.concat(removedElements, addedElements);

View File

@@ -295,8 +295,7 @@ public class GroupNameNotes extends VersionedMetaData {
private static ImmutableBiMap<AccountGroup.UUID, String> toBiMap(
Collection<GroupReference> groupReferences) {
try {
return groupReferences
.stream()
return groupReferences.stream()
.collect(toImmutableBiMap(GroupReference::getUUID, GroupReference::getName));
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException(UNIQUE_REF_ERROR, e);

View File

@@ -124,9 +124,7 @@ public class Groups {
getGroupFromNoteDb(allUsersName, allUsersRepo, internalGroup.getUUID());
group.map(InternalGroup::getSubgroups).ifPresent(allSubgroups::addAll);
}
return allSubgroups
.build()
.stream()
return allSubgroups.build().stream()
.filter(groupUuid -> !AccountGroup.isInternalGroup(groupUuid));
}

View File

@@ -157,8 +157,7 @@ public class AccountField {
storedOnly("external_id_state")
.buildRepeatable(
a ->
a.getExternalIds()
.stream()
a.getExternalIds().stream()
.filter(e -> e.blobId() != null)
.map(ExternalId::toByteArray)
.collect(toSet()));

View File

@@ -135,9 +135,7 @@ public class AllChangesIndexer extends SiteIndexer<Change.Id, ChangeData, Change
// Estimate size based on IDs that show up in ref names. This is not perfect, since patch set
// refs may exist for changes whose metadata was never successfully stored. But that's ok, as
// the estimate is just used as a heuristic for sorting projects.
return repo.getRefDatabase()
.getRefsByPrefix(RefNames.REFS_CHANGES)
.stream()
return repo.getRefDatabase().getRefsByPrefix(RefNames.REFS_CHANGES).stream()
.map(r -> Change.Id.fromRef(r.getName()))
.filter(Objects::nonNull)
.distinct()

View File

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

View File

@@ -66,9 +66,7 @@ public class StalenessChecker {
SetMultimap<Project.NameKey, RefState> currentRefStates =
MultimapBuilder.hashKeys().hashSetValues().build();
projectData
.tree()
.stream()
projectData.tree().stream()
.filter(p -> p.getProject().getConfigRefState() != null)
.forEach(
p ->

View File

@@ -170,8 +170,7 @@ public abstract class CallerFinder {
public LazyArg<String> findCaller() {
return lazy(
() ->
targets()
.stream()
targets().stream()
.map(t -> findCallerOf(t, skip() + 1))
.filter(Optional::isPresent)
.findFirst()

View File

@@ -134,10 +134,7 @@ public class TraceContext implements AutoCloseable {
}
Optional<String> existingTraceId =
LoggingContext.getInstance()
.getTagsAsMap()
.get(RequestId.Type.TRACE_ID.name())
.stream()
LoggingContext.getInstance().getTagsAsMap().get(RequestId.Type.TRACE_ID.name()).stream()
.findAny();
if (existingTraceId.isPresent()) {
// request tracing was already started, no need to generate a new trace ID

View File

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

View File

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

View File

@@ -557,8 +557,7 @@ public class ChangeBundle {
}
if (!bs.isEmpty()) {
sb.append("Only in B:");
bs.values()
.stream()
bs.values().stream()
.sorted(CHANGE_MESSAGE_COMPARATOR)
.forEach(cm -> sb.append("\n ").append(cm));
}
@@ -675,9 +674,7 @@ public class ChangeBundle {
private static boolean createdOnIsMonotonic(
Map<?, PatchSet> patchSets, Set<PatchSet.Id> limitToIds) {
List<PatchSet> orderedById =
patchSets
.values()
.stream()
patchSets.values().stream()
.filter(ps -> limitToIds.contains(ps.getId()))
.sorted(ChangeUtil.PS_ID_ORDER)
.collect(toList());

View File

@@ -336,8 +336,7 @@ public class ChangeNotes extends AbstractChangeNotes<ChangeNotes> {
ScanResult sr = scanChangeIds(repo);
PrimaryStorage defaultStorage = args.migration.changePrimaryStorage();
return sr.all()
.stream()
return sr.all().stream()
.map(id -> scanOneNoteDbChange(db, project, sr, defaultStorage, id))
.filter(Objects::nonNull);
}

View File

@@ -565,23 +565,17 @@ public abstract class ChangeNotesState {
.changeId(changeId)
.columns(toChangeColumns(changeId, proto.getColumns()))
.pastAssignees(
proto
.getPastAssigneeList()
.stream()
proto.getPastAssigneeList().stream()
.map(Account.Id::new)
.collect(toImmutableSet()))
.hashtags(proto.getHashtagList())
.patchSets(
proto
.getPatchSetList()
.stream()
proto.getPatchSetList().stream()
.map(PATCH_SET_CODEC::decode)
.map(ps -> Maps.immutableEntry(ps.getId(), ps))
.collect(toImmutableList()))
.approvals(
proto
.getApprovalList()
.stream()
proto.getApprovalList().stream()
.map(APPROVAL_CODEC::decode)
.map(a -> Maps.immutableEntry(a.getPatchSetId(), a))
.collect(toImmutableList()))
@@ -590,28 +584,20 @@ public abstract class ChangeNotesState {
.pendingReviewers(toReviewerSet(proto.getPendingReviewerList()))
.pendingReviewersByEmail(toReviewerByEmailSet(proto.getPendingReviewerByEmailList()))
.allPastReviewers(
proto
.getPastReviewerList()
.stream()
proto.getPastReviewerList().stream()
.map(Account.Id::new)
.collect(toImmutableList()))
.reviewerUpdates(toReviewerStatusUpdateList(proto.getReviewerUpdateList()))
.submitRecords(
proto
.getSubmitRecordList()
.stream()
proto.getSubmitRecordList().stream()
.map(r -> GSON.fromJson(r, StoredSubmitRecord.class).toSubmitRecord())
.collect(toImmutableList()))
.changeMessages(
proto
.getChangeMessageList()
.stream()
proto.getChangeMessageList().stream()
.map(MESSAGE_CODEC::decode)
.collect(toImmutableList()))
.publishedComments(
proto
.getPublishedCommentList()
.stream()
proto.getPublishedCommentList().stream()
.map(r -> GSON.fromJson(r, Comment.class))
.collect(toImmutableListMultimap(c -> new RevId(c.revId), c -> c)));
if (proto.getHasReadOnlyUntil()) {

View File

@@ -141,9 +141,7 @@ public class DeleteCommentRewriter implements NoteDbRewriter {
throws IOException, ConfigInvalidException {
return RevisionNoteMap.parse(
changeNoteJson, legacyChangeNoteRead, changeId, reader, noteMap, PUBLISHED)
.revisionNotes
.values()
.stream()
.revisionNotes.values().stream()
.flatMap(n -> n.getComments().stream())
.collect(toMap(c -> c.key.uuid, Function.identity()));
}
@@ -189,9 +187,7 @@ public class DeleteCommentRewriter implements NoteDbRewriter {
*/
private List<Comment> getDeletedComments(
Map<String, Comment> parMap, Map<String, Comment> curMap) {
return parMap
.entrySet()
.stream()
return parMap.entrySet().stream()
.filter(c -> !curMap.containsKey(c.getKey()))
.map(Map.Entry::getValue)
.collect(toList());

View File

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

View File

@@ -447,8 +447,7 @@ public class NoteDbMigrator implements AutoCloseable {
int sequenceGap,
boolean autoMigrate)
throws MigrationException {
if (ImmutableList.of(!changes.isEmpty(), !projects.isEmpty(), !skipProjects.isEmpty())
.stream()
if (ImmutableList.of(!changes.isEmpty(), !projects.isEmpty(), !skipProjects.isEmpty()).stream()
.filter(e -> e)
.count()
> 1) {
@@ -628,8 +627,7 @@ public class NoteDbMigrator implements AutoCloseable {
try (ContextHelper contextHelper = new ContextHelper()) {
List<ListenableFuture<Boolean>> futures =
allChanges
.stream()
allChanges.stream()
.map(
id ->
executor.submit(

View File

@@ -89,8 +89,7 @@ class EditTransformer {
* @return the transformed edits per file path
*/
public Multimap<String, ContextAwareEdit> getEditsPerFilePath() {
return edits
.stream()
return edits.stream()
.collect(
toMultimap(
ContextAwareEdit::getNewFilePath, Function.identity(), ArrayListMultimap::create));
@@ -112,9 +111,7 @@ class EditTransformer {
transformingEntries.stream().collect(groupingBy(EditTransformer::getOldFilePath));
edits =
editsPerFilePath
.entrySet()
.stream()
editsPerFilePath.entrySet().stream()
.flatMap(
pathAndEdits -> {
List<PatchListEntry> transEntries =
@@ -137,12 +134,11 @@ class EditTransformer {
}
// TODO(aliceks): Find a way to prevent an explosion of the number of entries.
return transformingEntries
.stream()
return transformingEntries.stream()
.flatMap(
transEntry ->
transformEdits(
sideStrategy, originalEdits, transEntry.getEdits(), transEntry.getNewName())
sideStrategy, originalEdits, transEntry.getEdits(), transEntry.getNewName())
.stream());
}

View File

@@ -287,8 +287,7 @@ public class PatchListLoader implements Callable<PatchList> {
}
List<DiffEntry> relevantDiffEntries =
diffEntries
.stream()
diffEntries.stream()
.filter(diffEntry -> isTouched(touchedFilePaths, diffEntry))
.collect(toImmutableList());
@@ -397,8 +396,7 @@ public class PatchListLoader implements Callable<PatchList> {
}
private static Set<Edit> getContentEdits(Set<ContextAwareEdit> editsDueToRebase) {
return editsDueToRebase
.stream()
return editsDueToRebase.stream()
.map(ContextAwareEdit::toEdit)
.filter(Optional::isPresent)
.map(Optional::get)

View File

@@ -252,8 +252,7 @@ public class DefaultPermissionBackend extends PermissionBackend {
private boolean allow(Collection<PermissionRule> rules) {
return user.getEffectiveGroups()
.containsAnyOf(
rules
.stream()
rules.stream()
.filter(r -> r.getAction() == Action.ALLOW)
.map(r -> r.getGroup().getUUID())
.collect(toSet()));
@@ -261,8 +260,7 @@ public class DefaultPermissionBackend extends PermissionBackend {
private boolean notDenied(Collection<PermissionRule> rules) {
Set<AccountGroup.UUID> denied =
rules
.stream()
rules.stream()
.filter(r -> r.getAction() != Action.ALLOW)
.map(r -> r.getGroup().getUUID())
.collect(toSet());

View File

@@ -502,9 +502,7 @@ public abstract class PermissionBackend {
}
private static Set<LabelPermission.WithValue> valuesOf(LabelType label) {
return label
.getValues()
.stream()
return label.getValues().stream()
.map((v) -> new LabelPermission.WithValue(label, v))
.collect(toSet());
}

View File

@@ -151,8 +151,7 @@ public class PermissionCollection {
Lists.reverse(Lists.newArrayList(sectionToProject.entrySet()));
Map<Project.NameKey, List<AccessSection>> accessByProject =
accessDescending
.stream()
accessDescending.stream()
.collect(
Collectors.groupingBy(
Map.Entry::getValue,

View File

@@ -93,8 +93,7 @@ public class ChildProjects {
Project.NameKey parent)
throws PermissionBackendException {
List<Project.NameKey> canSee =
perm.filter(ProjectPermission.ACCESS, children.get(parent))
.stream()
perm.filter(ProjectPermission.ACCESS, children.get(parent)).stream()
.sorted()
.collect(toList());
children.removeAll(parent); // removing all entries prevents cycles.

View File

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

View File

@@ -1168,14 +1168,12 @@ public class ProjectConfig extends VersionedMetaData implements ValidationError.
private void saveNotifySections(Config rc, Set<AccountGroup.UUID> keepGroups) {
for (NotifyConfig nc : sort(notifySections.values())) {
nc.getGroups()
.stream()
nc.getGroups().stream()
.map(gr -> gr.getUUID())
.filter(Objects::nonNull)
.forEach(keepGroups::add);
List<String> email =
nc.getGroups()
.stream()
nc.getGroups().stream()
.map(gr -> new PermissionRule(gr).asString(false))
.sorted()
.collect(toList());

View File

@@ -219,8 +219,7 @@ public class ProjectState {
}
// If not, we check the parents.
return parents()
.stream()
return parents().stream()
.map(ProjectState::getConfig)
.map(ProjectConfig::getRulesId)
.anyMatch(Objects::nonNull);

View File

@@ -296,9 +296,7 @@ public class ProjectsConsistencyChecker {
// Auto-close by commit
for (ObjectId patchSetSha1 :
autoCloseableChange
.patchSets()
.stream()
autoCloseableChange.patchSets().stream()
.map(ps -> ObjectId.fromString(ps.getRevision().get()))
.collect(toSet())) {
if (mergedSha1s.contains(patchSetSha1)) {

View File

@@ -42,9 +42,7 @@ public class SuggestParentCandidates {
}
public List<Project.NameKey> getNameKeys() throws PermissionBackendException {
return permissionBackend
.currentUser()
.filter(ProjectPermission.ACCESS, readableParents())
return permissionBackend.currentUser().filter(ProjectPermission.ACCESS, readableParents())
.stream()
.sorted()
.collect(toList());

View File

@@ -108,8 +108,7 @@ public class InternalAccountQuery extends InternalQuery<AccountState> {
return ImmutableList.of();
}
return query(AccountPredicates.preferredEmail(email))
.stream()
return query(AccountPredicates.preferredEmail(email)).stream()
.filter(a -> a.getAccount().getPreferredEmail().equals(email))
.collect(toList());
}
@@ -145,8 +144,7 @@ public class InternalAccountQuery extends InternalQuery<AccountState> {
for (int i = 0; i < emailList.size(); i++) {
String email = emailList.get(i);
Set<AccountState> matchingAccounts =
r.get(i)
.stream()
r.get(i).stream()
.filter(a -> a.getAccount().getPreferredEmail().equals(email))
.collect(toSet());
accountsByEmail.putAll(email, matchingAccounts);

View File

@@ -1358,8 +1358,7 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
if (!forDefaultField || accounts.size() <= MAX_ACCOUNTS_PER_DEFAULT_FIELD) {
reviewerPredicate =
Predicate.or(
accounts
.stream()
accounts.stream()
.map(id -> ReviewerPredicate.forState(id, state))
.collect(toList()));
}

View File

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

View File

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

View File

@@ -85,9 +85,7 @@ public class DeleteEmail implements RestModifyView<AccountResource.Email, Input>
}
Set<ExternalId> extIds =
externalIds
.byAccount(user.getAccountId())
.stream()
externalIds.byAccount(user.getAccountId()).stream()
.filter(e -> email.equals(e.email()))
.collect(toSet());
if (extIds.isEmpty()) {

View File

@@ -77,9 +77,7 @@ public class DeleteExternalIds implements RestModifyView<AccountResource, List<S
}
Map<ExternalId.Key, ExternalId> externalIdMap =
externalIds
.byAccount(resource.getUser().getAccountId())
.stream()
externalIds.byAccount(resource.getUser().getAccountId()).stream()
.collect(toMap(ExternalId::key, Function.identity()));
List<ExternalId> toDelete = new ArrayList<>();

View File

@@ -76,8 +76,7 @@ public class DeleteWatchedProjects
accountId,
u ->
u.deleteProjectWatches(
input
.stream()
input.stream()
.filter(Objects::nonNull)
.map(w -> ProjectWatchKey.create(new Project.NameKey(w.project), w.filter))
.collect(toList())));

View File

@@ -48,9 +48,7 @@ public class GetEmails implements RestReadView<AccountResource> {
if (!self.get().hasSameAccountId(rsrc.getUser())) {
permissionBackend.currentUser().check(GlobalPermission.MODIFY_ACCOUNT);
}
return rsrc.getUser()
.getEmailAddresses()
.stream()
return rsrc.getUser().getEmailAddresses().stream()
.filter(Objects::nonNull)
.map(e -> toEmailInfo(rsrc, e))
.sorted(comparing((EmailInfo e) -> e.email))

View File

@@ -65,10 +65,7 @@ public class GetWatchedProjects implements RestReadView<AccountResource> {
Account.Id accountId = rsrc.getUser().getAccountId();
AccountState account = accounts.get(accountId).orElseThrow(ResourceNotFoundException::new);
return account
.getProjectWatches()
.entrySet()
.stream()
return account.getProjectWatches().entrySet().stream()
.map(e -> toProjectWatchInfo(e.getKey(), e.getValue()))
.sorted(
comparing((ProjectWatchInfo pwi) -> pwi.project)

View File

@@ -93,8 +93,7 @@ public class PutPreferred implements RestModifyView<AccountResource.Email, Input
// check if the user has a matching email
String matchingEmail = null;
for (String email :
a.getExternalIds()
.stream()
a.getExternalIds().stream()
.map(ExternalId::email)
.filter(Objects::nonNull)
.collect(toSet())) {
@@ -121,8 +120,7 @@ public class PutPreferred implements RestModifyView<AccountResource.Email, Input
+ " by the following account(s): %s",
preferredEmail,
user.getAccountId(),
existingExtIdsWithThisEmail
.stream()
existingExtIdsWithThisEmail.stream()
.map(ExternalId::accountId)
.collect(toList()));
exception.set(

View File

@@ -389,9 +389,7 @@ public class CherryPickChange {
if (!cherryPickCommit.getFilesWithGitConflicts().isEmpty()) {
stringBuilder.append("\n\nThe following files contain Git conflicts:\n");
cherryPickCommit
.getFilesWithGitConflicts()
.stream()
cherryPickCommit.getFilesWithGitConflicts().stream()
.sorted()
.forEach(filePath -> stringBuilder.append("* ").append(filePath).append("\n"));
}

View File

@@ -127,9 +127,7 @@ public class GetRelated implements RestReadView<RevisionResource> {
@VisibleForTesting
public static Set<String> getAllGroups(ChangeNotes notes, ReviewDb db, PatchSetUtil psUtil)
throws OrmException {
return psUtil
.byChange(db, notes)
.stream()
return psUtil.byChange(db, notes).stream()
.flatMap(ps -> ps.getGroups().stream())
.collect(toSet());
}

View File

@@ -53,8 +53,7 @@ public class ListChangeMessages implements RestReadView<ChangeResource> {
List<ChangeMessage> messages =
changeMessagesUtil.byChange(dbProvider.get(), resource.getNotes());
List<ChangeMessageInfo> messageInfos =
messages
.stream()
messages.stream()
.map(m -> createChangeMessageInfo(m, accountLoader))
.collect(Collectors.toList());
accountLoader.fill();

View File

@@ -806,8 +806,7 @@ public class PostReview
private static void ensureRangesDoNotOverlap(
String commentPath, List<FixReplacementInfo> fixReplacementInfos) throws BadRequestException {
List<Range> sortedRanges =
fixReplacementInfos
.stream()
fixReplacementInfos.stream()
.map(fixReplacementInfo -> fixReplacementInfo.range)
.sorted()
.collect(toList());
@@ -1078,17 +1077,13 @@ public class PostReview
}
private Set<CommentSetEntry> readExistingComments(ChangeContext ctx) throws OrmException {
return commentsUtil
.publishedByChange(ctx.getDb(), ctx.getNotes())
.stream()
return commentsUtil.publishedByChange(ctx.getDb(), ctx.getNotes()).stream()
.map(CommentSetEntry::create)
.collect(toSet());
}
private Set<CommentSetEntry> readExistingRobotComments(ChangeContext ctx) throws OrmException {
return commentsUtil
.robotCommentsByChange(ctx.getNotes())
.stream()
return commentsUtil.robotCommentsByChange(ctx.getNotes()).stream()
.map(CommentSetEntry::create)
.collect(toSet());
}
@@ -1313,8 +1308,7 @@ public class PostReview
if (!reduced.isEmpty()) {
throw new ResourceConflictException(
"Cannot reduce vote on labels for closed change: "
+ reduced
.stream()
+ reduced.stream()
.map(PatchSetApproval::getLabel)
.distinct()
.sorted()

View File

@@ -195,9 +195,7 @@ public class ReviewerRecommender {
// Sort results
Stream<Entry<Account.Id, MutableDouble>> sorted =
reviewerScores
.entrySet()
.stream()
reviewerScores.entrySet().stream()
.sorted(Collections.reverseOrder(Map.Entry.comparingByValue()));
List<Account.Id> sortedSuggestions = sorted.map(Map.Entry::getKey).collect(toList());
logger.atFine().log("Sorted suggestions: %s", sortedSuggestions);

View File

@@ -247,9 +247,7 @@ public class ReviewersUtil {
ImmutableSet.of(AccountField.ID.getName())))
.readRaw();
List<Account.Id> matches =
result
.toList()
.stream()
result.toList().stream()
.map(f -> new Account.Id(f.getValue(AccountField.ID).intValue()))
.collect(toList());
logger.atFine().log("Matches: %s", matches);
@@ -310,8 +308,7 @@ public class ReviewersUtil {
try (Timer0.Context ctx = metrics.loadAccountsLatency.start()) {
List<SuggestedReviewerInfo> reviewer =
accountIds
.stream()
accountIds.stream()
.map(accountLoader::get)
.filter(Objects::nonNull)
.map(
@@ -431,8 +428,7 @@ public class ReviewersUtil {
}
private static String formatSuggestedReviewers(List<SuggestedReviewerInfo> suggestedReviewers) {
return suggestedReviewers
.stream()
return suggestedReviewers.stream()
.map(
r -> {
if (r.account != null) {

View File

@@ -106,9 +106,7 @@ public class ListTasks implements RestReadView<ConfigResource> {
}
private List<TaskInfo> getTasks() {
return workQueue
.getTaskInfos(TaskInfo::new)
.stream()
return workQueue.getTaskInfos(TaskInfo::new).stream()
.sorted(
comparing((TaskInfo t) -> t.state.ordinal())
.thenComparing(t -> t.delay)

Some files were not shown because too many files have changed in this diff Show More