The methods taking an exception in PluginRegistry currently require the exception instance to be create even if the plugin lookup actually succeeds and the exception instance is never used at all.
We should rather provide a Supplier variant that allows the callers to delay the exception creation based on a lambda:
registry.getPluginFor(delimiter, () -> new IllegalStateException("No plugin found for delimiter ".concat(delimiter)));
The methods taking an exception in
PluginRegistry
currently require the exception instance to be create even if the plugin lookup actually succeeds and the exception instance is never used at all.We should rather provide a
Supplier
variant that allows the callers to delay the exception creation based on a lambda: