Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
   *
   * Licensed under the Apache License, Version 2.0 (the "License").
   * You may not use this file except in compliance with the License.
   * A copy of the License is located at
   *
   *  http://aws.amazon.com/apache2.0
   *
  * or in the "license" file accompanying this file. This file is distributed
  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  * express or implied. See the License for the specific language governing
  * permissions and limitations under the License.
  */
 package com.amazonaws.services.dynamodbv2.document;
 
 import java.util.Map;
 import java.util.Set;
 
Used to represent a primary key that has one or multiple key components.
 
 public class PrimaryKey {
     private final Map<StringKeyAttributecomponents = new LinkedHashMap<StringKeyAttribute>();
     
     public PrimaryKey() {}

    
Constructs with the specified key components.
 
     public PrimaryKey(KeyAttribute ...components) {
         addComponents(components);
     }

    
Constructs with a hash key.
 
     public PrimaryKey(String hashKeyNameObject hashKeyValue) {
         addComponent(hashKeyNamehashKeyValue);
     }

    
Constructs with a hash key and a range key.
 
     public PrimaryKey(String hashKeyNameObject hashKeyValue,
             String rangeKeyNameObject rangeKeyValue) {
         if (hashKeyName.equals(rangeKeyName))
             throw new IllegalArgumentException("hashKyeName must not be the same as the rangeKeyName");
         addComponent(hashKeyNamehashKeyValue);
         addComponent(rangeKeyNamerangeKeyValue);
     }

    
Returns all the key components of this primary key.
 
     public Collection<KeyAttributegetComponents() {
         return .values();
     }

    
Returns all the key component names of this primary key as a set.
 
     public Set<StringgetComponentNameSet() {
         return .keySet();
     }

    
Add one or multiple key components to this primary key. Note adding a key component with the same name as that of an existing one would overwrite and become a single key component instead of two.
 
     public PrimaryKey addComponents(KeyAttribute ... components) {
         if (components != null) {
             for (KeyAttribute kacomponents) {
                 InternalUtils.rejectNullInput(ka);
                 this..put(ka.getName(), ka);
             }
         }
         return this;
     }

    
Add a key component to this primary key. Note adding a key component with the same name as that of an existing one would overwrite and become a single key component instead of two.
 
     public PrimaryKey addComponent(String keyAttributeNameObject keyAttributeValue) {
         .put(keyAttributeName
             new KeyAttribute(keyAttributeNamekeyAttributeValue));
         return this;
     }
 
     @Override
    public String toString() {
        return String.valueOf();
    }
New to GrepCode? Check out our FAQ X