@Test public void testParseLocationsSingle() { final String swLon = "-122.75"; final String swLat = "36.8"; final String neLon = "-121.75"; final String neLat = "37.8"; final String locationString = swLon + "," + swLat + "," + neLon + "," + neLat; List<Location> locations = LocationUtil.parseLocations(locationString); Assert.assertEquals(1, locations.size()); Location location = locations.get(0); Assert.assertEquals(new Double(location.southwestCoordinate().longitude()), Double.valueOf(swLon)); Assert.assertEquals(new Double(location.southwestCoordinate().latitude()), Double.valueOf(swLat)); Assert.assertEquals(new Double(location.northeastCoordinate().longitude()), Double.valueOf(neLon)); Assert.assertEquals(new Double(location.northeastCoordinate().latitude()), Double.valueOf(neLat)); }
public static List<Location> parseLocations(final String input) { final List<Location> locations = new ArrayList<>(); final Matcher locationsMatcher = LOCATIONS_PATTERN.matcher(input); if (locationsMatcher.matches()) { Matcher locationMatcher = LOCATION_PATTERN.matcher(input); while (locationMatcher.find()) { final String location = locationMatcher.group(); locations.add(parseLocation(location)); } } else { throw new IllegalStateException("The provided location string was invalid."); } return locations; }
LocationUtil { public static List<Location> parseLocations(final String input) { final List<Location> locations = new ArrayList<>(); final Matcher locationsMatcher = LOCATIONS_PATTERN.matcher(input); if (locationsMatcher.matches()) { Matcher locationMatcher = LOCATION_PATTERN.matcher(input); while (locationMatcher.find()) { final String location = locationMatcher.group(); locations.add(parseLocation(location)); } } else { throw new IllegalStateException("The provided location string was invalid."); } return locations; } }
LocationUtil { public static List<Location> parseLocations(final String input) { final List<Location> locations = new ArrayList<>(); final Matcher locationsMatcher = LOCATIONS_PATTERN.matcher(input); if (locationsMatcher.matches()) { Matcher locationMatcher = LOCATION_PATTERN.matcher(input); while (locationMatcher.find()) { final String location = locationMatcher.group(); locations.add(parseLocation(location)); } } else { throw new IllegalStateException("The provided location string was invalid."); } return locations; }  }
LocationUtil { public static List<Location> parseLocations(final String input) { final List<Location> locations = new ArrayList<>(); final Matcher locationsMatcher = LOCATIONS_PATTERN.matcher(input); if (locationsMatcher.matches()) { Matcher locationMatcher = LOCATION_PATTERN.matcher(input); while (locationMatcher.find()) { final String location = locationMatcher.group(); locations.add(parseLocation(location)); } } else { throw new IllegalStateException("The provided location string was invalid."); } return locations; }  static List<Location> parseLocations(final String input); static Location parseLocation(final String location); }
LocationUtil { public static List<Location> parseLocations(final String input) { final List<Location> locations = new ArrayList<>(); final Matcher locationsMatcher = LOCATIONS_PATTERN.matcher(input); if (locationsMatcher.matches()) { Matcher locationMatcher = LOCATION_PATTERN.matcher(input); while (locationMatcher.find()) { final String location = locationMatcher.group(); locations.add(parseLocation(location)); } } else { throw new IllegalStateException("The provided location string was invalid."); } return locations; }  static List<Location> parseLocations(final String input); static Location parseLocation(final String location);  }