View Javadoc

1   /**
2    * Copyright © 2018 spring-data-dynamodb (https://github.com/derjust/spring-data-dynamodb)
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.socialsignin.spring.data.dynamodb.core;
17  
18  import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper.FailedBatch;
19  import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapperTableModel;
20  import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBQueryExpression;
21  import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBScanExpression;
22  import com.amazonaws.services.dynamodbv2.datamodeling.KeyPair;
23  import com.amazonaws.services.dynamodbv2.datamodeling.PaginatedQueryList;
24  import com.amazonaws.services.dynamodbv2.datamodeling.PaginatedScanList;
25  import com.amazonaws.services.dynamodbv2.model.QueryRequest;
26  
27  import java.util.List;
28  import java.util.Map;
29  
30  /**
31   * Interface to DynmaoDB - as seen from the Spring-Data world
32   */
33  public interface DynamoDBOperations {
34  
35  	<T> int count(Class<T> domainClass, DynamoDBQueryExpression<T> queryExpression);
36  	<T> int count(Class<T> domainClass, DynamoDBScanExpression scanExpression);
37  	<T> int count(Class<T> clazz, QueryRequest mutableQueryRequest);
38  
39  	<T> PaginatedQueryList<T> query(Class<T> clazz, QueryRequest queryRequest);
40  	<T> PaginatedQueryList<T> query(Class<T> domainClass, DynamoDBQueryExpression<T> queryExpression);
41  	<T> PaginatedScanList<T> scan(Class<T> domainClass, DynamoDBScanExpression scanExpression);
42  
43  	<T> T load(Class<T> domainClass, Object hashKey, Object rangeKey);
44  	<T> T load(Class<T> domainClass, Object hashKey);
45  	<T> List<T> batchLoad(Map<Class<?>, List<KeyPair>> itemsToGet);
46  
47  	<T> T save(T entity);
48  	List<FailedBatch> batchSave(Iterable<?> entities);
49  
50  	<T> T delete(T entity);
51  	List<FailedBatch> batchDelete(Iterable<?> entities);
52  
53  	<T> String getOverriddenTableName(Class<T> domainClass, String tableName);
54  
55  	/**
56  	 * Provides access to the DynamoDB mapper table model of the underlying domain
57  	 * type.
58  	 *
59  	 * @param <T>
60  	 *            The type of the domain type itself
61  	 * @param domainClass
62  	 *            A domain type
63  	 * @return Corresponding DynamoDB table model
64  	 */
65  	<T> DynamoDBMapperTableModel<T> getTableModel(Class<T> domainClass);
66  }