Example usage for com.amazonaws.services.dynamodbv2.datamodeling DynamoDBQueryExpression setScanIndexForward

List of usage examples for com.amazonaws.services.dynamodbv2.datamodeling DynamoDBQueryExpression setScanIndexForward

Introduction

In this page you can find the example usage for com.amazonaws.services.dynamodbv2.datamodeling DynamoDBQueryExpression setScanIndexForward.

Prototype

public void setScanIndexForward(boolean scanIndexForward) 

Source Link

Document

Sets whether this query scans forward.

Usage

From source file:org.socialsignin.spring.data.dynamodb.repository.query.AbstractDynamoDBQueryCriteria.java

License:Apache License

protected void applySortIfSpecified(DynamoDBQueryExpression<T> queryExpression,
        List<String> permittedPropertyNames) {
    if (permittedPropertyNames.size() > 1) {
        throw new UnsupportedOperationException("Can only sort by at most a single range or index range key");

    }// w ww.ja v  a  2  s  . c  o m
    if (sort != null) {
        boolean sortAlreadySet = false;
        for (Order order : sort) {
            if (permittedPropertyNames.contains(order.getProperty())) {
                if (sortAlreadySet) {
                    throw new UnsupportedOperationException("Sorting by multiple attributes not possible");

                }
                queryExpression.setScanIndexForward(order.getDirection().equals(Direction.ASC));
                sortAlreadySet = true;
            } else {
                throw new UnsupportedOperationException(
                        "Sorting only possible by " + permittedPropertyNames + " for the criteria specified");
            }
        }
    }
}