[persistence] Handle `null` value for `relative` & `inverted` props of filters (#3727)

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
pull/3733/head
Florian Hotze 2023-07-25 21:07:24 +02:00 committed by GitHub
parent e1741cf61d
commit f5a0b37b3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 6 deletions

View File

@ -15,6 +15,7 @@ package org.openhab.core.persistence.filter;
import java.util.Collection;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.items.Item;
/**
@ -29,10 +30,10 @@ public class PersistenceEqualsFilter extends PersistenceFilter {
private final Collection<String> values;
private final boolean inverted;
public PersistenceEqualsFilter(String name, Collection<String> values, boolean inverted) {
public PersistenceEqualsFilter(String name, Collection<String> values, @Nullable Boolean inverted) {
super(name);
this.values = values;
this.inverted = inverted;
this.inverted = (inverted == null) ? false : inverted;
}
public Collection<String> getValues() {

View File

@ -40,12 +40,12 @@ public class PersistenceIncludeFilter extends PersistenceFilter {
private final boolean inverted;
public PersistenceIncludeFilter(String name, BigDecimal lower, BigDecimal upper, @Nullable String unit,
boolean inverted) {
@Nullable Boolean inverted) {
super(name);
this.lower = lower;
this.upper = upper;
this.unit = (unit == null) ? "" : unit;
this.inverted = inverted;
this.inverted = (inverted == null) ? false : inverted;
}
public BigDecimal getLower() {

View File

@ -48,11 +48,12 @@ public class PersistenceThresholdFilter extends PersistenceFilter {
private final transient Map<String, State> valueCache = new HashMap<>();
public PersistenceThresholdFilter(String name, BigDecimal value, @Nullable String unit, boolean relative) {
public PersistenceThresholdFilter(String name, BigDecimal value, @Nullable String unit,
@Nullable Boolean relative) {
super(name);
this.value = value;
this.unit = (unit == null) ? "" : unit;
this.relative = relative;
this.relative = (relative == null) ? false : relative;
}
public BigDecimal getValue() {