Coverage Report - com.jcabi.dynamo.Item
 
Classes in this File Line Coverage Branch Coverage Complexity
Item
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.AttributeValue;
 33  
 import com.amazonaws.services.dynamodbv2.model.AttributeValueUpdate;
 34  
 import com.jcabi.aspects.Immutable;
 35  
 import java.io.IOException;
 36  
 import java.util.Map;
 37  
 
 38  
 /**
 39  
  * Immutable Amazon DynamoDB item.
 40  
  *
 41  
  * <p>The class is immutable, which means that every call to
 42  
  * {@link #put(String,AttributeValueUpdate)} or {@link #put(Map)} changes
 43  
  * data in Amazon, but doesn't change the object. The object will contain
 44  
  * dirty data right after PUT operation, and should not be used any more.
 45  
  *
 46  
  * @author Yegor Bugayenko (yegor@tpc2.com)
 47  
  * @version $Id: 93cac722e61f6517b28ad800c34a726666f51ce1 $
 48  
  * @since 0.1
 49  
  */
 50  
 @Immutable
 51  
 public interface Item {
 52  
 
 53  
     /**
 54  
      * Get one attribute, fetching directly from AWS (runtime exception if
 55  
      * the attribute is absent, use {@link #has(String)} first).
 56  
      * @param name Attribute name
 57  
      * @return Value
 58  
      * @throws IOException In case of DynamoDB failure
 59  
      */
 60  
     AttributeValue get(String name) throws IOException;
 61  
 
 62  
     /**
 63  
      * Does this attribute exist?
 64  
      * @param name Attribute name
 65  
      * @return TRUE if it exists
 66  
      * @throws IOException In case of DynamoDB failure
 67  
      */
 68  
     boolean has(String name)
 69  
         throws IOException;
 70  
 
 71  
     /**
 72  
      * Change one attribute, immediately saving it to AWS (all other attributes
 73  
      * will be set to NULL, except primary keys).
 74  
      *
 75  
      * <p>Data in memory will become out of sync right after a successful
 76  
      * execution of the method.
 77  
      *
 78  
      * @param name Attribute name
 79  
      * @param value Value to save
 80  
      * @return Values saved
 81  
      * @throws IOException In case of DynamoDB failure
 82  
      * @since 0.12
 83  
      */
 84  
     Map<String, AttributeValue> put(String name, AttributeValueUpdate value)
 85  
         throws IOException;
 86  
 
 87  
     /**
 88  
      * Change all attributes in one call.
 89  
      *
 90  
      * <p>Data in memory will become out of sync right after a successful
 91  
      * execution of the method.
 92  
      *
 93  
      * <p>It is recommended to use {@link AttributeUpdates} supplementary class,
 94  
      * instead of a raw {@link Map}.
 95  
      *
 96  
      * @param attrs Attributes
 97  
      * @return Values saved
 98  
      * @throws IOException In case of DynamoDB failure
 99  
      * @since 0.12
 100  
      */
 101  
     Map<String, AttributeValue> put(Map<String, AttributeValueUpdate> attrs)
 102  
         throws IOException;
 103  
 
 104  
     /**
 105  
      * Get back to the frame it is from.
 106  
      * @return Frame
 107  
      */
 108  
     Frame frame();
 109  
 
 110  
 }