Example usage for org.springframework.data.domain Sort.Direction equals

List of usage examples for org.springframework.data.domain Sort.Direction equals

Introduction

In this page you can find the example usage for org.springframework.data.domain Sort.Direction equals.

Prototype

@Override
    public boolean equals(@Nullable Object obj) 

Source Link

Usage

From source file:org.oncoblocks.centromere.mongodb.GenericMongoRepository.java

/**
 * Creates an index on the desired field in the target collection.
 * /*from  www  . ja v  a 2  s  .  co  m*/
 * @param field
 * @param direction
 * @param isUnique
 * @param isSparse
 */
public void createIndex(String field, Sort.Direction direction, boolean isUnique, boolean isSparse) {
    Integer dir = direction.equals(Sort.Direction.ASC) ? 1 : -1;
    DBObject index = new BasicDBObject(field, dir);
    DBObject options = new BasicDBObject();
    if (isSparse)
        options.put("sparse", true);
    if (isUnique)
        options.put("unique", true);
    DBCollection collection = mongoOperations.getCollection(mongoOperations.getCollectionName(model));
    collection.createIndex(index, options);
}