Class

RemoteBoolean

A class representing a remote boolean value.

RevenueCat

RevenueCat

Add subscriptions to your apps in minutes

Ad Get started for free
Android
public open class RemoteBoolean internal constructor(internal val intValue: RemoteInt) :
    BaseRemoteState<Boolean>()

A class representing a remote boolean value.

RemoteBoolean internally stores its state as a RemoteInt, typically using 1 for true and 0 for false. This allows boolean logic to be evaluated efficiently on the remote rendering engine.

Secondary Constructors

@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public constructor(
    value: Boolean
) : this(
    if (value) {
        RemoteInt(1)
    } else {
        RemoteInt(0)
    }
)

Constructor for creating a RemoteBoolean instance from a standard Boolean.

It converts the standard boolean value into a RemoteInt: 1 for true and 0 for false.

Parameters

value The standard boolean value to convert.

Functions

not

public operator fun not(): RemoteBoolean

Logical NOT operator for RemoteBoolean.

This creates a new RemoteBoolean whose value is the logical inverse of this boolean. It achieves this by performing a bitwise XOR operation with 1 on the underlying RemoteInt.

Returns

A new RemoteBoolean representing the logical NOT of this boolean.

toRemoteInt

public fun toRemoteInt(): RemoteInt

Converts this RemoteBoolean to its underlying RemoteInt representation, which evaluates to 1 for true and 0 for false.

Returns

The RemoteInt that holds the boolean\'s value.

select

public fun select(ifTrue: RemoteString, ifFalse: RemoteString): RemoteString

If this RemoteBoolean evaluates to true then the returned value evaluates to ifTrue otherwise it evaluates to ifFalse.

Parameters

ifTrue The RemoteString to be selected if this boolean is true.
ifFalse The RemoteString to be selected if this boolean is false.

Returns

A new RemoteString representing the conditionally selected string.

select

public fun select(ifTrue: RemoteFloat, ifFalse: RemoteFloat): RemoteFloat

If this RemoteBoolean evaluates to true then the returned value evaluates to ifTrue otherwise it evaluates to ifFalse.

Parameters

ifTrue The RemoteFloat to be selected if this boolean is true.
ifFalse The RemoteFloat to be selected if this boolean is false.

Returns

A new RemoteFloat representing the conditionally selected float value.

select

public fun select(ifTrue: RemoteInt, ifFalse: RemoteInt): RemoteInt

If this RemoteBoolean evaluates to true then the returned value evaluates to ifTrue otherwise it evaluates to ifFalse.

Parameters

ifTrue The RemoteInt to be selected if this boolean is true.
ifFalse The RemoteInt to be selected if this boolean is false.

Returns

A new RemoteInt representing the conditionally selected integer value.

select

public fun select(ifTrue: RemoteBoolean, ifFalse: RemoteBoolean): RemoteBoolean

If this RemoteBoolean evaluates to true then the returned value evaluates to ifTrue otherwise it evaluates to ifFalse.

Parameters

ifTrue The RemoteBoolean to be selected if this boolean is true.
ifFalse The RemoteBoolean to be selected if this boolean is false.

Returns

A new RemoteBoolean representing the conditionally selected integer value.

select

@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
    public fun select(@ColorInt ifTrue: Int, @ColorInt ifFalse: Int): RemoteColor

If this RemoteBoolean evaluates to true then the returned value evaluates to ifTrue otherwise it evaluates to ifFalse.

Parameters

ifTrue The color to be selected if this boolean is true (as an Int representing an ARGB color).
ifFalse The color to be selected if this boolean is false (as an Int representing an ARGB color).

Returns

A new RemoteColor representing the conditionally selected color.

select

public fun select(ifTrue: RemoteColor, ifFalse: RemoteColor): RemoteColor

If this RemoteBoolean evaluates to true then the returned value evaluates to ifTrue otherwise it evaluates to ifFalse.

Parameters

ifTrue The RemoteColor to be selected if this boolean is true.
ifFalse The RemoteColor to be selected if this boolean is false.

Returns

A new RemoteColor representing the conditionally selected color.

eq

public infix fun eq(b: RemoteBoolean): RemoteBoolean

Equality operator for RemoteBooleans.

Returns a new RemoteBoolean that evaluates to true if this boolean\'s underlying RemoteInt is equal to another RemoteBoolean\'s underlying RemoteInt.

Parameters

b The other RemoteBoolean to compare with.

Returns

A new RemoteBoolean representing the result of the equality comparison.

ne

public infix fun ne(b: RemoteBoolean): RemoteBoolean

Inequality operator for RemoteBooleans.

Returns a new RemoteBoolean that evaluates to true if this boolean\'s underlying RemoteInt is not equal to another RemoteBoolean\'s underlying RemoteInt.

Parameters

b The other RemoteBoolean to compare with.

Returns

A new RemoteBoolean representing the result of the inequality comparison.

or

public infix fun or(b: RemoteBoolean): RemoteBoolean

Logical OR operator for RemoteBooleans.

Performs a bitwise OR operation on the underlying RemoteInt values of this boolean and the other RemoteBoolean. The result is a new RemoteBoolean.

Parameters

b The other RemoteBoolean to perform the OR operation with.

Returns

A new RemoteBoolean representing the result of the logical OR.

and

public infix fun and(b: RemoteBoolean): RemoteBoolean

Logical AND operator for RemoteBooleans.

Performs a bitwise AND operation on the underlying RemoteInt values of this boolean and the other RemoteBoolean. The result is a new RemoteBoolean.

Parameters

b The other RemoteBoolean to perform the AND operation with.

Returns

A new RemoteBoolean representing the result of the logical AND.

xor

public infix fun xor(b: RemoteBoolean): RemoteBoolean

Logical XOR operator for RemoteBooleans.

Performs a bitwise XOR operation on the underlying RemoteInt values of this boolean and the other RemoteBoolean. The result is a new RemoteBoolean.

Parameters

b The other RemoteBoolean to perform the XOR operation with.

Returns

A new RemoteBoolean representing the result of the logical XOR.

Companion Object

Methods


invoke

Android
public operator fun invoke(value: Boolean): RemoteBoolean

Creates a RemoteBoolean from a literal constant.

Parameters

value The constant Boolean value.

Returns

A RemoteBoolean representing the constant boolean.

createNamedRemoteBoolean

Android
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
        @JvmStatic
        public fun createNamedRemoteBoolean(
            name: String,
            defaultValue: Boolean,
            domain: RemoteState.Domain = RemoteState.Domain.User,
        ): RemoteBoolean

Creates a named RemoteBoolean with an initial value. Named remote booleans can be set via AndroidRemoteContext.setNamedBoolean.

Parameters

name The unique name for this remote boolean.
domain The domain of the named boolean (defaults to RemoteState.Domain.User).
defaultValue The initial Boolean value for the named remote boolean.

Returns

A RemoteBoolean representing the named boolean.