Introduce QueryCriterion.isEqualTo (Kotlin-friendly alias for is) - #949
Conversation
`isEqualTo` is now the canonical "equals" criterion. It carries the behavior previously implemented by `is`, and `is` delegates to it. `is` is documented as a short form of `isEqualTo`, convenient when working with a `QueryCriterion` from Java. Kotlin callers should prefer `isEqualTo`, because `is` is a reserved word in Kotlin and calling it requires wrapping the method name in backticks. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR introduces QueryCriterion.isEqualTo(V) as a Kotlin-friendly, canonical equality criterion while keeping is(V) as a Java-convenient short form that now delegates to isEqualTo.
Changes:
- Added
QueryCriterion.isEqualTo(V)and madeis(V)delegate to it (preserving behavior and null-checking). - Updated Javadoc/KDoc to guide Kotlin callers to
isEqualTowhile retainingisas the Java short form. - Added tests verifying
isEqualToproduces anEQUALSparameter and matchesis, plus bumped snapshot version and regenerated dependency reports.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
base/src/main/java/io/spine/query/QueryCriterion.java |
Adds isEqualTo() as the canonical equality criterion and makes is() delegate to it with updated docs. |
base/src/test/java/io/spine/query/RecordQueryBuilderTest.java |
Adds coverage ensuring isEqualTo() appends EQUALS and matches is(). |
version.gradle.kts |
Bumps published snapshot version to .421. |
docs/dependencies/pom.xml |
Regenerates dependency POM with the new snapshot version. |
docs/dependencies/dependencies.md |
Regenerates dependency report to reflect the new snapshot version and generation timestamp. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
alexander-yevsyukov
left a comment
There was a problem hiding this comment.
@claude[agent], please see my comments.
|
|
||
| @Nested | ||
| @DisplayName("treat `is` as a short form of `isEqualTo`") | ||
| final class IsEqualToAlias { |
There was a problem hiding this comment.
Please rename the class to IsEqualTo.
| } | ||
|
|
||
| @Nested | ||
| @DisplayName("treat `is` as a short form of `isEqualTo`") |
There was a problem hiding this comment.
Make the display name read: "support filtering by given values".
| } | ||
|
|
||
| @Test | ||
| @DisplayName("producing the same parameter as `is`") |
There was a problem hiding this comment.
Please change the display name to: "providing is alias for isEqualTo".
|
@alexander-yevsyukov Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub. You can ask me to try again later by mentioning me in a new comment. If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: Sorry for the inconvenience! |
…ness The `generateProto`/`generateTestProto` tasks delete `com.google` files from their own output directory in a `doLast` action. That mutation is not reproduced when a task is restored from the Gradle build cache, so a cached restoration leaves an inconsistent descriptor set on the test classpath and `io.spine.type.KnownTypes` loads an incomplete set of types. This intermittently failed ~30-80 tests unrelated to the change under test, in `io.spine.type`, `io.spine.base`, `io.spine.protobuf`, and `io.spine.code` (e.g. PR #949's Ubuntu CI), depending on whether the build cache had a hit for these tasks. It is why `master` (cache miss, executed) stayed green while a branch that restored the cache entry went red. Marking the tasks non-cacheable makes them always execute, so the deletion is always applied and the descriptor set is consistent. Verified: with the build cache enabled, `clean build` now passes 3/3 with `generateTestProto` always executed; previously it failed deterministically when the task was restored from cache. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
| /** | ||
| * Appends an associated query builder with a criterion checking that the value | ||
| * of the associated column equals to the one provided. | ||
| * |
| // downstream descriptor set on the test classpath) that differs from a | ||
| // fresh run, intermittently leaving `io.spine.type.KnownTypes` with an | ||
| // incomplete set of types. Opt this task out of the build cache so it | ||
| // always executes and the deletion is always applied. | ||
| outputs.cacheIf { false } |
Apply the same `equals to` -> `equals` correction to `is` that was made for `isEqualTo`, so the two duplicated summary sentences stay consistent. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- Rename the nested test class `IsEqualToAlias` to `IsEqualTo`. - Class display name -> "support filtering by given values". - `matchIs` display name -> "providing `is` alias for `isEqualTo`". Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
| // fresh run, intermittently leaving `io.spine.type.KnownTypes` with an | ||
| // incomplete set of types. Opt this task out of the build cache so it | ||
| // always executes and the deletion is always applied. |
What
Introduces
QueryCriterion.isEqualTo(V), carrying the behavior previouslyimplemented by
is(V), and makesis(V)delegate to it.isEqualTois now the canonical "equals" criterion.isis documented as ashort form of it — a convenience wrapper for working with a
QueryCriterionfrom Java.
Why
Calling
is(...)from Kotlin is awkward:isis a reserved word there, sothe call has to be wrapped in backticks:
isEqualToreads naturally from both Java and Kotlin, whileisstaysavailable (and convenient) for Java callers.
Changes
QueryCriterion.isEqualTo(V)— new canonical method (null-check +EQUALSparameter), inherited by
EntityCriterionandRecordCriterion.QueryCriterion.is(V)— now delegates toisEqualTo; KDoc/Javadoc updated todescribe it as the Java-convenient short form and to point Kotlin callers to
isEqualTo.RecordQueryBuilderTest— newIsEqualToAliastests:isEqualToappends anEQUALSparameter, and yields the same parameter asis.isis intentionally not deprecated — it remains a first-class Java-sideshort form.
Build fix (unrelated pre-existing CI flake)
While verifying this PR, CI's Build on Ubuntu failed with ~30–80 failures in
packages unrelated to this change (
io.spine.type,io.spine.base,io.spine.protobuf,io.spine.code) —io.spine.type.KnownTypesloading anincomplete descriptor set. Zero
io.spine.querytests were affected.Root cause (reproduced deterministically, independent of the
isEqualTochange):
generateProto/generateTestProtodeletecom.googlefiles fromtheir own output directory in a
doLastaction. That mutation is not reproducedwhen the task is restored from the Gradle build cache, so a cached
restoration leaves an inconsistent descriptor set on the test classpath and
KnownTypesloads a partial type set. This is whymaster(cache miss →executed → green) and a branch that restored the cache entry (cache hit → red)
behaved differently — pure cache-population order, not the code change.
Fix: opt those tasks out of the build cache (
outputs.cacheIf { false }) so theyalways execute and the deletion is always applied. Verified: with the cache
enabled,
clean buildnow passes 3/3 (previously failed deterministically whengenerateTestProtowas restored from cache).Testing
./gradlew :base:test --tests "io.spine.query.*"→ 133/133 pass (incl. thetwo new tests).
./gradlew clean build(cache enabled) → green and deterministic after thebuild fix.
Review notes
spine-code-reviewandreview-docsreviewed theisEqualTochange;spine-code-reviewreviewed the build fix — all APPROVE.2.0.0-SNAPSHOT.420→2.0.0-SNAPSHOT.421.🤖 Generated with Claude Code