@Test public void testURLtransformer() throws Exception { SpotifyURL.URLtransformer transformer = new SpotifyURL.URLtransformer(); assertEquals("spotify:track:123", SpotifyURL.match("http: assertEquals("spotify:album:123", SpotifyURL.match("http: assertEquals("spotify:artist:123", SpotifyURL.match("http: assertEquals("spotify:user:kent.finell:playlist:123", SpotifyURL.match("http: assertEquals("http: assertEquals("http: assertEquals("http: assertEquals("http: try { SpotifyURL.match("spotify:moo:bar", transformer); fail(); } catch (DespotifyException e) { } }
public static <T> T match(String URL, Visitor<T> matcher) { Matcher patternMatcher = pattern.matcher(URL); if (!patternMatcher.matches()) { throw new DespotifyException("Not a valid URL: " + URL); } URLtype urlType = patternMatcher.group(2) != null ? URLtype.httpURL : URLtype.spotifyURL; if (patternMatcher.group(5) != null) { return matcher.playlist(urlType, patternMatcher.group(6), patternMatcher.group(7)); } else if ("track".equals(patternMatcher.group(4))) { return matcher.track(urlType, patternMatcher.group(7)); } else if ("album".equals(patternMatcher.group(4))) { return matcher.album(urlType, patternMatcher.group(7)); } else if ("artist".equals(patternMatcher.group(4))) { return matcher.artist(urlType, patternMatcher.group(7)); } else { throw new RuntimeException(); } }
SpotifyURL { public static <T> T match(String URL, Visitor<T> matcher) { Matcher patternMatcher = pattern.matcher(URL); if (!patternMatcher.matches()) { throw new DespotifyException("Not a valid URL: " + URL); } URLtype urlType = patternMatcher.group(2) != null ? URLtype.httpURL : URLtype.spotifyURL; if (patternMatcher.group(5) != null) { return matcher.playlist(urlType, patternMatcher.group(6), patternMatcher.group(7)); } else if ("track".equals(patternMatcher.group(4))) { return matcher.track(urlType, patternMatcher.group(7)); } else if ("album".equals(patternMatcher.group(4))) { return matcher.album(urlType, patternMatcher.group(7)); } else if ("artist".equals(patternMatcher.group(4))) { return matcher.artist(urlType, patternMatcher.group(7)); } else { throw new RuntimeException(); } } }
SpotifyURL { public static <T> T match(String URL, Visitor<T> matcher) { Matcher patternMatcher = pattern.matcher(URL); if (!patternMatcher.matches()) { throw new DespotifyException("Not a valid URL: " + URL); } URLtype urlType = patternMatcher.group(2) != null ? URLtype.httpURL : URLtype.spotifyURL; if (patternMatcher.group(5) != null) { return matcher.playlist(urlType, patternMatcher.group(6), patternMatcher.group(7)); } else if ("track".equals(patternMatcher.group(4))) { return matcher.track(urlType, patternMatcher.group(7)); } else if ("album".equals(patternMatcher.group(4))) { return matcher.album(urlType, patternMatcher.group(7)); } else if ("artist".equals(patternMatcher.group(4))) { return matcher.artist(urlType, patternMatcher.group(7)); } else { throw new RuntimeException(); } }  }
SpotifyURL { public static <T> T match(String URL, Visitor<T> matcher) { Matcher patternMatcher = pattern.matcher(URL); if (!patternMatcher.matches()) { throw new DespotifyException("Not a valid URL: " + URL); } URLtype urlType = patternMatcher.group(2) != null ? URLtype.httpURL : URLtype.spotifyURL; if (patternMatcher.group(5) != null) { return matcher.playlist(urlType, patternMatcher.group(6), patternMatcher.group(7)); } else if ("track".equals(patternMatcher.group(4))) { return matcher.track(urlType, patternMatcher.group(7)); } else if ("album".equals(patternMatcher.group(4))) { return matcher.album(urlType, patternMatcher.group(7)); } else if ("artist".equals(patternMatcher.group(4))) { return matcher.artist(urlType, patternMatcher.group(7)); } else { throw new RuntimeException(); } }  static T match(String URL, Visitor<T> matcher); static Visitable browse(String URL, final Store store, final ConnectionManager connectionManager); }
SpotifyURL { public static <T> T match(String URL, Visitor<T> matcher) { Matcher patternMatcher = pattern.matcher(URL); if (!patternMatcher.matches()) { throw new DespotifyException("Not a valid URL: " + URL); } URLtype urlType = patternMatcher.group(2) != null ? URLtype.httpURL : URLtype.spotifyURL; if (patternMatcher.group(5) != null) { return matcher.playlist(urlType, patternMatcher.group(6), patternMatcher.group(7)); } else if ("track".equals(patternMatcher.group(4))) { return matcher.track(urlType, patternMatcher.group(7)); } else if ("album".equals(patternMatcher.group(4))) { return matcher.album(urlType, patternMatcher.group(7)); } else if ("artist".equals(patternMatcher.group(4))) { return matcher.artist(urlType, patternMatcher.group(7)); } else { throw new RuntimeException(); } }  static T match(String URL, Visitor<T> matcher); static Visitable browse(String URL, final Store store, final ConnectionManager connectionManager); static final Pattern pattern; }