[persistence] Use Java 17 features (#15486)

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
This commit is contained in:
Holger Friedrich
2023-08-26 08:56:27 +02:00
committed by GitHub
parent 5b42c4b071
commit 1cf57e7dfe
18 changed files with 118 additions and 107 deletions

View File

@@ -199,12 +199,12 @@ public class MongoDBPersistenceService implements QueryablePersistenceService {
private Object convertValue(State state) {
Object value;
if (state instanceof PercentType) {
value = ((PercentType) state).toBigDecimal().doubleValue();
} else if (state instanceof DateTimeType) {
value = Date.from(((DateTimeType) state).getZonedDateTime().toInstant());
} else if (state instanceof DecimalType) {
value = ((DecimalType) state).toBigDecimal().doubleValue();
if (state instanceof PercentType type) {
value = type.toBigDecimal().doubleValue();
} else if (state instanceof DateTimeType type) {
value = Date.from(type.getZonedDateTime().toInstant());
} else if (state instanceof DecimalType type) {
value = type.toBigDecimal().doubleValue();
} else {
value = state.toString();
}