You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2022/09/20 11:57:25 UTC

[GitHub] [dolphinscheduler] kezhenxu94 commented on a diff in pull request #11775: [fix][API]fix task types sequence

kezhenxu94 commented on code in PR #11775:
URL: https://github.com/apache/dolphinscheduler/pull/11775#discussion_r975265989


##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/configuration/TaskTypeConfiguration.java:
##########
@@ -60,7 +66,24 @@ public Set<FavTaskDto> getDefaultTaskTypes() {
             other.forEach(task -> defaultTaskTypes.add(new FavTaskDto(task, false, Constants.TYPE_OTHER)));
 
         }
+        List<FavTaskDto> result = new ArrayList<>();

Review Comment:
   Here you are still doing things repeatedly unnecessarily. Why not just 
   
   ```java
   
       private final List<FavTaskDto> defaultTaskTypes = new ArrayList<>();
   
       public List<FavTaskDto> getDefaultTaskTypes() {
           if (!defaultTaskTypes.isEmpty()) {
               return defaultTaskTypes;
           }
           printDefaultTypes();
           universal.forEach(task -> defaultTaskTypes.add(new FavTaskDto(task, false, Constants.TYPE_UNIVERSAL)));
           cloud.forEach(task -> defaultTaskTypes.add(new FavTaskDto(task, false, Constants.TYPE_CLOUD)));
           logic.forEach(task -> defaultTaskTypes.add(new FavTaskDto(task, false, Constants.TYPE_LOGIC)));
           dataIntegration.forEach(task -> defaultTaskTypes.add(new FavTaskDto(task, false, Constants.TYPE_DATA_INTEGRATION)));
           dataQuality.forEach(task -> defaultTaskTypes.add(new FavTaskDto(task, false, Constants.TYPE_DATA_QUALITY)));
           machineLearning.forEach(task -> defaultTaskTypes.add(new FavTaskDto(task, false, Constants.TYPE_MACHINE_LEARNING)));
           other.forEach(task -> defaultTaskTypes.add(new FavTaskDto(task, false, Constants.TYPE_OTHER)));
           return defaultTaskTypes;
       }
   ```



##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/configuration/TaskTypeConfiguration.java:
##########
@@ -60,7 +66,24 @@ public Set<FavTaskDto> getDefaultTaskTypes() {
             other.forEach(task -> defaultTaskTypes.add(new FavTaskDto(task, false, Constants.TYPE_OTHER)));
 
         }
+        List<FavTaskDto> result = new ArrayList<>();
+        defaultTaskTypes.forEach(e -> {
+            try {
+                result.add((FavTaskDto) e.clone());

Review Comment:
   Why do you need to clone these?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org