PositiveInt

@SinceKotoolsTypes(version = "1.1")
value class PositiveInt constructor(val value: Int) : Comparable<PositiveInt>

Represents positive integers, including 0.

Constructors

Link copied to clipboard
fun PositiveInt(value: Int)

Returns the value as a positive int, or throws an IllegalArgumentException if the value is strictly negative.

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
@SinceKotoolsTypes(version = "1.3")
infix operator fun compareTo(other: Int): Int
@SinceKotoolsTypes(version = "1.3")
infix operator fun compareTo(other: NonZeroInt): Int
open infix operator override fun compareTo(other: PositiveInt): Int
@SinceKotoolsTypes(version = "1.3")
infix operator fun compareTo(other: StrictlyPositiveInt): Int

Compares this value with the other value for order. Returns 0 if this value equals the other value, a negative number if this value is less than the other value, or a positive number if this value is greater than the other value.

@SinceKotoolsTypes(version = "1.3")
infix operator fun compareTo(other: NegativeInt): Int

Compares this value with the other value for order. Returns 0 if this value equals the other value, or a positive number if this value is greater than the other value.

@SinceKotoolsTypes(version = "1.3")
infix operator fun compareTo(other: StrictlyNegativeInt): Int

Compares this value with the other value and returns a positive number for order.

Link copied to clipboard
operator fun dec(): PositiveInt

Returns this value decremented by 1. If this value is the minimum, it returns the maximum value instead.

Link copied to clipboard
infix operator fun div(other: Int): Int
infix operator fun div(other: NegativeInt): NegativeInt
infix operator fun div(other: PositiveInt): PositiveInt

Divides this value by other, truncating the result to an integer that is closer to 0. Throws an ArithmeticException if the other value equals 0.

infix operator fun div(other: NonZeroInt): Int
infix operator fun div(other: StrictlyNegativeInt): NegativeInt
infix operator fun div(other: StrictlyPositiveInt): PositiveInt

Divides this value by other, truncating the result to an integer that is closer to 0.

Link copied to clipboard
operator fun inc(): PositiveInt

Returns this value incremented by 1. If this value is the maximum, it returns the minimum value instead.

Link copied to clipboard
infix operator fun minus(other: Int): Int
infix operator fun minus(other: NegativeInt): PositiveInt
infix operator fun minus(other: NonZeroInt): Int
infix operator fun minus(other: PositiveInt): Int
infix operator fun minus(other: StrictlyNegativeInt): StrictlyPositiveInt
infix operator fun minus(other: StrictlyPositiveInt): Int

Subtracts the other value from this value.

Link copied to clipboard
infix operator fun plus(other: Int): Int
infix operator fun plus(other: NegativeInt): Int
infix operator fun plus(other: NonZeroInt): Int
infix operator fun plus(other: PositiveInt): PositiveInt
infix operator fun plus(other: StrictlyNegativeInt): Int
infix operator fun plus(other: StrictlyPositiveInt): StrictlyPositiveInt

Adds the other value to this value.

Link copied to clipboard
infix operator fun times(other: Int): Int
infix operator fun times(other: NegativeInt): NegativeInt
infix operator fun times(other: NonZeroInt): Int
infix operator fun times(other: PositiveInt): PositiveInt
infix operator fun times(other: StrictlyNegativeInt): NegativeInt
infix operator fun times(other: StrictlyPositiveInt): PositiveInt

Multiplies this value by the other value.

Link copied to clipboard

Returns this value as a negative int, or throws an IllegalArgumentException if this value is strictly positive.

Link copied to clipboard

Returns this value as a negative int, or returns null if this value is strictly positive.

Link copied to clipboard

Returns this value as a non-zero int, or throws an IllegalArgumentException if this value equals 0.

Link copied to clipboard

Returns this value as a non-zero int, or returns null if this value equals 0.

Link copied to clipboard
@SinceKotoolsTypes(version = "1.2")
fun toNotBlankString(): NotBlankString

Returns the string representation of this value as a not blank string.

Link copied to clipboard

Returns this value as a strictly positive int, or throws an IllegalArgumentException if this value equals 0.

Link copied to clipboard

Returns this value as a strictly positive int, or returns null if this value equals 0.

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
operator fun unaryMinus(): NegativeInt

Returns the negative of this value.

Link copied to clipboard
operator fun unaryPlus(): PositiveInt

Returns this value.

Properties

Link copied to clipboard
val value: Int