Skip to content

Commit

Permalink
Fix comparison of filters.
Browse files Browse the repository at this point in the history
Signed-off-by: Maximilian Chrzan <[email protected]>
Signed-off-by: mchrza <[email protected]>
  • Loading branch information
mchrza committed Dec 9, 2024
1 parent eca4a89 commit 0e1361b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonView;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.here.xyz.XyzSerializable;
import com.here.xyz.XyzSerializable.Internal;
import com.here.xyz.XyzSerializable.Public;
import com.here.xyz.XyzSerializable.Static;
Expand Down Expand Up @@ -54,7 +56,11 @@ public PropertiesQuery getPropertyFilter() {

public void setPropertyFilter(Object propertyFilter) {
if (propertyFilter instanceof ArrayList propFilter){
this.propertyFilter = new PropertiesQuery(propFilter);
try {
this.propertyFilter = XyzSerializable.deserialize(XyzSerializable.serialize(propFilter), PropertiesQuery.class);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}
else if (propertyFilter instanceof String propFilter) {
this.propertyFilter = PropertiesQuery.fromString(propFilter);
Expand Down
19 changes: 17 additions & 2 deletions xyz-models/src/main/java/com/here/xyz/events/PropertyQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.here.xyz.XyzSerializable;

import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
Expand All @@ -29,7 +31,7 @@

@JsonIgnoreProperties(ignoreUnknown = true)
@JsonTypeName(value = "PropertyQuery")
public class PropertyQuery {
public class PropertyQuery implements XyzSerializable {

private String key;
private QueryOperation operation;
Expand Down Expand Up @@ -173,7 +175,20 @@ else if (thisValue instanceof BigDecimal && otherValue instanceof Long) {
if (!thisValue.equals(new BigDecimal((Long) otherValue))) {
return false;
}
} else if (!thisValue.equals(otherValue)) {
}
// Convert Integer to Long and BigDecimal
else if (thisValue instanceof Integer && otherValue instanceof BigDecimal) {
if (!new BigDecimal((Integer) thisValue).equals(otherValue)) {
return false;
}
}
// Convert BigDecimal to Integer and compare
else if (thisValue instanceof BigDecimal && otherValue instanceof Integer) {
if (!thisValue.equals(new BigDecimal((Integer) otherValue))) {
return false;
}
}
else if (!thisValue.equals(otherValue)) {
return false; // If the values are not equal, return false
}
}
Expand Down

0 comments on commit 0e1361b

Please sign in to comment.