DynamicBuilders.DynamicDuration


@RequiresSchemaVersion(major = 1, minor = 200)
public interface DynamicBuilders.DynamicDuration extends DynamicBuilders.DynamicType


Interface defining a dynamic duration type.

Summary

Public methods

default static @NonNull DynamicBuilders.DynamicDuration
@RequiresSchemaVersion(major = 1, minor = 300)
from(
    @NonNull DynamicDataKey<DynamicBuilders.DynamicDuration> dynamicDataKey
)

Creates a DynamicDuration that is bound to the value of an item of the State.

default static @NonNull DynamicBuilders.DynamicDuration
fromByteArray(@NonNull byte[] byteArray)

Creates a DynamicDuration from a byte array generated by toDynamicDurationByteArray.

default static @NonNull DynamicBuilders.DynamicDuration
fromByteArray(@NonNull byte[] byteArray, int offset, int length)

Creates a DynamicDuration from the provided byte array at the provided offset and length, that was generated by one of the toDynamicDurationByteArray overloads.

default @NonNull DynamicBuilders.DynamicInt32
@RequiresSchemaVersion(major = 1, minor = 200)
getHoursPart()

Returns the number of hours part in the duration as a DynamicInt32.

default @NonNull DynamicBuilders.DynamicInt32
@RequiresSchemaVersion(major = 1, minor = 200)
getIntDaysPart()

Returns the total number of days in a duration as a DynamicInt32.

default @NonNull DynamicBuilders.DynamicInt32
@RequiresSchemaVersion(major = 1, minor = 200)
getMinutesPart()

Returns the number of minutes part in the duration as a DynamicInt32.

default @NonNull DynamicBuilders.DynamicInt32
@RequiresSchemaVersion(major = 1, minor = 200)
getSecondsPart()

Returns the number of seconds part in the duration as a DynamicInt32.

default static @NonNull ConditionScopes.ConditionScope<DynamicBuilders.DynamicDurationDuration>
@RequiresSchemaVersion(major = 1, minor = 200)
onCondition(@NonNull DynamicBuilders.DynamicBool condition)

Bind the value of this DynamicDuration to the result of a conditional expression.

default @NonNull byte[]

Serializes the DynamicDuration into a new byte array that can later be used with fromByteArray.

default int

Serializes the DynamicDuration into the provided byte array, returning the amount of bytes written, that can later be used with DynamicDuration.fromByteArray( byteArray, 0, bytesWritten).

default int
toDynamicDurationByteArray(
    @NonNull byte[] byteArray,
    int offset,
    int length
)

Serializes the DynamicDuration into the provided byte array, returning the amount of bytes written, limited by the provided offset and length, that can later be used with DynamicDuration.fromByteArray(byteArray, offset, bytesWritten).

default @NonNull DynamicBuilders.DynamicInt32
@RequiresSchemaVersion(major = 1, minor = 200)
toIntDays()

Returns the total number of days in a DynamicDuration as a DynamicInt32.

default @NonNull DynamicBuilders.DynamicInt32
@RequiresSchemaVersion(major = 1, minor = 200)
toIntHours()

Returns the total number of hours in a DynamicDuration as a DynamicInt32.

default @NonNull DynamicBuilders.DynamicInt32
@RequiresSchemaVersion(major = 1, minor = 200)
toIntMinutes()

Returns the total number of minutes in a DynamicDuration as a .

default @NonNull DynamicBuilders.DynamicInt32
@RequiresSchemaVersion(major = 1, minor = 200)
toIntSeconds()

Returns the total number of seconds in a DynamicDuration as a .

default static @NonNull DynamicBuilders.DynamicDuration
@RequiresSchemaVersion(major = 1, minor = 200)
withSecondsPrecision(@NonNull Duration duration)

Creates a constant-valued DynamicDuration from a Duration.

Public methods

from

Added in 1.1.0
@RequiresSchemaVersion(major = 1, minor = 300)
default static @NonNull DynamicBuilders.DynamicDuration from(
    @NonNull DynamicDataKey<DynamicBuilders.DynamicDuration> dynamicDataKey
)

Creates a DynamicDuration that is bound to the value of an item of the State.

Parameters
@NonNull DynamicDataKey<DynamicBuilders.DynamicDuration> dynamicDataKey

The source key to a DynamicDataValue with an value.

