DynamoDBHashAndRangeKey.java
/*
* Copyright © 2018 spring-data-dynamodb (https://github.com/prasanna0586/spring-data-dynamodb)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License 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 org.socialsignin.spring.data.dynamodb.repository;
import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbPartitionKey;
import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbSortKey;
import java.io.Serial;
import java.io.Serializable;
/**
* Default implementation of a DynamoDB composite key, comprising both a partition key (hash key)
* and a sort key (range key).
* @author Prasanna Kumar Ramachandran
*/
public class DynamoDBHashAndRangeKey implements Serializable {
/**
* Default constructor creating an empty hash and range key instance.
*/
public DynamoDBHashAndRangeKey() {
}
/**
* Creates a new DynamoDBHashAndRangeKey with the specified hash and range key values.
*
* @param hash the partition key (hash key) value
* @param range the sort key (range key) value
*/
public DynamoDBHashAndRangeKey(Object hash, Object range) {
this.rangeKey = range;
this.hashKey = hash;
}
/**
*
*/
@Serial
private static final long serialVersionUID = 1L;
/** The partition key (hash key) value */
private Object hashKey;
/** The sort key (range key) value */
private Object rangeKey;
/**
* Gets the partition key (hash key) value.
*
* @return the partition key value
*/
@DynamoDbPartitionKey
public Object getHashKey() {
return hashKey;
}
/**
* Sets the partition key (hash key) value.
*
* @param hashKey the partition key value
*/
public void setHashKey(Object hashKey) {
this.hashKey = hashKey;
}
/**
* Gets the sort key (range key) value.
*
* @return the sort key value
*/
@DynamoDbSortKey
public Object getRangeKey() {
return rangeKey;
}
/**
* Sets the sort key (range key) value.
*
* @param rangeKey the sort key value
*/
public void setRangeKey(Object rangeKey) {
this.rangeKey = rangeKey;
}
}