Stream API call chains simplified

This commit is contained in:
Tagir Valeev
2018-09-05 17:18:05 +07:00
parent 0b1855a164
commit e0fa136562
7 changed files with 9 additions and 12 deletions
@@ -25,7 +25,6 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import static com.intellij.psi.CommonClassNames.*;
import static com.intellij.psi.impl.source.resolve.reference.impl.JavaReflectionReferenceUtil.*;
@@ -95,7 +94,7 @@ public class JavaReflectionMemberAccessInspection extends AbstractBaseJavaLocalI
}
private void collectSettings() {
ignoredClassNamesString = ignoredClassNames.stream().collect(Collectors.joining(","));
ignoredClassNamesString = String.join(",", ignoredClassNames);
}
@NotNull
@@ -180,7 +180,7 @@ public class JsonSchemaTreeNode {
if (mySchema.getRef() != null) sb.append("$ref: ").append(mySchema.getRef()).append("\n");
else if (!mySchema.getProperties().isEmpty()) {
sb.append("properties: ");
sb.append(mySchema.getProperties().keySet().stream().collect(Collectors.joining(", "))).append("\n");
sb.append(String.join(", ", mySchema.getProperties().keySet())).append("\n");
}
if (!myChildren.isEmpty()) {
sb.append("OR children of NODE#").append(hashCode()).append(":\n----------------\n")
@@ -31,9 +31,8 @@ import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
import java.text.MessageFormat;
import java.util.*;
import java.util.List;
import java.util.stream.Collectors;
import java.util.*;
// Please do not make this class concrete<PsiElement>.
// This prevents languages with polyadic expressions or sequences
@@ -119,7 +118,7 @@ public abstract class OccurrencesChooser<T> {
callback.pass(occurrencesMap.keySet().iterator().next());
return;
}
List<C> model = occurrencesMap.keySet().stream().collect(Collectors.toList());
List<C> model = new ArrayList<>(occurrencesMap.keySet());
JBPopupFactory.getInstance()
.createPopupChooserBuilder(model)
@@ -35,7 +35,6 @@ import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author Alexander Lobas
@@ -110,7 +109,7 @@ public class SceneBuilderEditor extends UserDataHolderBase implements FileEditor
}
}
Collections.reverse(messages);
description = "\n" + messages.stream().collect(Collectors.joining("\n\n"));
description = "\n" + String.join("\n\n", messages);
}
else {
description = "Unknown error occurred";
@@ -124,7 +124,7 @@ public abstract class YamlMissingKeysInspectionBase extends YamlMetaTypeInspecti
@NotNull
private static String composeKeyList(@NotNull final Collection<String> missingKeys) {
return missingKeys.stream().collect(Collectors.joining(", "));
return String.join(", ", missingKeys);
}
@NotNull
@@ -70,12 +70,12 @@ public class YamlEnumType extends YamlScalarType {
super.validateScalarValue(scalarValue, holder);
String text = scalarValue.getTextValue();
if (text.length() == 0) {
if (text.isEmpty()) {
// not our business
return;
}
if (Arrays.stream(myDeprecatedLiterals).anyMatch(text::equals)) {
if (Arrays.asList(myDeprecatedLiterals).contains(text)) {
holder.registerProblem(scalarValue,
YAMLBundle.message("YamlEnumType.validation.warning.value.deprecated", text),
ProblemHighlightType.LIKE_DEPRECATED);
@@ -298,7 +298,7 @@ public abstract class PydevConsoleCommunication extends AbstractConsoleCommunica
@NotNull
private static PydevCompletionVariant toPydevCompletionVariant(@NotNull CompletionOption option) {
String args = option.arguments.stream().collect(Collectors.joining(" "));
String args = String.join(" ", option.arguments);
return new PydevCompletionVariant(option.name, option.documentation, args, option.type.getValue());
}