Skip to content

Commit e7a587e

Browse files
Lift containsElement condition restrictions, must work with flex maps.
1 parent d3ac788 commit e7a587e

File tree

2 files changed

+2
-13
lines changed

2 files changed

+2
-13
lines changed

objectbox-java/src/main/java/io/objectbox/Property.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -443,27 +443,19 @@ private void checkNotStringArray() {
443443
}
444444

445445
/**
446-
* For a String array property, matches if at least one element equals the given value
446+
* For a String array or String-key map property, matches if at least one element equals the given value
447447
* using {@link StringOrder#CASE_SENSITIVE StringOrder#CASE_SENSITIVE}.
448448
*
449449
* @see #containsElement(String, StringOrder)
450450
*/
451451
public PropertyQueryCondition<ENTITY> containsElement(String value) {
452-
checkIsStringArray();
453452
return new StringCondition<>(this, Operation.CONTAINS_ELEMENT, value);
454453
}
455454

456455
public PropertyQueryCondition<ENTITY> containsElement(String value, StringOrder order) {
457-
checkIsStringArray();
458456
return new StringCondition<>(this, Operation.CONTAINS_ELEMENT, value, order);
459457
}
460458

461-
private void checkIsStringArray() {
462-
if (String[].class != type) {
463-
throw new IllegalArgumentException("containsElement is only supported for String[] properties.");
464-
}
465-
}
466-
467459
/**
468460
* For a String-key map property, matches if at least one key and value combination equals the given values
469461
* using {@link StringOrder#CASE_SENSITIVE StringOrder#CASE_SENSITIVE}.

objectbox-java/src/main/java/io/objectbox/query/QueryBuilder.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -771,12 +771,9 @@ public QueryBuilder<T> contains(Property<T> property, String value, StringOrder
771771
}
772772

773773
/**
774-
* For a String array property, matches if at least one element equals the given value.
774+
* For a String array or String-key map property, matches if at least one element equals the given value.
775775
*/
776776
public QueryBuilder<T> containsElement(Property<T> property, String value, StringOrder order) {
777-
if (String[].class != property.type) {
778-
throw new IllegalArgumentException("containsElement is only supported for String[] properties.");
779-
}
780777
verifyHandle();
781778
checkCombineCondition(nativeContainsElement(handle, property.getId(), value, order == StringOrder.CASE_SENSITIVE));
782779
return this;

0 commit comments

Comments
 (0)