@Test public void testGetRadar() throws Exception { Map<String, D3Vector> allEntities = new ConcurrentHashMap<>(); setField(radar, "allEntities", allEntities); allEntities.put("in-range", new D3Vector(100, 100, 100)); Assert.assertThat(radar.getRadar(), hasItems(allEntities.values().toArray(new D3Vector[allEntities.size()]))); allEntities.put("Out-of-range", new D3Vector(800, 800, 800)); Assert.assertThat(radar.getRadar(), not(hasItem(new D3Vector(800, 800, 800)))); setField(radar, "position", null); Assert.assertEquals(Collections.emptyList(), radar.getRadar()); }
public List<D3Vector> getRadar() { List<D3Vector> results; if (position != null) { results = allEntities.values() .parallelStream() .filter(otherDrone -> position.distance_between(otherDrone) <= RADAR_RANGE) .collect(Collectors.toList()); } else { results = Collections.emptyList(); } return new ArrayList<>(results); }
Radar implements Subscriber { public List<D3Vector> getRadar() { List<D3Vector> results; if (position != null) { results = allEntities.values() .parallelStream() .filter(otherDrone -> position.distance_between(otherDrone) <= RADAR_RANGE) .collect(Collectors.toList()); } else { results = Collections.emptyList(); } return new ArrayList<>(results); } }
Radar implements Subscriber { public List<D3Vector> getRadar() { List<D3Vector> results; if (position != null) { results = allEntities.values() .parallelStream() .filter(otherDrone -> position.distance_between(otherDrone) <= RADAR_RANGE) .collect(Collectors.toList()); } else { results = Collections.emptyList(); } return new ArrayList<>(results); } Radar();  Radar(ArchitectureEventController architectureEventController, DroneInit drone, Discoverer discoverer, D3Vector position);  Radar(Radar copy); }
Radar implements Subscriber { public List<D3Vector> getRadar() { List<D3Vector> results; if (position != null) { results = allEntities.values() .parallelStream() .filter(otherDrone -> position.distance_between(otherDrone) <= RADAR_RANGE) .collect(Collectors.toList()); } else { results = Collections.emptyList(); } return new ArrayList<>(results); } Radar();  Radar(ArchitectureEventController architectureEventController, DroneInit drone, Discoverer discoverer, D3Vector position);  Radar(Radar copy); D3Vector getPosition(); void setPosition(D3Vector position); void start(); List<D3Vector> getRadar(); Optional<D3Vector> getNearestTarget(); @Override void receive(Object msg, MultipartCallbacks multipartCallbacks); @Override boolean equals(Object o); @Override int hashCode(); }
Radar implements Subscriber { public List<D3Vector> getRadar() { List<D3Vector> results; if (position != null) { results = allEntities.values() .parallelStream() .filter(otherDrone -> position.distance_between(otherDrone) <= RADAR_RANGE) .collect(Collectors.toList()); } else { results = Collections.emptyList(); } return new ArrayList<>(results); } Radar();  Radar(ArchitectureEventController architectureEventController, DroneInit drone, Discoverer discoverer, D3Vector position);  Radar(Radar copy); D3Vector getPosition(); void setPosition(D3Vector position); void start(); List<D3Vector> getRadar(); Optional<D3Vector> getNearestTarget(); @Override void receive(Object msg, MultipartCallbacks multipartCallbacks); @Override boolean equals(Object o); @Override int hashCode(); static final int RADAR_RANGE; }