@@ -0,0 +1,2886 @@
+//snippet-sourcedescription:%5BDynamoDBAsyncListTables.java demonstrates how to use the asynchronous DynamoDB client to list tables.%5D%0A//snippet-keyword:%5BSDK for Java 2.0%5D%0A//snippet-keyword:%5BCode Sample%5D%0A//snippet-service:%5BDynamoDB%5D%0A//snippet-sourcetype:%5Bfull-example%5D%0A//snippet-sourcedate:%5B8/7/2020%5D%0A//snippet-sourceauthor:%5Bscmacdon-aws%5D%0A/*%0A * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at:%0A *%0A *    http://aws.amazon.com/apache2.0%0A *%0A * This file is distributed on an %22AS IS%22 BASIS, WITHOUT WARRANTIES%0A * OR CONDITIONS OF ANY KIND, either express or implied. See the%0A * License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage com.example.dynamodbasync;%0A%0A// snippet-start:%5Bdynamodb.java2.dbasync.complete%5D%0A// snippet-start:%5Bdynamodb.java2.dbasync.import%5D%0Aimport software.amazon.awssdk.regions.Region;%0Aimport software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient;%0Aimport software.amazon.awssdk.services.dynamodb.model.ListTablesRequest;%0Aimport software.amazon.awssdk.services.dynamodb.model.ListTablesResponse;%0Aimport java.util.List;%0Aimport java.util.concurrent.CompletableFuture;%0A// snippet-end:%5Bdynamodb.java2.dbasync.import%5D%0A%0A// snippet-start:%5Bdynamodb.java2.dbasync.main%5D%0Apublic class DynamoDBAsyncListTables %7B%0A%0A    public static void main(String%5B%5D args) throws InterruptedException %7B%0A%0A        // Create the DynamoDbAsyncClient object%0A        Region region = Region.US_EAST_1;%0A        DynamoDbAsyncClient client = DynamoDbAsyncClient.builder()%0A                .region(region)%0A                .build();%0A%0A        listTables(client);%0A    %7D%0A%0A    public static void listTables(DynamoDbAsyncClient client) %7B%0A%0A        CompletableFuture%3CListTablesResponse%3E response = client.listTables(ListTablesRequest.builder()%0A                .build());%0A%0A        // Map the response to another CompletableFuture containing just the table names%0A        CompletableFuture%3CList%3CString%3E%3E tableNames = response.thenApply(ListTablesResponse::tableNames);%0A%0A        // When future is complete (either successfully or in error) handle the response%0A        tableNames.whenComplete((tables, err) -%3E %7B%0A            try %7B%0A                if (tables != null) %7B%0A                    tables.forEach(System.out::println);%0A                %7D else %7B%0A                    // Handle error%0A                    err.printStackTrace();%0A                %7D%0A            %7D finally %7B%0A                // Lets the application shut down. Only close the client when you are completely done with it.%0A                client.close();%0A            %7D%0A        %7D);%0A        tableNames.join();%0A    %7D%0A%7D%0A// snippet-end:%5Bdynamodb.java2.dbasync.main%5D%0A// snippet-end:%5Bdynamodb.java2.dbasync.complete%5D%0A

Create DynamoDBAsyncListTables.java