content: package com.amazon.asksdk.scorekeeper.storage;
  
  import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient;
  import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper;
  
  /**
   * Client for DynamoDB persistance layer for the Score Keeper skill.
   */
  public class ScoreKeeperDynamoDbClient {
      private final AmazonDynamoDBClient dynamoDBClient;
  
      public ScoreKeeperDynamoDbClient(final AmazonDynamoDBClient dynamoDBClient) {
          this.dynamoDBClient = dynamoDBClient;
      }
  
      /**
       * Loads an item from DynamoDB by primary Hash Key. Callers of this method should pass in an
       * object which represents an item in the DynamoDB table item with the primary key populated.
       * 
       * @param tableItem
       * @return
       */
      public ScoreKeeperUserDataItem loadItem(final ScoreKeeperUserDataItem tableItem) {
          DynamoDBMapper mapper = createDynamoDBMapper();
          ScoreKeeperUserDataItem item = mapper.load(tableItem);
          return item;
      }
  
      /**
       * Stores an item to DynamoDB.
       * 
       * @param tableItem
       */
      public void saveItem(final ScoreKeeperUserDataItem tableItem) {
          DynamoDBMapper mapper = createDynamoDBMapper();
          mapper.save(tableItem);
      }
  
      /**
       * Creates a {@link DynamoDBMapper} using the default configurations.
       * 
       * @return
       */
      private DynamoDBMapper createDynamoDBMapper() {
          return new DynamoDBMapper(dynamoDBClient);
      }
  }
  