Skip to content

UTIL_Limits.LimitCheck

Class

apex
global class UTIL_Limits.LimitCheck

Fluent limit inspector scoped to a single governor limit type. Provides methods to check remaining budget, usage percentage, exhaustion, and threshold proximity.

Since: 1.0


Fields

FieldDescription
global final String labelThe human-readable label for this limit type (e.g.

Methods

MethodDescription
global Boolean isExhausted()Returns whether the limit has been fully consumed (no remaining budget).
global Boolean isNearLimit(Decimal threshold)Returns whether usage has reached or exceeded the given threshold.
global Integer maximum()Returns the maximum allowed units for this limit type.
global Decimal percentUsed()Returns the percentage of the limit consumed as a value between 0.0 and 1.0.
global Integer remaining()Returns the number of limit units remaining before the governor limit is hit.
global Integer used()Returns the number of limit units consumed in this transaction.

Method Details

isExhausted

apex
global Boolean isExhausted()

Returns whether the limit has been fully consumed (no remaining budget).

Returns: Boolean - True when remaining() is less than or equal to zero

Since: 1.0

isNearLimit

apex
global Boolean isNearLimit(Decimal threshold)

Returns whether usage has reached or exceeded the given threshold. Values greater than 1.0 are automatically normalised by dividing by 100 (e.g. 80 becomes 0.8).

Parameters:

  • threshold (Decimal) - The threshold as a decimal (0.0–1.0) or percentage (e.g. 80 for 80%)

Returns: Boolean - True when percentUsed() is at or above the normalised threshold

Since: 1.0

maximum

apex
global Integer maximum()

Returns the maximum allowed units for this limit type.

Returns: Integer - Governor limit maximum

Since: 1.0

percentUsed

apex
global Decimal percentUsed()

Returns the percentage of the limit consumed as a value between 0.0 and 1.0.

Returns: Decimal - Usage percentage (0.0 = none used, 1.0 = fully exhausted)

Since: 1.0

remaining

apex
global Integer remaining()

Returns the number of limit units remaining before the governor limit is hit.

Returns: Integer - Remaining budget (maximum - used)

Since: 1.0

used

apex
global Integer used()

Returns the number of limit units consumed in this transaction.

Returns: Integer - Current usage count

Since: 1.0


Field Details

label

apex
global final String label

Type: String

The human-readable label for this limit type (e.g. "Callouts", "Queries").