Source:
private void createGroupIfNecessary(SelectionContext<C> context, Executor executor) { synchronized (lockObj) { ResourceGroupId id = context.getResourceGroupId(); int specVersion = configurationManager.get().getSpecVersion(); if (!groups.containsKey(id)) { InternalResourceGroup group; if (id.getParent().isPresent()) { createGroupIfNecessary(new SelectionContext<>(id.getParent().get(), context.getContext()), executor); InternalResourceGroup parent = groups.get(id.getParent().get()).getLatest(); requireNonNull(parent, "parent is null"); group = parent.getOrCreateSubGroup(id.getLastSegment(), specVersion); } else { RootInternalResourceGroup root = new RootInternalResourceGroup(id.getSegments().get(0), this::exportGroup, executor, specVersion); group = root; rootGroups.add(root); } configurationManager.get().configure(group, context); checkState(groups.put(id, group) == null, "Unexpected existing resource group"); } else { InternalResourceGroup group = groups.get(id).getLatest(); if (specVersion != group.getVersion()) { InternalResourceGroup newGroup; if (id.getParent().isPresent()) { createGroupIfNecessary(new SelectionContext<>(id.getParent().get(), context.getContext()), executor); InternalResourceGroup parent = groups.get(id.getParent().get()).getLatest(); requireNonNull(parent, "parent is null"); newGroup = parent.getOrCreateSubGroup(id.getLastSegment(), specVersion); } else { RootInternalResourceGroup root = new RootInternalResourceGroup(id.getSegments().get(0), this::exportGroup, executor, group.getRoot(), specVersion); newGroup = root; } configurationManager.get().configure(newGroup, context); group.setNext(newGroup); newGroup.setPrev(group); groups.put(id, newGroup); } } } }

Target:
private void createGroupIfNecessary(SelectionContext<C> context, Executor executor) { synchronized (this) { ResourceGroupId id = context.getResourceGroupId(); int specVersion = configurationManager.get().getSpecVersion(); if (!groups.containsKey(id)) { InternalResourceGroup group; if (id.getParent().isPresent()) { createGroupIfNecessary(new SelectionContext<>(id.getParent().get(), context.getContext()), executor); InternalResourceGroup parent = groups.get(id.getParent().get()).getLatest(); requireNonNull(parent, "parent is null"); int subGroupSegmentIndex = parent.getId().getSegments().size(); group = parent.getOrCreateSubGroup(id.getLastSegment(), !context.getFirstDynamicSegmentPosition().equals(OptionalInt.of(subGroupSegmentIndex)), specVersion); } else { RootInternalResourceGroup root = new RootInternalResourceGroup(id.getSegments().get(0), this::exportGroup, executor, specVersion); group = root; rootGroups.add(root); } configurationManager.get().configure(group, context); checkState(groups.put(id, group) == null, "Unexpected existing resource group"); } else { InternalResourceGroup group = groups.get(id).getLatest(); if (specVersion != group.getVersion()) { InternalResourceGroup newGroup; if (id.getParent().isPresent()) { createGroupIfNecessary(new SelectionContext<>(id.getParent().get(), context.getContext()), executor); InternalResourceGroup parent = groups.get(id.getParent().get()).getLatest(); requireNonNull(parent, "parent is null"); int subGroupSegmentIndex = parent.getId().getSegments().size(); newGroup = parent.getOrCreateSubGroup(id.getLastSegment(), !context.getFirstDynamicSegmentPosition().equals(OptionalInt.of(subGroupSegmentIndex)), specVersion); } else { newGroup = new RootInternalResourceGroup(id.getSegments().get(0), this::exportGroup, executor, group.getRoot(), specVersion); } configurationManager.get().configure(newGroup, context); group.setNext(newGroup); newGroup.setPrev(group); groups.put(id, newGroup); } } } }