jeantil commented on a change in pull request #461:
URL: https://github.com/apache/james-project/pull/461#discussion_r641567950



##########
File path: 
server/container/guice/guice-utils/src/main/java/org/apache/james/utils/ExtensionConfiguration.java
##########
@@ -19,24 +19,25 @@
 
 package org.apache.james.utils;
 
-import java.util.Arrays;
 import java.util.List;
-import java.util.Optional;
 
 import org.apache.commons.configuration2.Configuration;
 
 import com.github.steveash.guavate.Guavate;
+import com.google.common.base.Splitter;
 import com.google.common.collect.ImmutableList;
 
 public class ExtensionConfiguration {
     public static final ExtensionConfiguration DEFAULT = new 
ExtensionConfiguration(ImmutableList.of());
 
     public static ExtensionConfiguration from(Configuration configuration) {
-        List<String> list = 
Optional.ofNullable(configuration.getStringArray("guice.extension.module"))
-            .map(Arrays::asList)
-            .orElse(ImmutableList.of());
+        String rawString = configuration.getString("guice.extension.module", 
"");
 
-        return new ExtensionConfiguration(list.stream()
+        return new ExtensionConfiguration(Splitter.on(",")
+            .omitEmptyStrings()
+            .trimResults()

Review comment:
       I feel that the splitter setup gets in the way of the actual parsing 
logic. 
   The first 3 lines are type Splitter, then the flow changes to stream 
processing with the actual input value only appearing on line 4 
   
   extracting to a constant would change the code to 
   ```
   SPLITTER.splitToList(rawString)
               .stream()
               .map(ClassName::new)
               .collect(Guavate.toImmutableList())
   ```
   An alternative could be extracting to a private method that event takes care 
of the list<->stream ceremony  
   
   ``` 
   splitOnCommas(rawString)
    .map(ClassName::new)
               .collect(Guavate.toImmutableList())
   ```




-- 
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.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to