use of se.michaelthelin.spotify.model_objects.special.SearchResult in project spotify-web-api-java by spotify-web-api-java.
the class SearchItemExample method searchItem_Sync.
public static void searchItem_Sync() {
try {
final SearchResult searchResult = searchItemRequest.execute();
System.out.println("Total tracks: " + searchResult.getTracks().getTotal());
} catch (IOException | SpotifyWebApiException | ParseException e) {
System.out.println("Error: " + e.getMessage());
}
}
use of se.michaelthelin.spotify.model_objects.special.SearchResult in project spotify-web-api-java by spotify-web-api-java.
the class SearchItemExample method searchItem_Async.
public static void searchItem_Async() {
try {
final CompletableFuture<SearchResult> searchResultFuture = searchItemRequest.executeAsync();
// Thread free to do other tasks...
// Example Only. Never block in production code.
final SearchResult searchResult = searchResultFuture.join();
System.out.println("Total tracks: " + searchResult.getTracks().getTotal());
} catch (CompletionException e) {
System.out.println("Error: " + e.getCause().getMessage());
} catch (CancellationException e) {
System.out.println("Async operation cancelled.");
}
}
Aggregations