private FederatedService getProviderFromProviders( Set<FederatedService> providers) throws OutOfServiceAreaServiceException, MultipleServiceAreasServiceException { if (providers.size() == 1) return providers.iterator().next(); if (providers.size() == 0) throw new OutOfServiceAreaServiceException(); throw new MultipleServiceAreasServiceException(); }
private FederatedService getProviderFromProviders( Set<FederatedService> providers) throws OutOfServiceAreaServiceException, MultipleServiceAreasServiceException { if (providers.size() == 1) return providers.iterator().next(); if (providers.size() == 0) throw new OutOfServiceAreaServiceException(); throw new MultipleServiceAreasServiceException(); }
@Override public FederatedService getServiceForLocations(List<CoordinatePoint> points) throws ServiceAreaServiceException { FederatedService service = null; for (CoordinatePoint point : points) { FederatedService provider = getServiceForLocation(point.getLat(), point.getLon()); if (service == null) { service = provider; } else if (service != provider) { throw new MultipleServiceAreasServiceException(); } } if (service == null) throw new OutOfServiceAreaServiceException(); return service; }