package ru.dbotthepony.mc.otm.capability.matter

private enum class PatternInsertResult {
	FAIL,
	UPDATED,
	INSERTED;
}

sealed class PatternInsertStatus(
	private val status: PatternInsertResult,
	val newState: IPatternState?,
	val oldState: IPatternState?
) {
	val isFailed get() = status == PatternInsertResult.FAIL
	val isUpdated get() = status == PatternInsertResult.UPDATED
	val isInserted get() = status == PatternInsertResult.INSERTED
}

object PatternInsertFailure : PatternInsertStatus(PatternInsertResult.FAIL, null, null)
class PatternInsertUpdated(new: IPatternState, old: IPatternState) : PatternInsertStatus(PatternInsertResult.UPDATED, new, old)
class PatternInsertInserted(new: IPatternState) : PatternInsertStatus(PatternInsertResult.INSERTED, new, null)

@JvmRecord
data class ReplicationTaskAllocation(val task: IReplicationTask<*>, val pattern: IPatternState?)
