OSDN Git Service

feat: change loop from for to stream
authorhizumiaoba <56146205+hizumiaoba@users.noreply.github.com>
Thu, 16 Dec 2021 05:39:39 +0000 (14:39 +0900)
committerhizumiaoba <56146205+hizumiaoba@users.noreply.github.com>
Thu, 16 Dec 2021 05:39:39 +0000 (14:39 +0900)
src/com/ranfa/lib/Scraping.java

index f326d06..9eae6d3 100644 (file)
@@ -94,18 +94,18 @@ public class Scraping {
                                tmp.setNotes(notes);
                                if(difficulty.equals(LEGACYMASTERPLUS)) {
                                        ArrayList<Album> newTypeList = typeLists.get(MASTERPLUS_TYPE.LEGACYMASTERPLUS.ordinal());
-                                       for (Album element : newTypeList) {
-                                               if(element.getSongName().equals(name)) {
-                                                       tmp.setAlbumType(element.getAlbumType());
-                                               }
-                                       }
+                                       newTypeList.stream()
+                                       .filter(element -> element.getSongName().equals(name))
+                                       .forEach(element -> {
+                                               tmp.setAlbumType(element.getAlbumType());
+                                       });
                                } else if(difficulty.equals(MASTERPLUS)) {
                                        ArrayList<Album> legacyTypeList = typeLists.get(MASTERPLUS_TYPE.NEWMASTERPLUS.ordinal());
-                                       for (Album element : legacyTypeList) {
-                                               if(element.getSongName().equals(name)) {
-                                                       tmp.setAlbumType(element.getAlbumType());
-                                               }
-                                       }
+                                       legacyTypeList.stream()
+                                       .filter(element -> element.getSongName().equals(name))
+                                       .forEach(element -> {
+                                               tmp.setAlbumType(element.getAlbumType());
+                                       });
                                } else {
                                        tmp.setAlbumType("Not-Implemented");
                                }