52
52
import java .io .IOException ;
53
53
import java .io .InputStream ;
54
54
import java .util .ArrayList ;
55
- import java .util .Arrays ;
55
+ import java .util .Collections ;
56
56
import java .util .List ;
57
57
58
58
import static processing .app .I18n ._ ;
@@ -67,8 +67,8 @@ public class LibrariesIndexer {
67
67
private final File indexFile ;
68
68
private final File stagingFolder ;
69
69
private File sketchbookLibrariesFolder ;
70
-
71
- private final List <String > badLibNotified = new ArrayList <String >();
70
+
71
+ private final List <String > badLibNotified = new ArrayList <>();
72
72
73
73
public LibrariesIndexer (File preferencesFolder , ContributionsIndexer contributionsIndexer ) {
74
74
this .contributionsIndexer = contributionsIndexer ;
@@ -92,11 +92,10 @@ private void parseIndex(File indexFile) throws IOException {
92
92
mapper .configure (DeserializationFeature .FAIL_ON_UNKNOWN_PROPERTIES , false );
93
93
index = mapper .readValue (indexIn , LibrariesIndex .class );
94
94
95
- for (ContributedLibrary library : index .getLibraries ()) {
96
- if (library .getCategory () == null || "" .equals (library .getCategory ())) {
97
- library .setCategory ("Uncategorized" );
98
- }
99
- }
95
+ index .getLibraries ()
96
+ .stream ()
97
+ .filter (library -> library .getCategory () == null || "" .equals (library .getCategory ()))
98
+ .forEach (library -> library .setCategory ("Uncategorized" ));
100
99
} finally {
101
100
IOUtils .closeQuietly (indexIn );
102
101
}
@@ -124,7 +123,7 @@ public void rescanLibraries() {
124
123
@ Override
125
124
public Object apply (UserLibrary userLibrary ) {
126
125
ContributedPlatform platform = contributionsIndexer .getPlatformByFolder (userLibrary .getInstalledFolder ());
127
- userLibrary .setTypes (Arrays . asList (platform .getCategory ()));
126
+ userLibrary .setTypes (Collections . singletonList (platform .getCategory ()));
128
127
return userLibrary ;
129
128
}
130
129
}).toList ();
@@ -140,14 +139,14 @@ private void scanInstalledLibraries(File folder, boolean isSketchbook) {
140
139
if (!BaseNoGui .isSanitaryName (subfolder .getName ())) {
141
140
142
141
// Detect whether the current folder name has already had a notification.
143
- if (!badLibNotified .contains (subfolder .getName ())) {
142
+ if (!badLibNotified .contains (subfolder .getName ())) {
144
143
145
144
badLibNotified .add (subfolder .getName ());
146
145
147
146
String mess = I18n .format (_ ("The library \" {0}\" cannot be used.\n "
148
- + "Library names must contain only basic letters and numbers.\n "
149
- + "(ASCII only and no spaces, and it cannot start with a number)" ),
150
- subfolder .getName ());
147
+ + "Library names must contain only basic letters and numbers.\n "
148
+ + "(ASCII only and no spaces, and it cannot start with a number)" ),
149
+ subfolder .getName ());
151
150
BaseNoGui .showMessage (_ ("Ignoring bad library name" ), mess );
152
151
}
153
152
continue ;
@@ -213,7 +212,7 @@ private void scanLibrary(File folder, boolean isSketchbook) throws IOException {
213
212
}
214
213
215
214
if (lib .getTypes () == null ) {
216
- lib .setTypes (Arrays . asList ("Contributed" ));
215
+ lib .setTypes (Collections . singletonList ("Contributed" ));
217
216
}
218
217
}
219
218
0 commit comments