void (Consumer<? super Configuration> consumer) { patternTree.addTreeSelectionListener(event -> { final var selection = patternTree.getLastSelectedPathComponent(); if (!(selection instanceof DefaultMutableTreeNode) || myDraftTemplateAutoselect) { return; } if (myTemplateChanged) { myDraftTemplateNode.setUserObject(myConfigurationProducer.get()); myTemplateChanged = false; } final var configuration = ((DefaultMutableTreeNode)selection).getUserObject(); if (configuration instanceof Configuration) { consumer.accept((Configuration)configuration); } }); }