Package org.eclipse.hono.util
Class LimitedResource
java.lang.Object
org.eclipse.hono.util.LimitedResource
- Direct Known Subclasses:
ConnectionDuration
,DataVolume
Common parameters for defining limits on the usage of a resource.
-
Constructor Summary
ModifierConstructorDescriptionprotected
LimitedResource
(Instant effectiveSince, ResourceLimitsPeriod period) Creates an instance. -
Method Summary
Modifier and TypeMethodDescriptionfinal Instant
Gets the point in time at which the limit became or will become effective.final Duration
Gets the already elapsed time of the most recent accounting period.final ResourceLimitsPeriod
Gets the definition of the accounting periods used for this specification.
-
Constructor Details
-
LimitedResource
Creates an instance.- Parameters:
effectiveSince
- The point in time at which the limit became or will become effective.period
- The definition of the accounting periods to be used for this specification ornull
to use the default period definition with modeResourceLimitsPeriod.PeriodMode.monthly
.- Throws:
NullPointerException
- if effective since isnull
.
-
-
Method Details
-
getEffectiveSince
Gets the point in time at which the limit became or will become effective.- Returns:
- The point in time.
-
getPeriod
Gets the definition of the accounting periods used for this specification.The default value of this property is a period definition with mode
ResourceLimitsPeriod.PeriodMode.monthly
.- Returns:
- The period definition.
-
getElapsedAccountingPeriodDuration
Gets the already elapsed time of the most recent accounting period.The value is calculated as the duration for which the most recent accounting period overlaps with the period that begins at the point in time defined by the effective since property and ends at the given point in time.
- Parameters:
end
- The end of the time period to evaluate. Ifnull
, the current point in time is used.- Returns:
- The elapsed time.
-