Skip to content
This repository has been archived by the owner on Oct 2, 2023. It is now read-only.

Commit

Permalink
null safe for compare methods (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
rvema authored Nov 15, 2019
1 parent 0405f73 commit 63ac049
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/main/java/com/capitalone/dashboard/util/HygieiaUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
import com.capitalone.dashboard.model.FeatureFlag;
import org.apache.commons.beanutils.BeanUtilsBean;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.jboss.logging.Logger;

import java.lang.reflect.InvocationTargetException;
import java.net.URI;
import java.util.Objects;

public class HygieiaUtils {
private static final Logger LOGGER = Logger.getLogger(HygieiaUtils.class);
Expand Down Expand Up @@ -148,17 +150,19 @@ public static boolean checkForEmptyStringValues(String ... values) {
*/
public static boolean allowSync(FeatureFlag featureFlag, CollectorType collectorType){
if(featureFlag == null) return true;
if(MapUtils.isEmpty(featureFlag.getFlags())) return true;
return !featureFlag.getFlags().get(StringUtils.lowerCase(collectorType.toString()));
String key = StringUtils.lowerCase(collectorType.toString());
if(MapUtils.isEmpty(featureFlag.getFlags()) || Objects.isNull(featureFlag.getFlags().get(key)) ) return true;
return !BooleanUtils.toBoolean(featureFlag.getFlags().get(StringUtils.lowerCase(collectorType.toString())));
}

/*
* If Feature flag is present then check for the collectortype and see if its enabled for AutoDiscover.
*/
public static boolean allowAutoDiscover(FeatureFlag featureFlag, CollectorType collectorType) {
if(featureFlag == null) return false;
if(MapUtils.isEmpty(featureFlag.getFlags())) return false;
return featureFlag.getFlags().get(StringUtils.lowerCase(collectorType.toString()));
String key = StringUtils.lowerCase(collectorType.toString());
if(MapUtils.isEmpty(featureFlag.getFlags()) || Objects.isNull(featureFlag.getFlags().get(key))) return false;
return BooleanUtils.toBoolean(featureFlag.getFlags().get(StringUtils.lowerCase(collectorType.toString())));
}

}

0 comments on commit 63ac049

Please sign in to comment.