|
1 | 1 | /*
|
2 |
| - * Copyright 2016-2020 the original author or authors. |
| 2 | + * Copyright 2016-2022 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
21 | 21 | import java.util.List;
|
22 | 22 | import java.util.Map;
|
23 | 23 | import java.util.function.Function;
|
| 24 | +import java.util.stream.Collectors; |
24 | 25 |
|
25 | 26 | import org.springframework.cloud.dataflow.core.TaskDefinition;
|
26 | 27 | import org.springframework.cloud.dataflow.core.dsl.TaskNode;
|
|
62 | 63 | * @author Gunnar Hillert
|
63 | 64 | * @author Daniel Serleg
|
64 | 65 | * @author Ilayaperumal Gopinathan
|
| 66 | + * @author Chris Bono |
65 | 67 | */
|
66 | 68 | @RestController
|
67 | 69 | @RequestMapping("/tasks/definitions")
|
@@ -176,20 +178,12 @@ public PagedModel<? extends TaskDefinitionResource> list(Pageable pageable, @Req
|
176 | 178 | }
|
177 | 179 | }
|
178 | 180 |
|
179 |
| - final java.util.HashMap<String, TaskDefinition> taskDefinitionMap = new java.util.HashMap<>(); |
180 |
| - |
181 |
| - for (TaskDefinition taskDefinition : taskDefinitions) { |
182 |
| - taskDefinitionMap.put(taskDefinition.getName(), taskDefinition); |
183 |
| - } |
184 |
| - |
185 |
| - final List<TaskExecution> taskExecutions; |
| 181 | + final Map<String, TaskDefinition> taskDefinitionMap = taskDefinitions.stream() |
| 182 | + .collect(Collectors.toMap(TaskDefinition::getTaskName, Function.identity())); |
186 | 183 |
|
| 184 | + List<TaskExecution> taskExecutions = null; |
187 | 185 | if (!taskDefinitionMap.isEmpty()) {
|
188 |
| - taskExecutions = this.explorer.getLatestTaskExecutionsByTaskNames( |
189 |
| - taskDefinitionMap.keySet().toArray(new String[taskDefinitionMap.size()])); |
190 |
| - } |
191 |
| - else { |
192 |
| - taskExecutions = null; |
| 186 | + taskExecutions = this.explorer.getLatestTaskExecutionsByTaskNames(taskDefinitionMap.keySet().toArray(new String[0])); |
193 | 187 | }
|
194 | 188 |
|
195 | 189 | final Page<TaskExecutionAwareTaskDefinition> taskExecutionAwareTaskDefinitions = taskDefinitions
|
|
0 commit comments