diff --git a/core/src/main/java/org/synyx/hera/core/SimplePluginRegistry.java b/core/src/main/java/org/synyx/hera/core/SimplePluginRegistry.java index 915ab65..9ce2741 100644 --- a/core/src/main/java/org/synyx/hera/core/SimplePluginRegistry.java +++ b/core/src/main/java/org/synyx/hera/core/SimplePluginRegistry.java @@ -17,6 +17,7 @@ package org.synyx.hera.core; import java.util.ArrayList; +import java.util.Collections; import java.util.Iterator; import java.util.List; @@ -32,16 +33,19 @@ import java.util.List; public class SimplePluginRegistry, S> implements MutablePluginRegistry { + private final List EMPTY_LIST = Collections.emptyList(); + // Registered plugins private List plugins; /** - * Creates a new {@code PluginRegistry}. + * Creates a new {@code SimplePluginRegistry}. Will create an empty registry + * if {@literal null} is provided. */ - public SimplePluginRegistry() { + protected SimplePluginRegistry(List plugins) { - plugins = new ArrayList(); + this.plugins = null == plugins ? EMPTY_LIST : new ArrayList(plugins); } @@ -54,12 +58,13 @@ public class SimplePluginRegistry, S> implements */ public static > SimplePluginRegistry create() { - return new SimplePluginRegistry(); + return new SimplePluginRegistry(null); } /** - * Creates a new {@link SimplePluginRegistry}. + * Creates a new {@link SimplePluginRegistry} with the given {@link Plugin} + * s. * * @param * @param @@ -68,10 +73,7 @@ public class SimplePluginRegistry, S> implements public static > SimplePluginRegistry create( List plugins) { - SimplePluginRegistry registry = create(); - registry.setPlugins(plugins); - - return registry; + return new SimplePluginRegistry(plugins); }