Search in sources :

Example 1 with Artist

use of se.michaelthelin.spotify.model_objects.specification.Artist in project spotify-web-api-java by spotify-web-api-java.

the class GetArtistExample method getArtist_Sync.

public static void getArtist_Sync() {
    try {
        final Artist artist = getArtistRequest.execute();
        System.out.println("Name: " + artist.getName());
    } catch (IOException | SpotifyWebApiException | ParseException e) {
        System.out.println("Error: " + e.getMessage());
    }
}
Also used : Artist(se.michaelthelin.spotify.model_objects.specification.Artist) IOException(java.io.IOException) ParseException(org.apache.hc.core5.http.ParseException) SpotifyWebApiException(se.michaelthelin.spotify.exceptions.SpotifyWebApiException)

Example 2 with Artist

use of se.michaelthelin.spotify.model_objects.specification.Artist in project spotify-web-api-java by spotify-web-api-java.

the class GetArtistExample method getArtist_Async.

public static void getArtist_Async() {
    try {
        final CompletableFuture<Artist> albumFuture = getArtistRequest.executeAsync();
        // Thread free to do other tasks...
        // Example Only. Never block in production code.
        final Artist artist = albumFuture.join();
        System.out.println("Name: " + artist.getName());
    } catch (CompletionException e) {
        System.out.println("Error: " + e.getCause().getMessage());
    } catch (CancellationException e) {
        System.out.println("Async operation cancelled.");
    }
}
Also used : Artist(se.michaelthelin.spotify.model_objects.specification.Artist) CancellationException(java.util.concurrent.CancellationException) CompletionException(java.util.concurrent.CompletionException)

Aggregations

Artist (se.michaelthelin.spotify.model_objects.specification.Artist)2 IOException (java.io.IOException)1 CancellationException (java.util.concurrent.CancellationException)1 CompletionException (java.util.concurrent.CompletionException)1 ParseException (org.apache.hc.core5.http.ParseException)1 SpotifyWebApiException (se.michaelthelin.spotify.exceptions.SpotifyWebApiException)1