FakeClock.Builder


public final class FakeClock.Builder


A builder for FakeClock instances.

Summary

Public constructors

Creates a new builder for FakeClock instances.

Public methods

FakeClock

Builds a FakeClock instance.

FakeClock.Builder

Sets the time the system was booted since the Unix Epoch, in milliseconds.

FakeClock.Builder

Sets the initial elapsed time since the boot time, in milliseconds.

FakeClock.Builder
@CanIgnoreReturnValue
setIsAutoAdvancing(boolean isAutoAdvancing)

Sets whether the clock should automatically advance the time to the time of the next message that is due to be sent.

FakeClock.Builder
@CanIgnoreReturnValue
setMaxAutoAdvancingTimeDiffMs(long maxAutoAdvancingTimeDiffMs)

Sets the maximum time difference between two messages that the fake clock will automatically advance.

Public constructors

Builder

public Builder()

Creates a new builder for FakeClock instances.

Public methods

build

public FakeClock build()

Builds a FakeClock instance.

Returns
FakeClock

The built FakeClock instance.

setBootTimeMs

@CanIgnoreReturnValue
public FakeClock.Builder setBootTimeMs(long bootTimeMs)

Sets the time the system was booted since the Unix Epoch, in milliseconds.

The default value is 0.

Parameters
long bootTimeMs

The time the system was booted since the Unix Epoch, in milliseconds.

Returns
FakeClock.Builder

This builder.

setInitialTimeMs

@CanIgnoreReturnValue
public FakeClock.Builder setInitialTimeMs(long initialTimeMs)

Sets the initial elapsed time since the boot time, in milliseconds.

The default value is 0.

Parameters
long initialTimeMs

The initial elapsed time since the boot time, in milliseconds.

Returns
FakeClock.Builder

This builder.

setIsAutoAdvancing

@CanIgnoreReturnValue
public FakeClock.Builder setIsAutoAdvancing(boolean isAutoAdvancing)

Sets whether the clock should automatically advance the time to the time of the next message that is due to be sent.

The default value is false.

Parameters
boolean isAutoAdvancing

Whether the clock should automatically advance the time.

Returns
FakeClock.Builder

This builder.

setMaxAutoAdvancingTimeDiffMs

@CanIgnoreReturnValue
public FakeClock.Builder setMaxAutoAdvancingTimeDiffMs(long maxAutoAdvancingTimeDiffMs)

Sets the maximum time difference between two messages that the fake clock will automatically advance.

The default value is DEFAULT_MAX_AUTO_ADVANCING_TIME_DIFF_MS.

Parameters
long maxAutoAdvancingTimeDiffMs

The maximum time difference in milliseconds.

Returns
FakeClock.Builder

This builder.