@@ -110,14 +110,25 @@ public Context() {
110110 /**
111111 * Creates a new SciJava application context.
112112 *
113- * @param empty If true, the context will be empty; otherwise, it will be
114- * initialized with all available services.
115- * @see #Context(Collection, PluginIndex , boolean)
113+ * @param empty If true, the context will be empty of services ; otherwise, it
114+ * will be initialized with all available services.
115+ * @see #Context(boolean , boolean)
116116 */
117- @ SuppressWarnings ("unchecked" )
118117 public Context (final boolean empty ) {
119- this (empty ? Collections .<Class <? extends Service >> emptyList () : Arrays
120- .<Class <? extends Service >> asList (Service .class ));
118+ this (empty , false );
119+ }
120+
121+ /**
122+ * Creates a new SciJava application context.
123+ *
124+ * @param noServices If true, the context will contain no services; otherwise,
125+ * it will be initialized with all available services.
126+ * @param noPlugins If true, the context will contain no plugins; otherwise,
127+ * it will be initialized with all available plugins.
128+ * @see #Context(Collection, PluginIndex, boolean)
129+ */
130+ public Context (final boolean noServices , final boolean noPlugins ) {
131+ this (services (noServices ), plugins (noPlugins ));
121132 }
122133
123134 /**
@@ -195,9 +206,8 @@ public Context(final Collection<Class<? extends Service>> serviceClasses,
195206 * result in a default plugin index being constructed and used.
196207 * @see #Context(Collection, PluginIndex, boolean)
197208 */
198- @ SuppressWarnings ("unchecked" )
199209 public Context (final PluginIndex pluginIndex ) {
200- this (Arrays .< Class <? extends Service >> asList ( Service . class ), pluginIndex );
210+ this (services ( false ), pluginIndex );
201211 }
202212
203213 /**
@@ -510,6 +520,16 @@ private String createMissingServiceMessage(
510520 return msg .toString ();
511521 }
512522
523+ private static PluginIndex plugins (final boolean empty ) {
524+ return empty ? new PluginIndex (null ) : null ;
525+ }
526+
527+ @ SuppressWarnings ("unchecked" )
528+ private static List <Class <? extends Service >> services (final boolean empty ) {
529+ if (empty ) return Collections .<Class <? extends Service >> emptyList ();
530+ return Arrays .<Class <? extends Service >> asList (Service .class );
531+ }
532+
513533 private static boolean strict () {
514534 return !"false" .equals (System .getProperty (STRICT_PROPERTY ));
515535 }
0 commit comments