This is an automated email from the ASF dual-hosted git repository.

ntimofeev pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cayenne.git


The following commit(s) were added to refs/heads/master by this push:
     new 653efe20a CAY-2807 EntityProperty.inId(..) / ninId(..) - disambiguate 
method parameters
653efe20a is described below

commit 653efe20a008be0dc80680045309260b9a7563ac
Author: Nikita Timofeev <[email protected]>
AuthorDate: Mon Jun 17 15:04:40 2024 +0400

    CAY-2807 EntityProperty.inId(..) / ninId(..) - disambiguate method 
parameters
---
 RELEASE-NOTES.txt                                  |  1 +
 .../cayenne/exp/property/EntityProperty.java       | 55 ++++++++++++++++++++++
 .../cayenne/exp/property/EntityPropertyTest.java   |  8 ++--
 3 files changed, 60 insertions(+), 4 deletions(-)

diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt
index 8d561261f..f7769100d 100644
--- a/RELEASE-NOTES.txt
+++ b/RELEASE-NOTES.txt
@@ -46,6 +46,7 @@ CAY-2795 Add unit tests for the Json type
 CAY-2802 Upgrade Gradle to 7.6.1
 CAY-2803 Test infrastructure: declarative custom DI modules in ServerCase
 CAY-2805 Stop calling exp parser internally
+CAY-2807 EntityProperty.inId(..) / ninId(..) - disambiguate method parameters
 CAY-2814 Select query iterator() and batchIterator() methods return incorrect 
results
 CAY-2817 Pagination flow refactoring
 CAY-2818 JDK 21 support
diff --git 
a/cayenne/src/main/java/org/apache/cayenne/exp/property/EntityProperty.java 
b/cayenne/src/main/java/org/apache/cayenne/exp/property/EntityProperty.java
index d2d33724e..c8cc078b5 100644
--- a/cayenne/src/main/java/org/apache/cayenne/exp/property/EntityProperty.java
+++ b/cayenne/src/main/java/org/apache/cayenne/exp/property/EntityProperty.java
@@ -61,10 +61,28 @@ public class EntityProperty<E extends Persistent> extends 
BaseProperty<E> implem
         return ExpressionFactory.matchExp(getExpression(), id);
     }
 
+    /**
+     * @deprecated since 5.0 in favour of {@link #idsInCollection(Collection)}
+     */
+    @Deprecated(since = "5.0", forRemoval = true)
     public Expression inId(Collection<Object> ids) {
         return ExpressionFactory.inExp(getExpression(), ids);
     }
 
+    /**
+     * @param ids to use for "IN" expression
+     * @return {@code IN} expression comparing path represented by this 
property with provided ids
+     *
+     * @since 5.0
+     */
+    public Expression idsInCollection(Collection<?> ids) {
+        return ExpressionFactory.inExp(getExpression(), ids);
+    }
+
+    /**
+     * @deprecated since 5.0 in favour of {@link #idsIn(Object...)}
+     */
+    @Deprecated(since = "5.0", forRemoval = true)
     public Expression inId(Object firstId, Object... moreIds) {
         Object[] ids = new Object[moreIds.length + 1];
         ids[0] = firstId;
@@ -72,14 +90,42 @@ public class EntityProperty<E extends Persistent> extends 
BaseProperty<E> implem
         return ExpressionFactory.inExp(getExpression(), ids);
     }
 
+    /**
+     * @param ids to use for "IN" expression
+     * @return {@code IN} expression comparing path represented by this 
property with provided ids
+     *
+     * @since 5.0
+     */
+    public Expression idsIn(Object... ids) {
+        return ExpressionFactory.inExp(getExpression(), ids);
+    }
+
     public Expression neqId(Object id) {
         return ExpressionFactory.noMatchExp(getExpression(), id);
     }
 
+    /**
+     * @deprecated since 5.0 in favour of {@link 
#idsNotInCollection(Collection)}
+     */
+    @Deprecated(since = "5.0", forRemoval = true)
     public Expression ninId(Collection<Object> ids) {
         return ExpressionFactory.notInExp(getExpression(), ids);
     }
 
+    /**
+     * @param ids collection of IDs to use for "{@code NOT IN}" expression
+     * @return {@code NOT IN} expression comparing path represented by this 
property with provided IDs
+     *
+     * @since 5.0
+     */
+    public Expression idsNotInCollection(Collection<?> ids) {
+        return ExpressionFactory.notInExp(getExpression(), ids);
+    }
+
+    /**
+     * @deprecated since 5.0 in favour of {@link #idsNotIn(Object...)}
+     */
+    @Deprecated(since = "5.0", forRemoval = true)
     public Expression ninId(Object firstId, Object... moreIds) {
         Object[] ids = new Object[moreIds.length + 1];
         ids[0] = firstId;
@@ -87,6 +133,15 @@ public class EntityProperty<E extends Persistent> extends 
BaseProperty<E> implem
         return ExpressionFactory.notInExp(getExpression(), ids);
     }
 
+    /**
+     * @param ids to use for "{@code NOT IN}" expression
+     * @return {@code NOT IN} expression comparing path represented by this 
property with provided ids
+     *
+     * @since 5.0
+     */
+    public Expression idsNotIn(Object... ids) {
+        return ExpressionFactory.notInExp(getExpression(), ids);
+    }
 
     /**
      * {@inheritDoc}
diff --git 
a/cayenne/src/test/java/org/apache/cayenne/exp/property/EntityPropertyTest.java 
b/cayenne/src/test/java/org/apache/cayenne/exp/property/EntityPropertyTest.java
index 79f66dac8..a8ba85e69 100644
--- 
a/cayenne/src/test/java/org/apache/cayenne/exp/property/EntityPropertyTest.java
+++ 
b/cayenne/src/test/java/org/apache/cayenne/exp/property/EntityPropertyTest.java
@@ -89,13 +89,13 @@ public class EntityPropertyTest {
 
     @Test
     public void inIdCollection() {
-        Expression exp = property.inId(Arrays.asList(1, 2, 3));
+        Expression exp = property.idsInCollection(Arrays.asList(1, 2, 3));
         assertEquals(ExpressionFactory.exp("path in (1, 2, 3)"), exp);
     }
 
     @Test
     public void inIdVararg() {
-        Expression exp = property.inId(1, 2, 3);
+        Expression exp = property.idsIn(1, 2, 3);
         assertEquals(ExpressionFactory.exp("path in (1, 2, 3)"), exp);
     }
 
@@ -107,13 +107,13 @@ public class EntityPropertyTest {
 
     @Test
     public void ninIdCollection() {
-        Expression exp = property.ninId(Arrays.asList(1, 2, 3));
+        Expression exp = property.idsNotInCollection(Arrays.asList(1, 2, 3));
         assertEquals(ExpressionFactory.exp("path not in (1, 2, 3)"), exp);
     }
 
     @Test
     public void ninIdVararg() {
-        Expression exp = property.ninId(1, 2, 3);
+        Expression exp = property.idsNotIn(1, 2, 3);
         assertEquals(ExpressionFactory.exp("path not in (1, 2, 3)"), exp);
     }
 }
\ No newline at end of file

Reply via email to