@@ -0,0 +1,1909 @@
+package cz.cuni.mff.d3s.deeco.ros.seams2016.garbagecollection;%0A%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0A%0Aimport cz.cuni.mff.d3s.deeco.timer.CurrentTimeProvider;%0Aimport cz.cuni.mff.d3s.jdeeco.position.Position;%0A%0Apublic class PositionMonitor %7B%0A%09static class PositionInfo %7B%0A%09%09public Position position;%0A%09%09public String initialOwner;%0A%09%09public String reachedBy;%0A%09%09public long reachedAtMs;%0A%0A%09%09public PositionInfo(Position position, String initalOwner) %7B%0A%09%09%09this.position = position;%0A%09%09%09this.initialOwner = initalOwner;%0A%09%09%7D%0A%0A%09%09public boolean isReached() %7B%0A%09%09%09return reachedBy != null;%0A%09%09%7D%0A%0A%09%09public void reached(String reachedBy, long reachedAtMs) %7B%0A%09%09%09if(isReached()) %7B%0A%09%09%09%09System.out.println(%22Position reached again!!!%22);%0A%09%09%09%09return;%0A%09%09%09%7D%0A%09%09%09this.reachedBy = reachedBy;%0A%09%09%09this.reachedAtMs = reachedAtMs;%0A%09%09%7D%0A%0A%09%09@Override%0A%09%09public String toString() %7B%0A%09%09%09return String.format(%22%5B%25s, initialOwner: %25s, reachedBy: %25s (%25dms)%5D%22, position.toString(), initialOwner,%0A%09%09%09%09%09isReached() ? reachedBy : %22none%22, reachedAtMs);%0A%09%09%7D%0A%09%7D%0A%0A%09private Map%3CPosition, PositionInfo%3E positions = new HashMap%3C%3E();%0A%09private final CurrentTimeProvider clock;%0A%0A%09public PositionMonitor(CurrentTimeProvider clock) %7B%0A%09%09this.clock = clock;%0A%09%7D%0A%0A%09@Override%0A%09public String toString() %7B%0A%09%09StringBuilder builder = new StringBuilder();%0A%0A%09%09for (PositionInfo info : positions.values()) %7B%0A%09%09%09builder.append(info.toString());%0A%09%09%09builder.append(%22, %22);%0A%09%09%7D%0A%0A%09%09return builder.toString();%0A%09%7D%0A%0A%09public void reportReached(Position position, String reachedBy) %7B%0A%09%09positions.get(position).reached(reachedBy, clock.getCurrentMilliseconds());%0A%09%09printStatus();%0A%09%7D%0A%0A%09public void printStatus() %7B%0A%09%09System.out.println(%22%3E%3E%3E Waypoint status:%22);%0A%09%09for (PositionInfo info : positions.values()) %7B%0A%09%09%09System.out.println(info.toString());%0A%09%09%7D%0A%09%7D%0A%09%0A%09public void addPosition(Position position, String owner) %7B%0A%09%09positions.put(position, new PositionInfo(position, owner));%0A%09%7D%0A%7D%0A

Add PositionMonitor