Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid mix of stream and non-stream; simplify comparison #676

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -25,6 +25,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
Expand All @@ -33,6 +34,7 @@
import java.util.Set;
import java.util.TreeSet;
import java.util.function.Predicate;
import java.util.stream.Collectors;

import javax.annotation.Generated;
import javax.xml.XMLConstants;
Expand Down Expand Up @@ -537,14 +539,10 @@ public boolean test(BaseOptionModel optionModel) {
HashMap<String, Object> templateParams = new HashMap<>();
templateParams.put("connectorName", StringUtils.capitalize(sanitizedName));
templateParams.put("connectorClass", packageName + "." + javaClassConnectorName);
ArrayList<CamelKafkaConnectorOptionModel> mandatoryOptions = new ArrayList<>();
listOptions.stream().filter(o -> o.getPriority().toUpperCase().equals("HIGH")).forEach(o -> mandatoryOptions.add(o));
mandatoryOptions.sort((option1, option2) -> {
String name1 = option1.getName();
String name2 = option2.getName();
int res = String.CASE_INSENSITIVE_ORDER.compare(name1, name2);
return (res != 0) ? res : name1.compareTo(name2);
});
List<CamelKafkaConnectorOptionModel> mandatoryOptions = listOptions.stream()
.filter(o -> "HIGH".equalsIgnoreCase(o.getPriority()))
.sorted(Comparator.comparing(CamelKafkaConnectorOptionModel::getName, String.CASE_INSENSITIVE_ORDER))
.collect(Collectors.toList());
templateParams.put("options", mandatoryOptions);
String examplePropertiesFileContent = (String)TemplateRuntime.eval(examplesPropertiestemplate, templateParams);
writeFileIfChanged(examplePropertiesFileContent, new File(connectorDir, "src/main/docs/examples/" + javaClassConnectorName + ".properties"), getLog());
Expand Down