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.


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.

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

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

ParameterTypeDescription
thresholdDecimalThe 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

maximum

apex
global Integer maximum()

Returns the maximum allowed units for this limit type.

Returns Integer — Governor limit maximum

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)

remaining

apex
global Integer remaining()

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

Returns Integer — Remaining budget (maximum - used)

used

apex
global Integer used()

Returns the number of limit units consumed in this transaction.

Returns Integer — Current usage count

Fields

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

label

apex
global final String label

Type: String

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