Skip to content

Commit

Permalink
[persistence] Handle null value for relative & inverted props o…
Browse files Browse the repository at this point in the history
…f filters (openhab#3727)

Signed-off-by: Florian Hotze <[email protected]>
  • Loading branch information
florian-h05 authored Jul 25, 2023
1 parent e1741cf commit f5a0b37
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.util.Collection;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.items.Item;

/**
Expand All @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit f5a0b37

Please sign in to comment.