fromByteArray

Added in 1.0.0
default static @NonNull DynamicBuilders.DynamicDuration fromByteArray(@NonNull byte[] byteArray)

Creates a DynamicDuration from a byte array generated by toDynamicDurationByteArray.

Throws
java.lang.IllegalArgumentException

if the byte array does not contain a valid serialization

fromByteArray

Added in 1.0.0
default static @NonNull DynamicBuilders.DynamicDuration fromByteArray(@NonNull byte[] byteArray, int offset, int length)

Creates a DynamicDuration from the provided byte array at the provided offset and length, that was generated by one of the toDynamicDurationByteArray overloads.

Throws
java.lang.IllegalArgumentException

if the byte array does not contain a valid serialization in the provided offset and length

getHoursPart

Added in 1.0.0
@RequiresSchemaVersion(major = 1, minor = 200)
default @NonNull DynamicBuilders.DynamicInt32 getHoursPart()

Returns the number of hours part in the duration as a DynamicInt32. This represents the absolute value of remaining hours when dividing total hours by hours in a day (24 hours); As an example, the following is equal to DynamicInt32.constant(10)

  DynamicInstant.withSecondsPrecision(Instant.EPOCH)
     .durationUntil(DynamicInstant.withSecondsPrecision(Instant.ofEpochSecond(123456L)))
     .getHoursPart();
Returns
@NonNull DynamicBuilders.DynamicInt32

a new instance of DynamicInt32 containing the result of the operation.

getIntDaysPart

Added in 1.0.0
@RequiresSchemaVersion(major = 1, minor = 200)
default @NonNull DynamicBuilders.DynamicInt32 getIntDaysPart()

Returns the total number of days in a duration as a DynamicInt32. This represents the absolute value of the total number of days in the duration based on the 24 hours day definition. The fraction part of the result will be truncated; As an example, the following is equal to DynamicInt32.constant(1)

  DynamicInstant.withSecondsPrecision(Instant.EPOCH)
     .durationUntil(DynamicInstant.withSecondsPrecision(Instant.ofEpochSecond(123456L)))
     .getIntDaysPart();
Returns
@NonNull DynamicBuilders.DynamicInt32

a new instance of DynamicInt32 containing the result of the operation. Integer overflow can occur if the result of the operation is larger than MAX_VALUE.

getMinutesPart

Added in 1.0.0
@RequiresSchemaVersion(major = 1, minor = 200)
default @NonNull DynamicBuilders.DynamicInt32 getMinutesPart()

Returns the number of minutes part in the duration as a DynamicInt32. This represents the absolute value of remaining minutes when dividing total minutes by minutes in an hour (60 minutes). As an example, the following is equal to DynamicInt32.constant(17)

  DynamicInstant.withSecondsPrecision(Instant.EPOCH)
     .durationUntil(DynamicInstant.withSecondsPrecision(Instant.ofEpochSecond(123456L)))
     .getMinutesPart();
Returns
@NonNull DynamicBuilders.DynamicInt32

a new instance of DynamicInt32 containing the result of the operation.

getSecondsPart

Added in 1.0.0
@RequiresSchemaVersion(major = 1, minor = 200)
default @NonNull DynamicBuilders.DynamicInt32 getSecondsPart()

Returns the number of seconds part in the duration as a DynamicInt32. This represents the absolute value of remaining seconds when dividing total seconds by seconds in a minute (60 seconds); As an example, the following is equal to DynamicInt32.constant(36)

  DynamicInstant.withSecondsPrecision(Instant.EPOCH)
     .durationUntil(DynamicInstant.withSecondsPrecision(Instant.ofEpochSecond(123456L)))
     .getSecondsPart();
Returns
@NonNull DynamicBuilders.DynamicInt32

a new instance of DynamicInt32 containing the result of the operation.

onCondition

Added in 1.0.0
@RequiresSchemaVersion(major = 1, minor = 200)
default static @NonNull ConditionScopes.ConditionScope<DynamicBuilders.DynamicDurationDurationonCondition(@NonNull DynamicBuilders.DynamicBool condition)

Bind the value of this DynamicDuration to the result of a conditional expression. This will use the value given in either use or elseUse depending on the value yielded from condition.

toDynamicDurationByteArray

Added in 1.0.0
default @NonNull byte[] toDynamicDurationByteArray()

