Source:
<code><START> public Collection<ContainerRendered> getContainersRendered(final Template template, final Context velocityContext, <END> PageMode mode) throws DotSecurityException, DotDataException { final User systemUser = this.userAPI.getSystemUser(); if (!template.isDrawed()) { return Collections.EMPTY_LIST; } final TemplateLayout layout = DotTemplateTool.themeLayout(template.getInode()); final List<ContainerUUID> containersUUID = this.templateAPI.getContainersUUID(layout); final Map<String, List<ContainerUUID>> groupByContainerID = containersUUID.stream().collect(Collectors.groupingBy(ContainerUUID::getIdentifier)); return groupByContainerID.entrySet().stream().map(entry -> { final String containerId = entry.getKey(); try { final Container container = (mode.showLive) ? (Container) APILocator.getVersionableAPI().findLiveVersion(containerId, systemUser, false) : (Container) APILocator.getVersionableAPI().findWorkingVersion(containerId, systemUser, false); final List<ContainerStructure> containerStructures = this.containerAPI.getContainerStructures(container); Map<String, String> containersRendered = null; if (velocityContext != null) { containersRendered = entry.getValue().stream() .map(containerUUID -> containerUUID.getUUID()) .collect(Collectors.toMap(uuid -> "uuid-" + uuid, uuid -> { final VelocityResourceKey key = new VelocityResourceKey(container, uuid, mode); try { return VelocityUtil.mergeTemplate(key.path, velocityContext); } catch (Exception e) { throw new DotRuntimeException(String.format("Container '%s' could not be " + "rendered via " + "Velocity.", container.getIdentifier()), e); } })); } return new ContainerRendered(container, containerStructures, containersRendered); } catch (DotDataException | DotSecurityException e) { Logger.error(ContainerRenderedBuilder.class, e.getMessage()); throw new DotRuntimeException(e); } }).collect(Collectors.toList()); }</code><technical_language>This logic fragmented in a couple of methods, especially if lambda expressions</technical_language>

Target:
public Collection<ContainerRendered> getContainersRendered(final Template template, final Context velocityContext, PageMode mode) throws DotSecurityException, DotDataException { if (!template.isDrawed()) { return Collections.EMPTY_LIST; } final TemplateLayout layout = DotTemplateTool.themeLayout(template.getInode()); final List<ContainerUUID> containersUUID = this.templateAPI.getContainersUUID(layout); final Map<String, List<ContainerUUID>> groupByContainerID = containersUUID.stream().collect(Collectors.groupingBy(ContainerUUID::getIdentifier)); return groupByContainerID.entrySet().stream().map(entry -> { final String containerId = entry.getKey(); try { final Container container = getContainer(mode, containerId); final List<ContainerStructure> containerStructures = this.containerAPI.getContainerStructures(container); Map<String, String> containersRendered = velocityContext != null ? render(velocityContext, mode, entry.getValue(), container): null; return new ContainerRendered(container, containerStructures, containersRendered); } catch (DotDataException | DotSecurityException e) { Logger.error(ContainerRenderedBuilder.class, e.getMessage()); throw new DotRuntimeException(e); } }).collect(Collectors.toList()); }