mirror of
https://github.com/danieldemus/openhab-core.git
synced 2025-01-10 13:21:53 +01:00
Simplify boolean expressions (#3971)
Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
parent
ba5647b871
commit
f376606e92
@ -94,7 +94,6 @@ public class ConfigDescriptionParameterGroupBuilder {
|
||||
* @return the desired result
|
||||
*/
|
||||
public ConfigDescriptionParameterGroup build() throws IllegalArgumentException {
|
||||
return new ConfigDescriptionParameterGroup(name, context, advanced != null ? advanced : false, label,
|
||||
description);
|
||||
return new ConfigDescriptionParameterGroup(name, context, advanced != null && advanced, label, description);
|
||||
}
|
||||
}
|
||||
|
@ -91,6 +91,6 @@ public class ConfigurableServiceUtil {
|
||||
|
||||
private static boolean resolveBoolean(Function<String, @Nullable Object> propertyResolver, String key) {
|
||||
Boolean value = (Boolean) propertyResolver.apply(key);
|
||||
return value == null ? false : value.booleanValue();
|
||||
return value != null && value.booleanValue();
|
||||
}
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ public class ConfigDescriptionParameterConverter extends GenericUnmarshaller<Con
|
||||
}
|
||||
|
||||
private Boolean falseIfNull(@Nullable Boolean b) {
|
||||
return b != null ? b : false;
|
||||
return b != null && b;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -41,7 +41,7 @@ public abstract class BaseAddonFinder implements AddonFinder {
|
||||
protected static boolean propertyMatches(Map<String, Pattern> propertyPatternMap, String propertyName,
|
||||
@Nullable String propertyValue) {
|
||||
Pattern pattern = propertyPatternMap.get(propertyName);
|
||||
return pattern == null ? true : propertyValue == null ? false : pattern.matcher(propertyValue).matches();
|
||||
return pattern == null || (propertyValue != null && pattern.matcher(propertyValue).matches());
|
||||
}
|
||||
|
||||
protected volatile List<AddonInfo> addonCandidates = List.of();
|
||||
|
@ -105,8 +105,8 @@ public class ModbusSlaveConnectionFactoryImpl
|
||||
long reconnectAfterMillis = configuration.getReconnectAfterMillis();
|
||||
long connectionAgeMillis = System.currentTimeMillis() - localLastConnected;
|
||||
long disconnectIfConnectedBeforeMillis = disconnectIfConnectedBefore.getOrDefault(localEndpoint, -1L);
|
||||
boolean disconnectSinceTooOldConnection = disconnectIfConnectedBeforeMillis < 0L ? false
|
||||
: localLastConnected <= disconnectIfConnectedBeforeMillis;
|
||||
boolean disconnectSinceTooOldConnection = disconnectIfConnectedBeforeMillis >= 0L
|
||||
&& localLastConnected <= disconnectIfConnectedBeforeMillis;
|
||||
boolean shouldBeDisconnected = (reconnectAfterMillis == 0
|
||||
|| (reconnectAfterMillis > 0 && connectionAgeMillis > reconnectAfterMillis)
|
||||
|| disconnectSinceTooOldConnection);
|
||||
|
@ -164,7 +164,7 @@ public class NumberExtensions {
|
||||
BigDecimal leftValue = numberToBigDecimal(left);
|
||||
BigDecimal rightValue = numberToBigDecimal(right);
|
||||
if (leftValue == null) {
|
||||
return (rightValue != null) ? false : true;
|
||||
return rightValue == null;
|
||||
} else if (rightValue == null) {
|
||||
return true;
|
||||
} else {
|
||||
|
@ -33,7 +33,7 @@ public class PersistenceEqualsFilter extends PersistenceFilter {
|
||||
public PersistenceEqualsFilter(String name, Collection<String> values, @Nullable Boolean inverted) {
|
||||
super(name);
|
||||
this.values = values;
|
||||
this.inverted = (inverted == null) ? false : inverted;
|
||||
this.inverted = inverted != null && inverted;
|
||||
}
|
||||
|
||||
public Collection<String> getValues() {
|
||||
|
@ -45,7 +45,7 @@ public class PersistenceIncludeFilter extends PersistenceFilter {
|
||||
this.lower = lower;
|
||||
this.upper = upper;
|
||||
this.unit = (unit == null) ? "" : unit;
|
||||
this.inverted = (inverted == null) ? false : inverted;
|
||||
this.inverted = inverted != null && inverted;
|
||||
}
|
||||
|
||||
public BigDecimal getLower() {
|
||||
|
@ -53,7 +53,7 @@ public class PersistenceThresholdFilter extends PersistenceFilter {
|
||||
super(name);
|
||||
this.value = value;
|
||||
this.unit = (unit == null) ? "" : unit;
|
||||
this.relative = (relative == null) ? false : relative;
|
||||
this.relative = relative != null && relative;
|
||||
}
|
||||
|
||||
public BigDecimal getValue() {
|
||||
|
@ -169,8 +169,7 @@ public class StateDescriptionFragmentImpl implements StateDescriptionFragment {
|
||||
return null;
|
||||
}
|
||||
final Boolean ro = readOnly;
|
||||
return new StateDescriptionImpl(minimum, maximum, step, pattern, ro == null ? false : ro.booleanValue(),
|
||||
options);
|
||||
return new StateDescriptionImpl(minimum, maximum, step, pattern, ro != null && ro.booleanValue(), options);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -71,7 +71,7 @@ public class UpgradeTool {
|
||||
"Please either set the environment variable ${OPENHAB_USERDATA} or provide a directory through the --dir option.");
|
||||
System.exit(0);
|
||||
} else {
|
||||
boolean force = commandLine.hasOption(OPT_FORCE) ? true : false;
|
||||
boolean force = commandLine.hasOption(OPT_FORCE);
|
||||
|
||||
Upgrader upgrader = new Upgrader(baseDir, force);
|
||||
if (!commandLine.hasOption(OPT_COMMAND)
|
||||
|
Loading…
Reference in New Issue
Block a user