Serializes the DynamicDuration into a new byte array that can later be used with fromByteArray.

toDynamicDurationByteArray

Added in 1.0.0
default int toDynamicDurationByteArray(@NonNull byte[] byteArray)

Serializes the DynamicDuration into the provided byte array, returning the amount of bytes written, that can later be used with DynamicDuration.fromByteArray( byteArray, 0, bytesWritten).

Throws
java.lang.IllegalArgumentException

if the byte array is too small

toDynamicDurationByteArray

Added in 1.0.0
default int toDynamicDurationByteArray(
    @NonNull byte[] byteArray,
    int offset,
    int length
)

Serializes the DynamicDuration into the provided byte array, returning the amount of bytes written, limited by the provided offset and length, that can later be used with DynamicDuration.fromByteArray(byteArray, offset, bytesWritten).

Throws
java.lang.IllegalArgumentException

if the byte array is too small

toIntDays

Added in 1.0.0
@RequiresSchemaVersion(major = 1, minor = 200)
default @NonNull DynamicBuilders.DynamicInt32 toIntDays()

Returns the total number of days in a DynamicDuration as a DynamicInt32. The fraction part of the result will be truncated. This is based on the standard definition of a day as 24 hours. As an example, the following is equal to DynamicInt32.constant(1)

  DynamicInstant.withSecondsPrecision(Instant.EPOCH)
     .durationUntil(DynamicInstant.withSecondsPrecision(Instant.ofEpochSecond(123456L)))
     .toIntDays();
Returns
@NonNull DynamicBuilders.DynamicInt32

a new instance of DynamicInt32 containing the result of the operation. Integer overflow can occur if the result of the operation is larger than MAX_VALUE.

toIntHours

Added in 1.0.0
@RequiresSchemaVersion(major = 1, minor = 200)
default @NonNull DynamicBuilders.DynamicInt32 toIntHours()

Returns the total number of hours in a DynamicDuration as a DynamicInt32. The fraction part of the result will be truncated. As an example, the following is equal to DynamicInt32.constant(34)

  DynamicInstant.withSecondsPrecision(Instant.EPOCH)
     .durationUntil(DynamicInstant.withSecondsPrecision(Instant.ofEpochSecond(123456L)))
     .toIntHours();
Returns
@NonNull DynamicBuilders.DynamicInt32

a new instance of DynamicInt32 containing the result of the operation. Integer overflow can occur if the result of the operation is larger than MAX_VALUE.

toIntMinutes

Added in 1.0.0
@RequiresSchemaVersion(major = 1, minor = 200)
default @NonNull DynamicBuilders.DynamicInt32 toIntMinutes()

Returns the total number of minutes in a DynamicDuration as a . The fraction part of the result will be truncated. As an example, the following is equal to DynamicInt32.constant(2057)

  DynamicInstant.withSecondsPrecision(Instant.EPOCH)
     .durationUntil(DynamicInstant.withSecondsPrecision(Instant.ofEpochSecond(123456L)))
     .toIntMinutes();
Returns
@NonNull DynamicBuilders.DynamicInt32

a new instance of DynamicInt32 containing the result of the operation. Integer overflow can occur if the result of the operation is larger than MAX_VALUE.

toIntSeconds

Added in 1.0.0
@RequiresSchemaVersion(major = 1, minor = 200)
default @NonNull DynamicBuilders.DynamicInt32 toIntSeconds()

Returns the total number of seconds in a DynamicDuration as a . As an example, the following is equal to DynamicInt32.constant(123456)

  DynamicInstant.withSecondsPrecision(Instant.EPOCH)
     .durationUntil(DynamicInstant.withSecondsPrecision(Instant.ofEpochSecond(123456L)))
     .toIntSeconds();
Returns
@NonNull DynamicBuilders.DynamicInt32

a new instance of DynamicInt32 containing the result of the operation. Integer overflow can occur if the result of the operation is larger than MAX_VALUE.

withSecondsPrecision

Added in 1.0.0
@RequiresSchemaVersion(major = 1, minor = 200)
default static @NonNull DynamicBuilders.DynamicDuration withSecondsPrecision(@NonNull Duration duration)

Creates a constant-valued DynamicDuration from a Duration. If precision is greater than seconds, then any excess precision information will be dropped.