make helper functions in rented instance data class

This commit is contained in:
Minecon724 2024-08-08 13:53:59 +02:00
parent 643006f9c4
commit 0b4bc2e524
Signed by: Minecon724
GPG key ID: 3CCC4D267742C8E8

View file

@ -72,4 +72,26 @@ data class RentedInstance(
)
}
}
/**
* returns whether the instance is running
* this is true also if the instance is stopping
* vice versa, false if stopped or starting
* @return is the instance running
*/
fun isRunning(): Boolean {
return status == "running"
}
fun isStopping(): Boolean {
return status == "running" && targetStatus == "stopped"
}
fun isStarting(): Boolean {
return status == "exited" && targetStatus == "running"
}
fun isChangingState(): Boolean {
return isStopping() || isStarting()
}
}