ReadInjectionProviderClassNames.java

  1. package org.jbehave.core.steps.needle.configuration;

  2. import java.util.LinkedHashSet;
  3. import java.util.ResourceBundle;
  4. import java.util.Set;

  5. /**
  6.  * Read ClassNames from properties.
  7.  *
  8.  * @author Jan Galinski, Holisticon AG (jan.galinski@holisticon.de)
  9.  * @author Simon Zambrovski, Holisticon AG (simon.zambrovski@holisticon.de)
  10.  */
  11. public enum ReadInjectionProviderClassNames {
  12.     /**
  13.      * Singleton Instance
  14.      */
  15.     INSTANCE;

  16.     private static final String CUSTOM_INJECTION_PROVIDER_CLASSES = "custom.injection.provider.classes";

  17.     public final Set<String> apply(final ResourceBundle resourceBundle) {
  18.         final LinkedHashSet<String> result = new LinkedHashSet<>();

  19.         if (resourceBundle != null && resourceBundle.containsKey(CUSTOM_INJECTION_PROVIDER_CLASSES)) {
  20.             final String csvProperty = resourceBundle.getString(CUSTOM_INJECTION_PROVIDER_CLASSES);
  21.             for (final String className : csvProperty.split(",")) {
  22.                 if (className != null) {
  23.                     final String trim = className.trim();
  24.                     if (!"".equals(trim)) {
  25.                         result.add(trim);
  26.                     }
  27.                 }
  28.             }
  29.         }

  30.         return result;
  31.     }

  32. }