PersistenceExtensions: Re-add deprecated evolutionRate variant (#4212)

Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
This commit is contained in:
Mark Herwege 2024-05-03 16:59:19 +02:00 committed by GitHub
parent d9685ca9c0
commit 94572aa7c8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1726,6 +1726,26 @@ public class PersistenceExtensions {
return internalEvolutionRateBetween(item, null, timestamp);
}
/**
* Gets the evolution rate of the state of a given {@link Item} between two points in time.
* The default {@link PersistenceService} is used.
*
* @param item the item to get the evolution rate value for
* @param begin the beginning point in time
* @param end the end point in time
* @return the evolution rate in percent (positive and negative) in the given interval, or <code>null</code> if
* there is no default persistence service available, the default persistence service is not a
* {@link QueryablePersistenceService}, or if there are no persisted state for the given <code>item</code>
* at the given interval, or if there is a state but it is zero (which would cause a
* divide-by-zero error)
*/
@Deprecated
public static @Nullable DecimalType evolutionRate(Item item, ZonedDateTime begin, ZonedDateTime end) {
LoggerFactory.getLogger(PersistenceExtensions.class).info(
"The evolutionRate method has been deprecated and will be removed in a future version, use evolutionRateBetween instead.");
return internalEvolutionRateBetween(item, begin, end);
}
/**
* Gets the evolution rate of the state of a given {@link Item} between two points in time.
* The default {@link PersistenceService} is used.
@ -1803,6 +1823,29 @@ public class PersistenceExtensions {
return internalEvolutionRateBetween(item, null, timestamp, serviceId);
}
/**
* Gets the evolution rate of the state of a given {@link Item} between two points in time.
* The {@link PersistenceService} identified by the <code>serviceId</code> is used.
*
* @param item the {@link Item} to get the evolution rate value for
* @param begin the beginning point in time
* @param end the end point in time
* @param serviceId the name of the {@link PersistenceService} to use
* @return the evolution rate in percent (positive and negative) in the given interval, or <code>null</code> if
* the persistence service given by <code>serviceId</code> is not available or is not a
* {@link QueryablePersistenceService}, or if there is no persisted state for the given
* <code>item</code> at the given <code>begin</code> and <code>end</code> using the persistence service
* given by <code>serviceId</code>, or if there is a state but it is zero (which would cause a
* divide-by-zero error)
*/
@Deprecated
public static @Nullable DecimalType evolutionRate(Item item, ZonedDateTime begin, ZonedDateTime end,
String serviceId) {
LoggerFactory.getLogger(PersistenceExtensions.class).info(
"The evolutionRate method has been deprecated and will be removed in a future version, use evolutionRateBetween instead.");
return internalEvolutionRateBetween(item, begin, end, serviceId);
}
/**
* Gets the evolution rate of the state of a given {@link Item} between two points in time.
* The {@link PersistenceService} identified by the <code>serviceId</code> is used.