package locator.selector;

import locator.Location;

import java.util.List;

/**
 * Created by Parth on 12/20/2014.
 *
 */
public class NearestOneLocationSelector extends AbstractLocationSelector {

    private Location closestLocation;

    @Override
    protected void processCurrentLocation(List<Location> locations, Location currentLocation, boolean allDone) {

        if (allDone)
            locations.add(closestLocation);

        else if (closestLocation == null) closestLocation = currentLocation;

        else {
            Location userLocation = locations.get(0);

            double minDistance = userLocation.getDistanceFrom(closestLocation);

            double currentDistance = userLocation.getDistanceFrom(currentLocation);

            if (currentDistance < minDistance)
                closestLocation = currentLocation;
        }
    }
}

@@ -80,43 +80,33 @@
 *%0A *
- Created by Parth on 12/20/2014.%0A *
+%0A * @author Parth Solanki
 %0A */

Update NearestOneLocationSelector.java