Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quantity item should extend number item #189

Merged
Merged
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 @@ -12,7 +12,6 @@
*/
package org.openhab.automation.jrule.items;

import java.time.ZonedDateTime;
import java.util.Optional;

import org.openhab.automation.jrule.exception.JRuleItemNotFoundException;
Expand All @@ -27,7 +26,7 @@
*
* @author Robert Delbrück - Initial contribution
*/
public interface JRuleQuantityItem extends JRuleItem {
public interface JRuleQuantityItem extends JRuleNumberItem {
static JRuleQuantityItem forName(String itemName) throws JRuleItemNotFoundException {
return JRuleItemRegistry.get(itemName, JRuleInternalQuantityItem.class);
}
Expand Down Expand Up @@ -131,46 +130,10 @@ default void postUpdate(int state) {
}

default JRuleDecimalValue getStateAsDecimal() {
return JRuleEventHandler.get().getValue(getName(), JRuleDecimalValue.class);
return new JRuleDecimalValue(getStateAsQuantity().doubleValue());
}

default JRuleQuantityValue getStateAsQuantity() {
return JRuleEventHandler.get().getValue(getName(), JRuleQuantityValue.class);
}

default Optional<Double> maximumSince(ZonedDateTime timestamp) {
return maximumSince(timestamp, null);
}

Optional<Double> maximumSince(ZonedDateTime timestamp, String persistenceServiceId);

default Optional<Double> minimumSince(ZonedDateTime timestamp) {
return minimumSince(timestamp, null);
}

Optional<Double> minimumSince(ZonedDateTime timestamp, String persistenceServiceId);

default Optional<Double> varianceSince(ZonedDateTime timestamp) {
return varianceSince(timestamp, null);
}

Optional<Double> varianceSince(ZonedDateTime timestamp, String persistenceServiceId);

default Optional<Double> deviationSince(ZonedDateTime timestamp) {
return deviationSince(timestamp, null);
}

Optional<Double> deviationSince(ZonedDateTime timestamp, String persistenceServiceId);

default Optional<Double> averageSince(ZonedDateTime timestamp) {
return averageSince(timestamp, null);
}

Optional<Double> averageSince(ZonedDateTime timestamp, String persistenceServiceId);

default Optional<Double> sumSince(ZonedDateTime timestamp) {
return sumSince(timestamp, null);
}

Optional<Double> sumSince(ZonedDateTime timestamp, String persistenceServiceId);
}