Source:
public void createTrace(IWorkbenchWindow window, BiFunction<Collection<EClass>, List<EObject>, Optional<EClass>> chooseTraceType) { List<?> artifacts = SelectionView.getOpenedView().getSelection(); TraceMetaModelAdapter traceAdapter = ExtensionPointHelper.getTraceMetamodelAdapter().get(); TracePersistenceAdapter persistenceAdapter = ExtensionPointHelper.getTracePersistenceAdapter().get(); ResourceSet resourceSet = new ResourceSetImpl(); EObject traceModel = persistenceAdapter.getTraceModel(resourceSet); EObject artifactModel = persistenceAdapter.getArtifactWrappers(resourceSet); ArtifactHelper artifactHelper = new ArtifactHelper(artifactModel); TraceHelper traceHelper = new TraceHelper(traceModel); List<EObject> wrappers = artifactHelper.createWrappers(artifacts); Collection<EClass> traceTypes = traceAdapter.getAvailableTraceTypes(wrappers); Optional<EClass> chosenType = chooseTraceType.apply(traceTypes, wrappers); if (chosenType.isPresent()) { if (traceHelper.traceExists(wrappers, chosenType.get(), traceModel)) { MessageDialog.openInformation(window.getShell(), "Capra Information", "The trace link you want to create already exists and will therefore not be created"); } else { traceHelper.createTrace(wrappers, chosenType.get()); persistenceAdapter.saveTracesAndArtifacts(traceModel, artifactModel); traceHelper.annotateTrace(wrappers); IPreferenceStore store = CapraPreferences.getPreferences(); if (store.getBoolean(CapraPreferences.SHOW_TRACE_CREATED_SUCCESSFULLY_DIALOG)) { MessageDialogWithToggle.open(MessageDialog.INFORMATION, window.getShell(), "Capra Information", "Trace link has been successfully created", "Do not show this dialog again", false, store, CapraPreferences.SHOW_TRACE_CREATED_SUCCESSFULLY_DIALOG, SWT.NONE); } } } }

Target:
public void createTrace(IWorkbenchWindow window, BiFunction<Collection<EClass>, List<EObject>, Optional<EClass>> chooseTraceType) { List<?> artifacts = SelectionView.getOpenedView().getSelection(); TraceMetaModelAdapter traceAdapter = ExtensionPointHelper.getTraceMetamodelAdapter().get(); TracePersistenceAdapter persistenceAdapter = ExtensionPointHelper.getTracePersistenceAdapter().get(); ResourceSet resourceSet = new ResourceSetImpl(); EObject traceModel = persistenceAdapter.getTraceModel(resourceSet); EObject artifactModel = persistenceAdapter.getArtifactWrappers(resourceSet); ArtifactHelper artifactHelper = new ArtifactHelper(artifactModel); TraceHelper traceHelper = new TraceHelper(traceModel); List<EObject> wrappers = artifactHelper.createWrappers(artifacts); Collection<EClass> traceTypes = traceAdapter.getAvailableTraceTypes(wrappers); Optional<EClass> chosenType = chooseTraceType.apply(traceTypes, wrappers); if (chosenType.isPresent()) { if (traceHelper.traceExists(wrappers, chosenType.get(), traceModel)) { MessageDialog.openInformation(window.getShell(), CAPRA_INFORMATION, TRACE_LINK_EXISTS); } else { traceHelper.createTrace(wrappers, chosenType.get()); persistenceAdapter.saveTracesAndArtifacts(traceModel, artifactModel); traceHelper.annotateTrace(wrappers); IPreferenceStore store = CapraPreferences.getPreferences(); if (store.getBoolean(CapraPreferences.SHOW_TRACE_CREATED_CONFIRMATION_DIALOG)) { MessageDialogWithToggle.open(MessageDialog.INFORMATION, window.getShell(), CAPRA_INFORMATION, TRACE_LINK_SUCCESSFULLY_CREATED, DO_NOT_SHOW_DIALOG_AGAIN, false, store, CapraPreferences.SHOW_TRACE_CREATED_CONFIRMATION_DIALOG, SWT.NONE); } } } }