DATAMONGO-2155 - Polishing.

Reduce visibility of MappedUpdated to package-protected to avoid exposure. Rename UpdateDefinition.incVersion() to inc().

Original pull request: #625.
This commit is contained in:
Mark Paluch
2019-01-09 16:07:59 +01:00
parent 4be3fe006f
commit 8ad16c1f23
5 changed files with 13 additions and 12 deletions

View File

@@ -83,7 +83,7 @@ public class MappedDocument {
return Filters.eq(ID_FIELD, document.get(ID_FIELD));
}
public MappedUpdate updateWithoutId() {
public UpdateDefinition updateWithoutId() {
return new MappedUpdate(Update.fromDocument(document, ID_FIELD));
}
@@ -94,7 +94,7 @@ public class MappedDocument {
* @author Christoph Strobl
* @since 2.2
*/
public class MappedUpdate implements UpdateDefinition {
class MappedUpdate implements UpdateDefinition {
private final Update delegate;
@@ -122,11 +122,11 @@ public class MappedDocument {
/*
* (non-Javadoc)
* @see org.springframework.data.mongodb.core.query.UpdateDefinition#incVersion(java.lang.String)
* @see org.springframework.data.mongodb.core.query.UpdateDefinition#inc(java.lang.String)
*/
@Override
public void incVersion(String version) {
delegate.incVersion(version);
public void inc(String version) {
delegate.inc(version);
}
/*

View File

@@ -1386,7 +1386,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
MappedDocument mapped = source.toMappedDocument(mongoConverter);
maybeEmitEvent(new BeforeSaveEvent<>(toSave, mapped.getDocument(), collectionName));
MappedUpdate update = mapped.updateWithoutId();
UpdateDefinition update = mapped.updateWithoutId();
UpdateResult result = doUpdate(collectionName, query, update, toSave.getClass(), false, false);
@@ -1622,7 +1622,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
if (persistentEntity != null && persistentEntity.hasVersionProperty()) {
String versionFieldName = persistentEntity.getRequiredVersionProperty().getFieldName();
if (!update.modifies(versionFieldName)) {
update.incVersion(versionFieldName);
update.inc(versionFieldName);
}
}
}

View File

@@ -1674,7 +1674,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
if (persistentEntity != null && persistentEntity.hasVersionProperty()) {
String versionFieldName = persistentEntity.getRequiredVersionProperty().getFieldName();
if (!update.modifies(versionFieldName)) {
update.incVersion(versionFieldName);
update.inc(versionFieldName);
}
}
}

View File

@@ -157,10 +157,10 @@ public class Update implements UpdateDefinition {
/*
* (non-Javadoc)
* @see org.springframework.data.mongodb.core.query.UpdateDefinition#incVersion()
* @see org.springframework.data.mongodb.core.query.UpdateDefinition#inc()
*/
@Override
public void incVersion(String key) {
public void inc(String key) {
inc(key, 1L);
}

View File

@@ -21,6 +21,7 @@ import org.bson.Document;
* Interface fixing must have operations for {@literal updates} as implemented via {@link Update}.
*
* @author Christoph Strobl
* @author Mark Paluch
* @since 2.2
*/
public interface UpdateDefinition {
@@ -47,9 +48,9 @@ public interface UpdateDefinition {
boolean modifies(String key);
/**
* Bump the version of a given {@literal key} by {@code 1}.
* Increment the value of a given {@literal key} by {@code 1}.
*
* @param key must not be {@literal null}.
*/
void incVersion(String key);
void inc(String key);
}