Browse Source

Update javadoc & switch method defaulting.

Closes #5010
Original pull request: #5015
pull/5026/head
Christoph Strobl 5 months ago committed by Mark Paluch
parent
commit
b1ac55cb62
No known key found for this signature in database
GPG Key ID: 55BC6374BAA9D973
  1. 2
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/DefaultIndexOperations.java
  2. 2
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/DefaultReactiveIndexOperations.java
  3. 13
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/IndexOperations.java
  4. 4
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/IndexOperationsAdapter.java
  5. 13
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/ReactiveIndexOperations.java

2
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/DefaultIndexOperations.java

@ -116,7 +116,7 @@ public class DefaultIndexOperations implements IndexOperations { @@ -116,7 +116,7 @@ public class DefaultIndexOperations implements IndexOperations {
@Override
@SuppressWarnings("NullAway")
public String ensureIndex(IndexDefinition indexDefinition) {
public String createIndex(IndexDefinition indexDefinition) {
return execute(collection -> {

2
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/DefaultReactiveIndexOperations.java

@ -84,7 +84,7 @@ public class DefaultReactiveIndexOperations implements ReactiveIndexOperations { @@ -84,7 +84,7 @@ public class DefaultReactiveIndexOperations implements ReactiveIndexOperations {
@Override
@SuppressWarnings("NullAway")
public Mono<String> ensureIndex(IndexDefinition indexDefinition) {
public Mono<String> createIndex(IndexDefinition indexDefinition) {
return mongoOperations.execute(collectionName, collection -> {

13
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/IndexOperations.java

@ -36,19 +36,20 @@ public interface IndexOperations { @@ -36,19 +36,20 @@ public interface IndexOperations {
* @deprecated since 4.5, in favor of {@link #createIndex(IndexDefinition)}.
*/
@Deprecated(since = "4.5", forRemoval = true)
String ensureIndex(IndexDefinition indexDefinition);
default String ensureIndex(IndexDefinition indexDefinition) {
return createIndex(indexDefinition);
}
/**
* Create the index for the provided {@link IndexDefinition} exists for the collection indicated by the entity class.
* If not it will be created.
* Create the index for the provided {@link IndexDefinition} for the collection indicated by the entity class. If the
* index does not exist it will be created. Might error if the collection already defines an index with the same name
* but different settings.
*
* @param indexDefinition must not be {@literal null}.
* @return the index name.
* @since 4.5
*/
default String createIndex(IndexDefinition indexDefinition) {
return ensureIndex(indexDefinition);
}
String createIndex(IndexDefinition indexDefinition);
/**
* Alters the index with given {@literal name}.

4
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/IndexOperationsAdapter.java

@ -41,8 +41,8 @@ public interface IndexOperationsAdapter extends IndexOperations { @@ -41,8 +41,8 @@ public interface IndexOperationsAdapter extends IndexOperations {
return new IndexOperationsAdapter() {
@Override
public String ensureIndex(IndexDefinition indexDefinition) {
return reactiveIndexOperations.ensureIndex(indexDefinition).block();
public String createIndex(IndexDefinition indexDefinition) {
return reactiveIndexOperations.createIndex(indexDefinition).block();
}
@Override

13
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/ReactiveIndexOperations.java

@ -36,19 +36,20 @@ public interface ReactiveIndexOperations { @@ -36,19 +36,20 @@ public interface ReactiveIndexOperations {
* @deprecated since 4.5, in favor of {@link #createIndex(IndexDefinition)}.
*/
@Deprecated(since = "4.5", forRemoval = true)
Mono<String> ensureIndex(IndexDefinition indexDefinition);
default Mono<String> ensureIndex(IndexDefinition indexDefinition) {
return createIndex(indexDefinition);
}
/**
* Create the index for the provided {@link IndexDefinition} exists for the collection indicated by the entity class.
* If not it will be created.
* Create the index for the provided {@link IndexDefinition} for the collection indicated by the entity class. If the
* index does not exist it will be created. Might error if the collection already defines an index with the same name
* but different settings.
*
* @param indexDefinition must not be {@literal null}.
* @return the index name.
* @since 4.5
*/
default Mono<String> createIndex(IndexDefinition indexDefinition) {
return ensureIndex(indexDefinition);
}
Mono<String> createIndex(IndexDefinition indexDefinition);
/**
* Alters the index with given {@literal name}.

Loading…
Cancel
Save