Source:
<code>public static List<ProcessVariableSummary> adaptCollection(List<VariableInstance> variables, Map<String, String> properties, long processInstanceId, String deploymentId, String serverTemplateId, String sortBy, boolean asc) { List<VariableInstance> filteredVariables = variables.stream() .filter(variable -> !excludedVariables.contains(variable.getVariableName())) .collect(Collectors.toList()); List<ProcessVariableSummary> variablesSummary = new ArrayList<>(); properties.forEach((key, value) -> { VariableProcessor processor = processors.getOrDefault(value, new DefaultVariableProcessor()); processor.process(processInstanceId, key, value, filteredVariables, deploymentId, serverTemplateId, variableSummary -> variablesSummary.add(variableSummary)); }); variablesSummary.addAll(ofNullable(filteredVariables).orElse(emptyList()) .stream() .map(new ProcessInstanceVariableMapper(deploymentId, serverTemplateId, "")) .collect(Collectors.toList())); Comparator<ProcessVariableSummary> comparator; switch (ofNullable(sortBy).orElse(COL_PROCESS_INSTANCE_VAR_ID)) { case COL_PROCESS_INSTANCE_VAR_ID: comparator = comparing(ProcessVariableSummary::getVariableId); break; case COL_PROCESS_INSTANCE_VAR_VALUE: comparator = comparing(ProcessVariableSummary::getNewValue); break; case COL_PROCESS_INSTANCE_VAR_TYPE: comparator = comparing(ProcessVariableSummary::getType); break; case COL_PROCESS_INSTANCE_VAR_LASTMOD: comparator = comparing(ProcessVariableSummary::getTimestamp); break; default: comparator = comparing(ProcessVariableSummary::getName); } <START> variablesSummary.sort(!asc ? comparator : comparator.reversed()); <END> return variablesSummary; }</code><technical_language>logic reversed here? assume default order for Comparator<T> is ascending (relying compareTo() implementation of types passed comparing()) .... asc is true, expect sorting comparator, false reversed counterpart</technical_language>

Target:
public static List<ProcessVariableSummary> adaptCollection(List<VariableInstance> variables, Map<String, String> properties, long processInstanceId, String deploymentId, String serverTemplateId, String sortBy, boolean asc) { List<VariableInstance> filteredVariables = variables.stream() .filter(variable -> !excludedVariables.contains(variable.getVariableName())) .collect(Collectors.toList()); List<ProcessVariableSummary> variablesSummary = new ArrayList<>(); properties.forEach((key, value) -> { VariableProcessor processor = processors.getOrDefault(value, new DefaultVariableProcessor()); processor.process(processInstanceId, key, value, filteredVariables, deploymentId, serverTemplateId, variableSummary -> variablesSummary.add(variableSummary)); }); variablesSummary.addAll(ofNullable(filteredVariables).orElse(emptyList()) .stream() .map(new ProcessInstanceVariableMapper(deploymentId, serverTemplateId, "")) .collect(Collectors.toList())); Comparator<ProcessVariableSummary> comparator; switch (ofNullable(sortBy).orElse(COL_PROCESS_INSTANCE_VAR_ID)) { case COL_PROCESS_INSTANCE_VAR_ID: comparator = comparing(ProcessVariableSummary::getVariableId); break; case COL_PROCESS_INSTANCE_VAR_VALUE: comparator = comparing(ProcessVariableSummary::getNewValue); break; case COL_PROCESS_INSTANCE_VAR_TYPE: comparator = comparing(ProcessVariableSummary::getType); break; case COL_PROCESS_INSTANCE_VAR_LASTMOD: comparator = comparing(ProcessVariableSummary::getTimestamp); break; default: comparator = comparing(ProcessVariableSummary::getName); } variablesSummary.sort(asc ? comparator : comparator.reversed()); return variablesSummary; }