Source:
<code>public RuleModellerWidget getWidget( RuleModeller ruleModeller, EventBus eventBus, IAction action, Boolean readOnly ) { if ( action instanceof ActionCallMethod ) { return new ActionCallMethodWidget( ruleModeller, eventBus, (ActionCallMethod) action, readOnly ); } if ( action instanceof ActionSetField ) { return new ActionSetFieldWidget( ruleModeller, eventBus, (ActionSetField) action, readOnly ); } if ( action instanceof ActionInsertFact ) { return new ActionInsertFactWidget( ruleModeller, eventBus, (ActionInsertFact) action, readOnly ); } if ( action instanceof ActionRetractFact ) { return new ActionRetractFactWidget( ruleModeller, eventBus, (ActionRetractFact) action, readOnly ); } if ( action instanceof DSLSentence ) { RuleModellerWidget w = new DSLSentenceWidget( ruleModeller, eventBus, (DSLSentence) action, readOnly ); return w; } if ( action instanceof FreeFormLine ) { return new FreeFormLineWidget( ruleModeller, eventBus, (FreeFormLine) action, readOnly ); } if ( action instanceof ActionGlobalCollectionAdd ) { return new GlobalCollectionAddWidget( ruleModeller, eventBus, (ActionGlobalCollectionAdd) action, readOnly ); } <START> if ( actionPlugins != null ) { <END> List<RuleModellerActionPlugin> matchingActionPlugins = actionPlugins.stream().filter( p -> p.accept( action ) ).collect( Collectors.toList() ); if ( matchingActionPlugins.size() > 1 ) { throw new IllegalStateException( "Ambigious " + RuleModellerActionPlugin.class.getName() + " implementations for action " + action ); } if ( matchingActionPlugins.size() == 1 ) { RuleModellerActionPlugin actionPlugin = matchingActionPlugins.get( 0 ); RuleModellerWidget ruleModellerWidget = actionPlugin.createWidget( ruleModeller, eventBus, action, readOnly ); return ruleModellerWidget; } } throw new RuntimeException( "I don't know what type of action is: " + action ); }</code><technical_language>Optional ... repeat myself.. pointing out occurrences</technical_language>

Target:
public RuleModellerWidget getWidget(RuleModeller ruleModeller, EventBus eventBus, IAction action, Boolean readOnly) { if (action instanceof ActionCallMethod) { return new ActionCallMethodWidget(ruleModeller, eventBus, (ActionCallMethod) action, readOnly); } if (action instanceof ActionSetField) { return new ActionSetFieldWidget(ruleModeller, eventBus, (ActionSetField) action, readOnly); } if (action instanceof ActionInsertFact) { return new ActionInsertFactWidget(ruleModeller, eventBus, (ActionInsertFact) action, readOnly); } if (action instanceof ActionRetractFact) { return new ActionRetractFactWidget(ruleModeller, eventBus, (ActionRetractFact) action, readOnly); } if (action instanceof DSLSentence) { RuleModellerWidget w = new DSLSentenceWidget(ruleModeller, eventBus, (DSLSentence) action, readOnly); return w; } if (action instanceof FreeFormLine) { return new FreeFormLineWidget(ruleModeller, eventBus, (FreeFormLine) action, readOnly); } if (action instanceof ActionGlobalCollectionAdd) { return new GlobalCollectionAddWidget(ruleModeller, eventBus, (ActionGlobalCollectionAdd) action, readOnly); } List<RuleModellerActionPlugin> matchingActionPlugins = actionPlugins.stream().filter(p -> p.accept(action)).collect(Collectors.toList()); if (matchingActionPlugins.size() > 1) { throw new IllegalStateException("Ambigious " + RuleModellerActionPlugin.class.getName() + " implementations for action " + action); } if (matchingActionPlugins.size() == 1) { RuleModellerActionPlugin actionPlugin = matchingActionPlugins.get(0); RuleModellerWidget ruleModellerWidget = actionPlugin.createWidget(ruleModeller, eventBus, action, readOnly); return ruleModellerWidget; } throw new RuntimeException("I don't know what type of action is: " + action); }