class 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;
    }

}