All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.s2.dsl.automate.ssm.SsmExtention.kt Maven / Gradle / Ivy

There is a newer version: 0.16.0
Show newest version
package s2.dsl.automate.ssm

import s2.dsl.automate.S2Automate
import s2.dsl.automate.S2Transition
import ssm.chaincode.dsl.model.Ssm
import ssm.chaincode.dsl.model.SsmTransition

fun S2Automate.toSsm(permissive: Boolean = false) = Ssm(
	name = this.name,
	transitions = if(permissive) {
		this.transitions.toSsmTransitions(0, 0)
	} else {
		this.transitions.toSsmTransitions()
	}
)

fun Array.toSsmTransitions(
	from: Int? = null, to: Int? = null
) = filter { it.from != null }. map {
	it.toSsmTransition(from, to)
}

fun S2Transition.toSsmTransition(from: Int? = null, to: Int? = null) = SsmTransition(
	from = from ?: this.from!!.position,
	to = to ?: this.to.position,
	role = this.role.name,
	action = this.result?.name ?: this.action.name
)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy