Skip to content

Commit

Permalink
CAY-2807 EntityProperty.inId(..) / ninId(..) - disambiguate method pa…
Browse files Browse the repository at this point in the history
…rameters
  • Loading branch information
stariy95 committed Jun 17, 2024
1 parent 10b18e6 commit 653efe2
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 4 deletions.
1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,32 +61,87 @@ public Expression eqId(Object id) {
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;
System.arraycopy(moreIds, 0, ids, 1, moreIds.length);
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;
System.arraycopy(moreIds, 0, ids, 1, moreIds.length);
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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ public void eqId() {

@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);
}

Expand All @@ -107,13 +107,13 @@ public void neqId() {

@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);
}
}

0 comments on commit 653efe2

Please sign in to comment.