Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

If state conversion fails use original value instead of null #3546

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,13 @@ public void setState(State state) {
applyState(state);
}
} else {
applyState(state.as(HSBType.class));
// try conversion
State convertedState = state.as(HSBType.class);
if (convertedState != null) {
applyState(convertedState);
} else {
applyState(state);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,13 @@ public List<Class<? extends Command>> getAcceptedCommandTypes() {
*/
@Override
public void setState(State state) {
applyState(state.as(PercentType.class));
// try conversion
State convertedState = state.as(PercentType.class);
if (convertedState != null) {
applyState(convertedState);
} else {
applyState(state);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,13 @@ public void send(PercentType command) {
*/
@Override
public void setState(State state) {
applyState(state.as(PercentType.class));
// try conversion
State convertedState = state.as(PercentType.class);
if (convertedState != null) {
applyState(convertedState);
} else {
applyState(state);
}
}

}