@Test public void testBrowseArtist() { SpotifyURL.browse("spotify:artist:0WjkBDqno4HbjwNDqyMgVa", new MemoryStore(), manager).accept(new FailingVisitor() { @Override public void visit(Artist artist) { } }); }
public static Visitable browse(String URL, final Store store, final DespotifyManager connectionManager) { return match(URL, new Visitor<Visitable>(){ public Visitable track(URLtype type, String URI) { Track track = store.getTrack(SpotifyURI.toHex(URI)); try { new LoadTracks(store, track).send(connectionManager); } catch (DespotifyException e) { throw new RuntimeException(e); } return track; } public Visitable album(URLtype type, String URI) { Album album = store.getAlbum(SpotifyURI.toHex(URI)); try { new LoadAlbum(store, album).send(connectionManager); } catch (DespotifyException e) { throw new RuntimeException(e); } return album; } public Visitable artist(URLtype type, String URI) { Artist artist = store.getArtist(SpotifyURI.toHex(URI)); try { new LoadArtist(store, artist).send(connectionManager); } catch (DespotifyException e) { throw new RuntimeException(e); } return artist; } public Visitable playlist(URLtype type, String user, String URI) { Playlist playlist = store.getPlaylist(SpotifyURI.toHex(URI)); try { new LoadPlaylist(store, playlist).send(connectionManager); } catch (DespotifyException e) { throw new RuntimeException(e); } return playlist; } }); }
SpotifyURL { public static Visitable browse(String URL, final Store store, final DespotifyManager connectionManager) { return match(URL, new Visitor<Visitable>(){ public Visitable track(URLtype type, String URI) { Track track = store.getTrack(SpotifyURI.toHex(URI)); try { new LoadTracks(store, track).send(connectionManager); } catch (DespotifyException e) { throw new RuntimeException(e); } return track; } public Visitable album(URLtype type, String URI) { Album album = store.getAlbum(SpotifyURI.toHex(URI)); try { new LoadAlbum(store, album).send(connectionManager); } catch (DespotifyException e) { throw new RuntimeException(e); } return album; } public Visitable artist(URLtype type, String URI) { Artist artist = store.getArtist(SpotifyURI.toHex(URI)); try { new LoadArtist(store, artist).send(connectionManager); } catch (DespotifyException e) { throw new RuntimeException(e); } return artist; } public Visitable playlist(URLtype type, String user, String URI) { Playlist playlist = store.getPlaylist(SpotifyURI.toHex(URI)); try { new LoadPlaylist(store, playlist).send(connectionManager); } catch (DespotifyException e) { throw new RuntimeException(e); } return playlist; } }); } }
SpotifyURL { public static Visitable browse(String URL, final Store store, final DespotifyManager connectionManager) { return match(URL, new Visitor<Visitable>(){ public Visitable track(URLtype type, String URI) { Track track = store.getTrack(SpotifyURI.toHex(URI)); try { new LoadTracks(store, track).send(connectionManager); } catch (DespotifyException e) { throw new RuntimeException(e); } return track; } public Visitable album(URLtype type, String URI) { Album album = store.getAlbum(SpotifyURI.toHex(URI)); try { new LoadAlbum(store, album).send(connectionManager); } catch (DespotifyException e) { throw new RuntimeException(e); } return album; } public Visitable artist(URLtype type, String URI) { Artist artist = store.getArtist(SpotifyURI.toHex(URI)); try { new LoadArtist(store, artist).send(connectionManager); } catch (DespotifyException e) { throw new RuntimeException(e); } return artist; } public Visitable playlist(URLtype type, String user, String URI) { Playlist playlist = store.getPlaylist(SpotifyURI.toHex(URI)); try { new LoadPlaylist(store, playlist).send(connectionManager); } catch (DespotifyException e) { throw new RuntimeException(e); } return playlist; } }); }  }
SpotifyURL { public static Visitable browse(String URL, final Store store, final DespotifyManager connectionManager) { return match(URL, new Visitor<Visitable>(){ public Visitable track(URLtype type, String URI) { Track track = store.getTrack(SpotifyURI.toHex(URI)); try { new LoadTracks(store, track).send(connectionManager); } catch (DespotifyException e) { throw new RuntimeException(e); } return track; } public Visitable album(URLtype type, String URI) { Album album = store.getAlbum(SpotifyURI.toHex(URI)); try { new LoadAlbum(store, album).send(connectionManager); } catch (DespotifyException e) { throw new RuntimeException(e); } return album; } public Visitable artist(URLtype type, String URI) { Artist artist = store.getArtist(SpotifyURI.toHex(URI)); try { new LoadArtist(store, artist).send(connectionManager); } catch (DespotifyException e) { throw new RuntimeException(e); } return artist; } public Visitable playlist(URLtype type, String user, String URI) { Playlist playlist = store.getPlaylist(SpotifyURI.toHex(URI)); try { new LoadPlaylist(store, playlist).send(connectionManager); } catch (DespotifyException e) { throw new RuntimeException(e); } return playlist; } }); }  static T match(String URL, Visitor<T> matcher); static Visitable browse(String URL, final Store store, final DespotifyManager connectionManager); }
SpotifyURL { public static Visitable browse(String URL, final Store store, final DespotifyManager connectionManager) { return match(URL, new Visitor<Visitable>(){ public Visitable track(URLtype type, String URI) { Track track = store.getTrack(SpotifyURI.toHex(URI)); try { new LoadTracks(store, track).send(connectionManager); } catch (DespotifyException e) { throw new RuntimeException(e); } return track; } public Visitable album(URLtype type, String URI) { Album album = store.getAlbum(SpotifyURI.toHex(URI)); try { new LoadAlbum(store, album).send(connectionManager); } catch (DespotifyException e) { throw new RuntimeException(e); } return album; } public Visitable artist(URLtype type, String URI) { Artist artist = store.getArtist(SpotifyURI.toHex(URI)); try { new LoadArtist(store, artist).send(connectionManager); } catch (DespotifyException e) { throw new RuntimeException(e); } return artist; } public Visitable playlist(URLtype type, String user, String URI) { Playlist playlist = store.getPlaylist(SpotifyURI.toHex(URI)); try { new LoadPlaylist(store, playlist).send(connectionManager); } catch (DespotifyException e) { throw new RuntimeException(e); } return playlist; } }); }  static T match(String URL, Visitor<T> matcher); static Visitable browse(String URL, final Store store, final DespotifyManager connectionManager); static final Pattern pattern; }