Skip to content

channelCache.getBoolean

Signature: channelCache.getBoolean(key, defaultValue*)

Returns: Boolean booleanValue - the value associated with the Boolean-typed key

Get the Boolean-typed value associated with the key.

Note

A ClassCastException will be thrown if the value stored at the key is not a Boolean.

Note

defaultValue is optional. When not specified, a NullPointerException is thrown if no value is associated with the key.

Parameters

Type Name Description Default
String key a unique string used to identify the cached value
Boolean defaultValue* (optional) the value to return if no value is associated with the key

Example

// Read a stored Boolean-typed channel-cache entry. The default value is OPTIONAL:

// (1) With a default -- always safe; the default is returned when the key is unset:
var betaMode = channelCache.getBoolean("betaMode", false); // stored value, or false if unset

// (2) Without a default -- returns the stored Boolean directly, but a missing key throws
//     (the null is unboxed to a primitive), so omit the default only when the key is set:
if (channelCache.checkValueExists("featureEnabled")) {
    var featureEnabled = channelCache.getBoolean("featureEnabled"); // the stored Boolean
}