Source:
public Set<TimelineObjectHolder<VersionType, ObjectType>> findFullyOvershadowed() { lock.readLock().lock(); try { final Map<Interval, Map<VersionType, TimelineEntry>> overShadowed = new HashMap<>(); for (Map.Entry<Interval, TreeMap<VersionType, TimelineEntry>> versionEntry : allTimelineEntries.entrySet()) { Map<VersionType, TimelineEntry> versionCopy = new HashMap<>(versionEntry.getValue()); overShadowed.put(versionEntry.getKey(), versionCopy); } for (Entry<Interval, TimelineEntry> entry : completePartitionsTimeline.entrySet()) { Map<VersionType, TimelineEntry> versionEntry = overShadowed.get(entry.getValue().getTrueInterval()); if (versionEntry != null) { versionEntry.remove(entry.getValue().getVersion()); if (versionEntry.isEmpty()) { overShadowed.remove(entry.getValue().getTrueInterval()); } } } for (Entry<Interval, TimelineEntry> entry : incompletePartitionsTimeline.entrySet()) { Map<VersionType, TimelineEntry> versionEntry = overShadowed.get(entry.getValue().getTrueInterval()); if (versionEntry != null) { versionEntry.remove(entry.getValue().getVersion()); if (versionEntry.isEmpty()) { overShadowed.remove(entry.getValue().getTrueInterval()); } } } final Set<TimelineObjectHolder<VersionType, ObjectType>> retVal = new HashSet<>(); for (Entry<Interval, Map<VersionType, TimelineEntry>> versionEntry : overShadowed.entrySet()) { for (Entry<VersionType, TimelineEntry> entry : versionEntry.getValue().entrySet()) { final TimelineEntry timelineEntry = entry.getValue(); retVal.add(timelineEntryToObjectHolder(timelineEntry)); } } for (TimelineEntry entry : incompletePartitionsTimeline.values()) { if (!entry.partitionHolder.getOvershadowed().isEmpty()) { retVal.add( new TimelineObjectHolder<>( entry.trueInterval, entry.version, new PartitionHolder<>(new ArrayList<>(entry.partitionHolder.getOvershadowed())) ) ); } } return retVal; } finally { lock.readLock().unlock(); } }

Target:
public Set<TimelineObjectHolder<VersionType, ObjectType>> findFullyOvershadowed() { lock.readLock().lock(); try { final Map<Interval, Map<VersionType, TimelineEntry>> overShadowed = new HashMap<>(); for (Map.Entry<Interval, TreeMap<VersionType, TimelineEntry>> versionEntry : allTimelineEntries.entrySet()) { @SuppressWarnings("unchecked") Map<VersionType, TimelineEntry> versionCopy = (TreeMap) versionEntry.getValue().clone(); overShadowed.put(versionEntry.getKey(), versionCopy); } for (Entry<Interval, TimelineEntry> entry : completePartitionsTimeline.entrySet()) { Map<VersionType, TimelineEntry> versionEntry = overShadowed.get(entry.getValue().getTrueInterval()); if (versionEntry != null) { versionEntry.remove(entry.getValue().getVersion()); if (versionEntry.isEmpty()) { overShadowed.remove(entry.getValue().getTrueInterval()); } } } for (Entry<Interval, TimelineEntry> entry : incompletePartitionsTimeline.entrySet()) { Map<VersionType, TimelineEntry> versionEntry = overShadowed.get(entry.getValue().getTrueInterval()); if (versionEntry != null) { versionEntry.remove(entry.getValue().getVersion()); if (versionEntry.isEmpty()) { overShadowed.remove(entry.getValue().getTrueInterval()); } } } final Set<TimelineObjectHolder<VersionType, ObjectType>> retVal = new HashSet<>(); for (Entry<Interval, Map<VersionType, TimelineEntry>> versionEntry : overShadowed.entrySet()) { for (Entry<VersionType, TimelineEntry> entry : versionEntry.getValue().entrySet()) { final TimelineEntry timelineEntry = entry.getValue(); retVal.add(timelineEntryToObjectHolder(timelineEntry)); } } for (TimelineEntry entry : incompletePartitionsTimeline.values()) { final List<PartitionChunk<ObjectType>> entryOvershadowed = entry.partitionHolder.getOvershadowed(); if (!entryOvershadowed.isEmpty()) { retVal.add( new TimelineObjectHolder<>( entry.trueInterval, entry.version, new PartitionHolder<>(entryOvershadowed) ) ); } } return retVal; } finally { lock.readLock().unlock(); } }