Skip to content

Commit 28c2833

Browse files
committed
Update naming, terms, and missing checks and annotations (#1073)
JAVA-3879
1 parent 5dc067c commit 28c2833

File tree

17 files changed

+53
-86
lines changed

17 files changed

+53
-86
lines changed

driver-core/src/main/com/mongodb/client/model/mql/MqlArray.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ public interface MqlArray<T extends MqlValue> extends MqlValue {
209209
* necessary, then the identity function {@code array.union(v -> v)} should
210210
* be used.
211211
*
212-
* @see MqlMap#entrySet()
212+
* @see MqlMap#entries()
213213
* @param mapper the mapper function.
214214
* @return the resulting value.
215215
* @param <R> the type of the resulting map's values.

driver-core/src/main/com/mongodb/client/model/mql/MqlBoolean.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public interface MqlBoolean extends MqlValue {
6161
* @param ifTrue the ifTrue value.
6262
* @param ifFalse the ifFalse value.
6363
* @return the resulting value.
64-
* @param <T> The type of the resulting expression.
64+
* @param <T> The type of the resulting value.
6565
*/
6666
<T extends MqlValue> T cond(T ifTrue, T ifFalse);
6767

driver-core/src/main/com/mongodb/client/model/mql/MqlDocument.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ default MqlBoolean getBoolean(final String fieldName, final boolean other) {
186186
default MqlNumber getNumber(final String fieldName, final Number other) {
187187
Assertions.notNull("fieldName", fieldName);
188188
Assertions.notNull("other", other);
189-
return getNumber(fieldName, MqlValues.numberToExpression(other));
189+
return getNumber(fieldName, MqlValues.numberToMqlNumber(other));
190190
}
191191

192192
/**
@@ -521,7 +521,7 @@ default MqlDocument getDocument(final String fieldName, final Bson other) {
521521
* @param <T> the type.
522522
*/
523523

524-
<T extends MqlValue> MqlMap<T> asMap();
524+
<T extends MqlValue> MqlMap<@MqlUnchecked(TYPE_ARGUMENT) T> asMap();
525525

526526
/**
527527
* The result of passing {@code this} value to the provided function.

driver-core/src/main/com/mongodb/client/model/mql/MqlEntry.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
import com.mongodb.annotations.Beta;
2020
import com.mongodb.annotations.Sealed;
2121

22-
import static com.mongodb.client.model.mql.MqlValues.of;
23-
2422
/**
2523
* A map entry {@linkplain MqlValue value} in the context
2624
* of the MongoDB Query Language (MQL). An entry has a
@@ -74,16 +72,4 @@ public interface MqlEntry<T extends MqlValue> extends MqlValue {
7472
* @return the resulting entry.
7573
*/
7674
MqlEntry<T> setKey(MqlString key);
77-
78-
/**
79-
* An entry with the same value as {@code this} entry, and the
80-
* specified {@code key}.
81-
*
82-
* @mongodb.server.release 5.0
83-
* @param key the key.
84-
* @return the resulting entry.
85-
*/
86-
default MqlEntry<T> setKey(final String key) {
87-
return setKey(of(key));
88-
}
8975
}

driver-core/src/main/com/mongodb/client/model/mql/MqlExpression.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ final class MqlExpression<T extends MqlValue>
4343
}
4444

4545
/**
46-
* Exposes the evaluated BsonValue so that expressions may be used in
47-
* aggregations. Non-public, as it is intended to be used only by the
46+
* Exposes the evaluated BsonValue so that this mql expression may be used
47+
* in aggregations. Non-public, as it is intended to be used only by the
4848
* {@link MqlExpressionCodec}.
4949
*/
5050
BsonValue toBsonValue(final CodecRegistry codecRegistry) {
@@ -67,11 +67,13 @@ public T getValue() {
6767

6868
@Override
6969
public MqlEntry<T> setValue(final T value) {
70+
Assertions.notNull("value", value);
7071
return setFieldInternal("v", value);
7172
}
7273

7374
@Override
7475
public MqlEntry<T> setKey(final MqlString key) {
76+
Assertions.notNull("key", key);
7577
return setFieldInternal("k", key);
7678
}
7779

@@ -1081,7 +1083,7 @@ public MqlMap<T> merge(final MqlMap<? extends T> other) {
10811083
}
10821084

10831085
@Override
1084-
public MqlArray<MqlEntry<T>> entrySet() {
1086+
public MqlArray<MqlEntry<T>> entries() {
10851087
return newMqlExpression(ast("$objectToArray"));
10861088
}
10871089

driver-core/src/main/com/mongodb/client/model/mql/MqlExpressionCodec.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ final class MqlExpressionCodec implements Codec<MqlExpression> {
3434

3535
@Override
3636
public MqlExpression decode(final BsonReader reader, final DecoderContext decoderContext) {
37-
throw new UnsupportedOperationException("Decoding to an expression is not supported");
37+
throw new UnsupportedOperationException("Decoding to an MqlExpression is not supported");
3838
}
3939

4040
@Override

driver-core/src/main/com/mongodb/client/model/mql/MqlMap.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public interface MqlMap<T extends MqlValue> extends MqlValue {
5555
* @return the resulting value.
5656
*/
5757
default MqlBoolean has(final String key) {
58+
Assertions.notNull("key", key);
5859
return has(of(key));
5960
}
6061

@@ -188,7 +189,7 @@ default MqlMap<T> unset(final String key) {
188189
* @see MqlArray#asMap
189190
* @return the resulting value.
190191
*/
191-
MqlArray<MqlEntry<T>> entrySet();
192+
MqlArray<MqlEntry<T>> entries();
192193

193194
/**
194195
* {@code this} map as a {@linkplain MqlDocument document}.

driver-core/src/main/com/mongodb/client/model/mql/MqlNumber.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public interface MqlNumber extends MqlValue {
5050
*/
5151
default MqlNumber multiply(final Number other) {
5252
Assertions.notNull("other", other);
53-
return this.multiply(MqlValues.numberToExpression(other));
53+
return this.multiply(MqlValues.numberToMqlNumber(other));
5454
}
5555

5656
/**
@@ -73,7 +73,7 @@ default MqlNumber multiply(final Number other) {
7373
*/
7474
default MqlNumber divide(final Number other) {
7575
Assertions.notNull("other", other);
76-
return this.divide(MqlValues.numberToExpression(other));
76+
return this.divide(MqlValues.numberToMqlNumber(other));
7777
}
7878

7979
/**
@@ -92,7 +92,7 @@ default MqlNumber divide(final Number other) {
9292
*/
9393
default MqlNumber add(final Number other) {
9494
Assertions.notNull("other", other);
95-
return this.add(MqlValues.numberToExpression(other));
95+
return this.add(MqlValues.numberToMqlNumber(other));
9696
}
9797

9898
/**
@@ -111,7 +111,7 @@ default MqlNumber add(final Number other) {
111111
*/
112112
default MqlNumber subtract(final Number other) {
113113
Assertions.notNull("other", other);
114-
return this.subtract(MqlValues.numberToExpression(other));
114+
return this.subtract(MqlValues.numberToMqlNumber(other));
115115
}
116116

117117
/**

driver-core/src/main/com/mongodb/client/model/mql/MqlString.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ public interface MqlString extends MqlValue {
4848
MqlString toUpper();
4949

5050
/**
51-
* The concatenation of {@code this} string, followed by
52-
* the {@code other} string.
51+
* The result of appending the {@code other} string to the end of
52+
* {@code this} string (strict concatenation).
5353
*
5454
* @param other the other value.
5555
* @return the resulting value.

driver-core/src/main/com/mongodb/client/model/mql/MqlValue.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
* filtered and summed, in a style similar to that of the Java Stream API:
3939
*
4040
* <pre>{@code
41-
* import static com.mongodb.client.model.expressions.Expressions.current;
41+
* import static com.mongodb.client.model.mql.MqlValues.current;
4242
* MongoCollection<Document> col = ...;
4343
* AggregateIterable<Document> result = col.aggregate(Arrays.asList(
4444
* addFields(new Field<>("result", current()
@@ -254,7 +254,7 @@ public interface MqlValue {
254254
* @return the resulting value.
255255
* @param <T> the type of the values of the resulting map.
256256
*/
257-
<T extends MqlValue> MqlMap<T> isMapOr(MqlMap<@MqlUnchecked(TYPE_ARGUMENT) ? extends T> other);
257+
<T extends MqlValue> MqlMap<@MqlUnchecked(TYPE_ARGUMENT) T> isMapOr(MqlMap<? extends T> other);
258258

259259
/**
260260
* The {@linkplain MqlString string} representation of {@code this} value.

0 commit comments

Comments
 (0)