Skip to content

Commit

Permalink
code format
Browse files Browse the repository at this point in the history
  • Loading branch information
agrgr committed Jan 1, 2025
1 parent 61ca6cf commit 2bf09c4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import static org.springframework.data.aerospike.util.Utils.ctxArrToString;
import static org.springframework.data.aerospike.util.Utils.getExpType;
import static org.springframework.data.aerospike.util.Utils.getExpValOrFail;
import static org.springframework.data.aerospike.util.Utils.objectToBoolean;

public enum FilterOperation {
/**
Expand Down Expand Up @@ -2014,7 +2015,6 @@ protected Filter geoWithinRadius(IndexCollectionType collectionType, Map<Qualifi
}

private static boolean hasMapKeyPlaceholder(Map<QualifierKey, Object> qualifierMap) {
Object mapKeyPlaceholder = qualifierMap.get(MAP_KEY_PLACEHOLDER);
return mapKeyPlaceholder != null && Boolean.parseBoolean(mapKeyPlaceholder.toString());
return objectToBoolean(qualifierMap.get(MAP_KEY_PLACEHOLDER));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
import static org.springframework.data.aerospike.query.qualifier.QualifierKey.PATH;
import static org.springframework.data.aerospike.query.qualifier.QualifierKey.SECOND_VALUE;
import static org.springframework.data.aerospike.query.qualifier.QualifierKey.VALUE;
import static org.springframework.data.aerospike.util.Utils.objectToBoolean;

@SuppressWarnings("unchecked")
public abstract class BaseQualifierBuilder<T extends BaseQualifierBuilder<?>> implements IQualifierBuilder {

protected final Map<QualifierKey, Object> map = new HashMap<>();

public boolean getIgnoreCase() {
Object ignoreCase = map.get(IGNORE_CASE);
return ignoreCase != null && Boolean.parseBoolean(ignoreCase.toString());
return objectToBoolean(map.get(IGNORE_CASE));
}

public FilterOperation getFilterOperation() {
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/org/springframework/data/aerospike/util/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.springframework.dao.InvalidDataAccessResourceUsageException;
import org.springframework.data.aerospike.query.qualifier.Qualifier;
import org.springframework.data.aerospike.repository.query.CriteriaDefinition;
import org.springframework.lang.Nullable;
import org.springframework.util.StringUtils;

import java.io.File;
Expand Down Expand Up @@ -320,4 +321,14 @@ public static void setIntFromConfig(Consumer<Integer> setter, Environment enviro
String value = getProperty(environment, prefix, propertyName);
if (value != null) setter.accept(Integer.parseInt(value));
}

/**
* Convert an Object to boolean.
*
* @param object Can be null
* @return The given object cast to boolean, or false if it is null
*/
public static boolean objectToBoolean(@Nullable Object object) {
return object != null && (boolean) object;
}
}

0 comments on commit 2bf09c4

Please sign in to comment.