Class LimitedResource

java.lang.Object
org.eclipse.hono.util.LimitedResource
Direct Known Subclasses:
ConnectionDuration, DataVolume

public abstract class LimitedResource extends Object
Common parameters for defining limits on the usage of a resource.
  • Constructor Details

    • LimitedResource

      protected LimitedResource(Instant effectiveSince, ResourceLimitsPeriod period)
      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 or null to use the default period definition with mode ResourceLimitsPeriod.PeriodMode.monthly.
      Throws:
      NullPointerException - if effective since is null.
  • Method Details

    • getEffectiveSince

      @HonoTimestamp public final Instant getEffectiveSince()
      Gets the point in time at which the limit became or will become effective.
      Returns:
      The point in time.
    • getPeriod

      public final ResourceLimitsPeriod 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

      public final Duration getElapsedAccountingPeriodDuration(Instant end)
      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. If null, the current point in time is used.
      Returns:
      The elapsed time.