Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
Table |
|
| 1.0;1 |
1 | /** | |
2 | * Copyright (c) 2012-2016, jcabi.com | |
3 | * All rights reserved. | |
4 | * | |
5 | * Redistribution and use in source and binary forms, with or without | |
6 | * modification, are permitted provided that the following conditions | |
7 | * are met: 1) Redistributions of source code must retain the above | |
8 | * copyright notice, this list of conditions and the following | |
9 | * disclaimer. 2) Redistributions in binary form must reproduce the above | |
10 | * copyright notice, this list of conditions and the following | |
11 | * disclaimer in the documentation and/or other materials provided | |
12 | * with the distribution. 3) Neither the name of the jcabi.com nor | |
13 | * the names of its contributors may be used to endorse or promote | |
14 | * products derived from this software without specific prior written | |
15 | * permission. | |
16 | * | |
17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
18 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT | |
19 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | |
20 | * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | |
21 | * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |
22 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
26 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | |
28 | * OF THE POSSIBILITY OF SUCH DAMAGE. | |
29 | */ | |
30 | package com.jcabi.dynamo; | |
31 | ||
32 | import com.amazonaws.services.dynamodbv2.model.AttributeValue; | |
33 | import com.jcabi.aspects.Immutable; | |
34 | import java.io.IOException; | |
35 | import java.util.Map; | |
36 | ||
37 | /** | |
38 | * Amazon DynamoDB table abstraction. | |
39 | * | |
40 | * <p>To get data from the table use {@link Table#frame()} method. To | |
41 | * create a new item in the table (or replace the existing one) use | |
42 | * {@link Table#put(Attributes)} method. For example: | |
43 | * | |
44 | * <pre> Region region = new Region.Simple(...); | |
45 | * Table table = region.table("employees"); | |
46 | * table.put(new Attributes().with("name", "John Smith")); | |
47 | * for (Item item : table.frame()) { | |
48 | * System.out.println("Name: " + item.get("name").getS()); | |
49 | * } | |
50 | * table.frame() | |
51 | * .where("name", Conditions.equalTo("John Smith")) | |
52 | * .iterator().next().remove();</pre> | |
53 | * | |
54 | * @author Yegor Bugayenko (yegor@tpc2.com) | |
55 | * @version $Id: b8dd7ca56614ab966c3c0ce461cb1bd87a4af56f $ | |
56 | * @since 0.1 | |
57 | */ | |
58 | @Immutable | |
59 | public interface Table { | |
60 | ||
61 | /** | |
62 | * Put new item there. | |
63 | * | |
64 | * <p>It is recommended to use {@link Attributes} supplementary class, | |
65 | * instead of a raw {@link Map}. | |
66 | * | |
67 | * @param attributes Attributes to save | |
68 | * @return Item just created | |
69 | * @throws IOException In case of DynamoDB failure | |
70 | * @see Attributes | |
71 | */ | |
72 | Item put(Map<String, AttributeValue> attributes) throws IOException; | |
73 | ||
74 | /** | |
75 | * Make a new frame, in order to retrieve items. | |
76 | * @return Frame | |
77 | */ | |
78 | Frame frame(); | |
79 | ||
80 | /** | |
81 | * Get back to the entire region. | |
82 | * @return Region | |
83 | */ | |
84 | Region region(); | |
85 | ||
86 | /** | |
87 | * Get real table name. | |
88 | * @return Actual name of DynamoDB table | |
89 | */ | |
90 | String name(); | |
91 | ||
92 | /** | |
93 | * Delete item from aws table. | |
94 | * <p>It is recommended to use {@link Attributes} supplementary class, | |
95 | * instead of a raw {@link Map}. | |
96 | * @param attributes Attributes containing item key and value | |
97 | * @throws IOException In case of DynamoDB failure | |
98 | * @see Attributes | |
99 | */ | |
100 | void delete(Map<String, AttributeValue> attributes) throws IOException; | |
101 | ||
102 | } |