Coverage Report - com.jcabi.dynamo.Frame
 
Classes in this File Line Coverage Branch Coverage Complexity
Frame
N/A
N/A
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.Condition;
 33  
 import com.jcabi.aspects.Immutable;
 34  
 import java.util.Collection;
 35  
 import java.util.Map;
 36  
 
 37  
 /**
 38  
  * DynamoDB frame (subset of a table).
 39  
  *
 40  
  * <p>{@link Frame} is a subset of a Dynamo table, and is used to retrieve items
 41  
  * and remove them. {@link Frame} acts as an iterable immutable collection of
 42  
  * items. You can't use {@link Frame#remove(Object)} method directly. Instead,
 43  
  * find the right item using iterator and than remove it with
 44  
  * {@link java.util.Iterator#remove()}.
 45  
  *
 46  
  * <p>To fetch items from Dynamo DB, {@link Frame} uses
 47  
  * {@code Query} operation, with "consistent read" mode turned ON. It fetches
 48  
  * twenty items on every request.
 49  
  *
 50  
  * <p>Keep in mind that Frame object provides a very limited functionality
 51  
  * and is intended to be used in most cases, but not in all of them. When
 52  
  * you need something specific, just get an Amazon DynamoDB client from
 53  
  * a {@link Region} and use Amazon SDK methods directly.
 54  
  *
 55  
  * @author Yegor Bugayenko (yegor@tpc2.com)
 56  
  * @version $Id: 08a7a6747ec8b819bcc43930143dcde7413fa504 $
 57  
  * @since 0.1
 58  
  * @see Item
 59  
  * @see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/QueryAndScan.html">Query and Scan</a>
 60  
  */
 61  
 @Immutable
 62  
 public interface Frame extends Collection<Item> {
 63  
 
 64  
     /**
 65  
      * Refine using this EQ condition argument.
 66  
      * @param name Attribute name
 67  
      * @param value String value expected
 68  
      * @return New frame
 69  
      * @since 0.7.21
 70  
      */
 71  
     Frame where(String name, String value);
 72  
 
 73  
     /**
 74  
      * Refine using this condition.
 75  
      *
 76  
      * <p>It is recommended to use a utility static method
 77  
      * {@link Conditions#equalTo(Object)}, when condition is simply an
 78  
      * equation to a plain string value.
 79  
      *
 80  
      * @param name Attribute name
 81  
      * @param condition The condition
 82  
      * @return New frame
 83  
      */
 84  
     Frame where(String name, Condition condition);
 85  
 
 86  
     /**
 87  
      * Refine using these conditions.
 88  
      *
 89  
      * <p>It is recommended to use {@link Conditions} supplementary class
 90  
      * instead of a raw {@link Map}.
 91  
      *
 92  
      * @param conditions The conditions
 93  
      * @return New frame
 94  
      * @see Conditions
 95  
      */
 96  
     Frame where(Map<String, Condition> conditions);
 97  
 
 98  
     /**
 99  
      * Get back to the table this frame came from.
 100  
      * @return The table
 101  
      */
 102  
     Table table();
 103  
 
 104  
     /**
 105  
      * Change valve for items fetching.
 106  
      * @param valve The valve to go through
 107  
      * @return New frame
 108  
      * @since 0.7.21
 109  
      */
 110  
     Frame through(Valve valve);
 111  
 
 112  
 }