Polishing.

Reformat code.

See #2750
Original pull request: #4316
This commit is contained in:
Mark Paluch
2023-03-06 14:31:19 +01:00
parent f4b85242d4
commit 0020499d4e
3 changed files with 16 additions and 19 deletions

View File

@@ -18,7 +18,6 @@ package org.springframework.data.mongodb.core.aggregation;
import org.bson.Document;
import org.springframework.data.mongodb.core.aggregation.EvaluationOperators.Expr;
import org.springframework.data.mongodb.core.query.CriteriaDefinition;
import org.springframework.lang.Nullable;
/**
* A {@link CriteriaDefinition criteria} to use {@code $expr} within a
@@ -52,7 +51,6 @@ public class AggregationExpressionCriteria implements CriteriaDefinition {
return new Document(getKey(), expression);
}
@Nullable
@Override
public String getKey() {
return "$expr";

View File

@@ -41,7 +41,6 @@ import org.springframework.data.mapping.PropertyReferenceException;
import org.springframework.data.mapping.context.InvalidPersistentPropertyPath;
import org.springframework.data.mapping.context.MappingContext;
import org.springframework.data.mongodb.MongoExpression;
import org.springframework.data.mongodb.core.aggregation.Aggregation;
import org.springframework.data.mongodb.core.aggregation.AggregationExpression;
import org.springframework.data.mongodb.core.aggregation.RelaxedTypeBasedAggregationOperationContext;
import org.springframework.data.mongodb.core.convert.MappingMongoConverter.NestedDocument;
@@ -563,10 +562,12 @@ public class QueryMapper {
return exampleMapper.getMappedExample((Example<?>) source, entity);
}
if(source instanceof MongoExpression exr) {
if(source instanceof AggregationExpression age) {
return age.toDocument(new RelaxedTypeBasedAggregationOperationContext(entity.getType(), this.mappingContext, this));
}
if (source instanceof AggregationExpression age) {
return age
.toDocument(new RelaxedTypeBasedAggregationOperationContext(entity.getType(), this.mappingContext, this));
}
if (source instanceof MongoExpression exr) {
return exr.toDocument();
}

View File

@@ -158,14 +158,14 @@ public class Criteria implements CriteriaDefinition {
* <pre class="code">
* expr(() -> Document.parse("{ $gt : [ '$spent', '$budget'] }")))
* </pre>
*
*
* or an {@link org.springframework.data.mongodb.core.aggregation.AggregationExpression} which will be subject to
* context (domain type) specific field mapping.
*
* <pre class="code">
* expr(valueOf("amountSpent").greaterThan("budget"))
* </pre>
*
*
* @param expression must not be {@literal null}.
* @return new instance of {@link Criteria}.
* @since 4.1
@@ -211,8 +211,7 @@ public class Criteria implements CriteriaDefinition {
/**
* Creates a criterion using {@literal null} equality comparison which matches documents that either contain the item
* field whose value is {@literal null} or that do not contain the item field.
* <br />
* field whose value is {@literal null} or that do not contain the item field. <br />
* Use {@link #isNullValue()} to only query for documents that contain the field whose value is equal to
* {@link org.bson.BsonType#NULL}. <br />
* Use {@link #exists(boolean)} to query for documents that do (not) contain the field.
@@ -228,10 +227,9 @@ public class Criteria implements CriteriaDefinition {
/**
* Creates a criterion using a {@link org.bson.BsonType} comparison which matches only documents that contain the item
* field whose value is equal to {@link org.bson.BsonType#NULL}.
* <br />
* Use {@link #isNull()} to query for documents that contain the field with a {@literal null} value or do not contain the
* field at all. <br />
* field whose value is equal to {@link org.bson.BsonType#NULL}. <br />
* Use {@link #isNull()} to query for documents that contain the field with a {@literal null} value or do not contain
* the field at all. <br />
* Use {@link #exists(boolean)} to query for documents that do (not) contain the field.
*
* @return this.
@@ -659,8 +657,8 @@ public class Criteria implements CriteriaDefinition {
* Creates a geo-spatial criterion using a {@literal $maxDistance} operation, for use with {@literal $near} or
* {@literal $nearSphere}.
* <p>
* <strong>NOTE:</strong> The unit of measure for distance may depends on the used coordinate representation
* (legacy vs. geoJson) as well as the target operation.
* <strong>NOTE:</strong> The unit of measure for distance may depends on the used coordinate representation (legacy
* vs. geoJson) as well as the target operation.
*
* @param maxDistance radians or meters
* @return this.
@@ -682,8 +680,8 @@ public class Criteria implements CriteriaDefinition {
* Creates a geospatial criterion using a {@literal $minDistance} operation, for use with {@literal $near} or
* {@literal $nearSphere}.
* <p>
* <strong>NOTE:</strong> The unit of measure for distance may depends on the used coordinate representation
* (legacy vs. geoJson) as well as the target operation.
* <strong>NOTE:</strong> The unit of measure for distance may depends on the used coordinate representation (legacy
* vs. geoJson) as well as the target operation.
*
* @param minDistance radians or meters
* @return this.