-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Javadoc for expressions #1059
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Javadoc for expressions #1059
Conversation
stIncMale
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So far I reviewed only Expression.
driver-core/src/main/com/mongodb/client/model/expressions/Expression.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/expressions/Expression.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/expressions/Expression.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/expressions/Expression.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/expressions/Expression.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/expressions/Expression.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/expressions/Expression.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/expressions/Expression.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/expressions/Expression.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/expressions/Expression.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've never, ever seen this done. Have you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've seen abuses, though not the deprecation of equals in particular. I don't plan to argue for it or keep it, but I was worried that users will mistake it for eq, and was hoping for some creative way to address this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I removed this)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you plan to write here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think:
A value that may be stored in or otherwise operated upon by MongoDB.
Followed by some less-dense variation on:
This API is a language binding: it is a way to use a remote system as if
it were a native Java API. It is a way to represent values and computations
in some "execution context". This API is also a Domain Specific Language: it
is the Java-native variant of MQL, which is used to query MongoDB or (more
broadly) to work with data on MongoDB.
It would be followed by a few paragraphs covering important points and gotchas.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a long description (similar to Stream). Unsure which parts of it, if any, might be moved to the package docs (none are obviously unrelated to the type hierarchy of which this is the root).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know we've been over this, but I'm still having difficulty squaring this sentence with the service that this API actually provides in the context of a MongoDB application. To my ears, this sentence implies that there should be a method like boolean booleanValue() (just like java.lang.Boolean has) on this type, which of course makes no sense. If you had to write another paragraph expanding on what this means, what would it say?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slack discussion: https://mongodb.slack.com/archives/GCKKT44RM/p1671122088820819.
7b0fde5 to
52776b6
Compare
a1bffc6 to
47f7c61
Compare
driver-core/src/main/com/mongodb/client/model/expressions/BooleanExpression.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/expressions/BooleanExpression.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/expressions/IntegerExpression.java
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/expressions/IntegerExpression.java
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/expressions/NumberExpression.java
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/expressions/NumberExpression.java
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/expressions/NumberExpression.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/expressions/DateExpression.java
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/expressions/BooleanExpression.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/expressions/IntegerExpression.java
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/expressions/ArrayExpression.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/expressions/Expressions.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/expressions/Expressions.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/expressions/Expressions.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/expressions/Expressions.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/expressions/Expressions.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/expressions/Expressions.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/expressions/Expressions.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/expressions/Expressions.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/expressions/Expression.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/expressions/Expression.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/expressions/Expression.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/expressions/Expression.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/expressions/Expression.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/expressions/Expression.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/expressions/Expression.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/expressions/Expression.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/expressions/Expressions.java
Outdated
Show resolved
Hide resolved
f6e5a14 to
1fb5893
Compare
9ae661b to
bc48a5c
Compare
|
Rebased. Conflicts on switch/pass (none on MqlEx, which should confirm that the correct signature was used). |
driver-core/src/main/com/mongodb/client/model/expressions/Expression.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/expressions/DateExpression.java
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/expressions/DateExpression.java
Show resolved
Hide resolved
| * @see Expressions | ||
| */ | ||
| @Evolving | ||
| public interface Expression { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to make sure that the following unchecked methods are documented as such (I am using the annotation from #1068 to express what the user asserts when using any of these methods):
| method | annotation |
|---|---|
| Branches.isArray | @MqlUnchecked(TYPE_ARGUMENT) |
| Branches.isMap | @MqlUnchecked(TYPE_ARGUMENT) |
| BranchesIntermediary.isArray | @MqlUnchecked(TYPE_ARGUMENT) |
| BranchesIntermediary.isMap | @MqlUnchecked(TYPE_ARGUMENT) |
| Expressions.currentAsMap | @MqlUnchecked(TYPE_ARGUMENT) |
| Expressions.ofMap(Bson) | @MqlUnchecked(TYPE_ARGUMENT) |
| Expression.isArrayOr | @MqlUnchecked(TYPE_ARGUMENT) |
| Expression.isMapOr | @MqlUnchecked(TYPE_ARGUMENT) |
| ArrayExpression.elementAt | @MqlUnchecked(PRESENT) |
| ArrayExpression.first | @MqlUnchecked(PRESENT) |
| ArrayExpression.last | @MqlUnchecked(PRESENT) |
| MapExpression.get(key) | @MqlUnchecked(PRESENT) |
| DocumentExpression.getField | @MqlUnchecked(PRESENT) |
| DocumentExpression.getBoolean(fieldName) | @MqlUnchecked({PRESENT, TYPE}) |
| DocumentExpression.getNumber(fieldName) | @MqlUnchecked({PRESENT, TYPE}) |
| DocumentExpression.getInteger(fieldName) | @MqlUnchecked({PRESENT, TYPE}) |
| DocumentExpression.getString(fieldName) | @MqlUnchecked({PRESENT, TYPE}) |
| DocumentExpression.getDate(fieldName) | @MqlUnchecked({PRESENT, TYPE}) |
| DocumentExpression.getDocument(fieldName) | @MqlUnchecked({PRESENT, TYPE}) |
| DocumentExpression.getMap(fieldName) | @MqlUnchecked({PRESENT, TYPE}) |
| DocumentExpression.getArray(fieldName) | @MqlUnchecked({PRESENT, TYPE}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will apply this in the final doc PR which covers docs etc. (along with, for example, server version annotations).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, the annotation may be added later. This comment is about documenting all unchecked methods with text (unless you decide not to do so and use only the annotation instead, which is what I would have preferred). The reason I used the annotation in the table is to conveniently express what a user must assert.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please leave unresolved, for easier reference.
driver-core/src/main/com/mongodb/client/model/expressions/Expression.java
Outdated
Show resolved
Hide resolved
1fb5893 to
458d786
Compare
125c935 to
7f00dec
Compare
driver-core/src/main/com/mongodb/client/model/expressions/Expression.java
Outdated
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/client/model/expressions/Expressions.java
Outdated
Show resolved
Hide resolved
e01fa10 to
6713b6d
Compare
| /** | ||
| * Documents places where the API relies on a user asserting | ||
| * something that is not checked at run-time. | ||
| * If the assertion turns out to be false, the API behavior is unspecified. | ||
| * | ||
| * <p>This class is not part of the public API and may be removed or changed at any time</p> | ||
| */ | ||
| @Documented | ||
| @Retention(RetentionPolicy.SOURCE) | ||
| @Target({ElementType.METHOD, ElementType.TYPE_USE}) | ||
| public @interface MqlUnchecked { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note how this annotation is documented as not being a part of the public API despite residing in a non-internal package and being public. This is because we want to generate the API docs for this annotation, but we don't want users to use it either to annotate their code, or to analyze the code at compile time.
Partial work for JAVA-4799
Covers boolean, date, number, integer, and expression, but not others, since PRs are still in progress.
There are naming changes, to parameters especially.