@Test public void testGetNearestTarget() throws Exception { Map<String, D3Vector> allEntities = new ConcurrentHashMap<>(); setField(radar, "allEntities", allEntities); allEntities.put("far", new D3Vector(100, 100, 100)); allEntities.put("near", new D3Vector(10, 10, 10)); allEntities.put("Out-of-range", new D3Vector(800, 800, 800)); Optional<D3Vector> target = radar.getNearestTarget(); if (target.isPresent()) { Assert.assertThat(target.get(), is(new D3Vector(10, 10, 10))); } else { Assert.fail("No nearest target found"); } }
public Optional<D3Vector> getNearestTarget() { return getRadar() .parallelStream().min(Comparator.comparingDouble(e -> e.distance_between(position))); }
Radar implements Subscriber { public Optional<D3Vector> getNearestTarget() { return getRadar() .parallelStream().min(Comparator.comparingDouble(e -> e.distance_between(position))); } }
Radar implements Subscriber { public Optional<D3Vector> getNearestTarget() { return getRadar() .parallelStream().min(Comparator.comparingDouble(e -> e.distance_between(position))); } Radar();  Radar(ArchitectureEventController architectureEventController, DroneInit drone, Discoverer discoverer, D3Vector position);  Radar(Radar copy); }
Radar implements Subscriber { public Optional<D3Vector> getNearestTarget() { return getRadar() .parallelStream().min(Comparator.comparingDouble(e -> e.distance_between(position))); } 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 Optional<D3Vector> getNearestTarget() { return getRadar() .parallelStream().min(Comparator.comparingDouble(e -> e.distance_between(position))); } 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; }