-
-
Notifications
You must be signed in to change notification settings - Fork 429
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
restore previous state and last state change date on startup
Signed-off-by: Mark Herwege <[email protected]>
- Loading branch information
Showing
6 changed files
with
304 additions
and
29 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
...rg.openhab.core.persistence/src/main/java/org/openhab/core/persistence/PersistedItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/** | ||
* Copyright (c) 2010-2024 Contributors to the openHAB project | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.openhab.core.persistence; | ||
|
||
import java.time.Instant; | ||
import java.time.ZonedDateTime; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
import org.eclipse.jdt.annotation.Nullable; | ||
import org.openhab.core.types.State; | ||
|
||
/** | ||
* This interface is used by persistence services to represent the full persisted state of an item, including the | ||
* previous state, and last update and change timestamps. | ||
* It can be used in restoring the full state of an item. | ||
* | ||
* @author Mark Herwege - Initial contribution | ||
*/ | ||
@NonNullByDefault | ||
public interface PersistedItem extends HistoricItem { | ||
|
||
/** | ||
* returns the timestamp of the last state change of the persisted item | ||
* | ||
* @return the timestamp of the last state change of the item | ||
*/ | ||
@Nullable | ||
ZonedDateTime getLastStateChange(); | ||
|
||
/** | ||
* returns the timestamp of the last state change of the persisted item | ||
* | ||
* @return the timestamp of the last state change of the item | ||
*/ | ||
@Nullable | ||
default Instant getLastStateChangeInstant() { | ||
ZonedDateTime lastStateChange = getLastStateChange(); | ||
return lastStateChange != null ? lastStateChange.toInstant() : null; | ||
} | ||
|
||
/** | ||
* returns the last state of the item | ||
* | ||
* @return the last state | ||
*/ | ||
@Nullable | ||
State getLastState(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.