EvaluationEngines

Collection of contract evaluation engines.

Provides secure registration and lookup of evaluation engines, with tamper detection capabilities.

Thread Safety: This collection is thread-safe for concurrent access.

  • All operations (register, unregister, lookup) are thread-safe

  • Iterators are weakly consistent (may not reflect all concurrent modifications)

  • Engine instances themselves should be thread-safe if accessed concurrently

Example Usage:

val engines = EvaluationEngines()

// Register an engine (using += operator)
engines += ParametricInsuranceEngine()

// Get an engine (using [] operator)
val engine = engines["parametric-insurance"]

// Check if registered (using 'in' operator)
if ("parametric-insurance" in engines) { ... }

// Verify engine integrity
engines.verify("parametric-insurance", expectedHash)

// Iterate over engines
for (engine in engines) { ... }

Properties

Link copied to clipboard
abstract val isEmpty: Boolean

Check if the collection is empty.

Link copied to clipboard
abstract val keys: Set<String>

Get all registered engine IDs. Returns a view of the keys (not a copy).

Link copied to clipboard
abstract val size: Int

Get the number of registered engines.

Link copied to clipboard

Get all registered engines. Returns a view of the values (not a copy).

Functions

Link copied to clipboard
abstract fun clear()

Clear all registered engines.

Link copied to clipboard
abstract operator fun contains(engineId: String): Boolean

Check if an engine is registered.

Link copied to clipboard

Filter engines by a predicate.

Link copied to clipboard
abstract operator fun get(engineId: String): ContractEvaluationEngine?

Get an evaluation engine by ID.

Link copied to clipboard

Get an engine or return default value.

Link copied to clipboard
abstract operator fun iterator(): Iterator<ContractEvaluationEngine>
Link copied to clipboard

Transform engines using a mapping function.

Link copied to clipboard
abstract operator fun minusAssign(engineId: String)

Unregister an evaluation engine.

Link copied to clipboard
abstract operator fun plusAssign(engine: ContractEvaluationEngine)

Register an evaluation engine.

Link copied to clipboard
abstract fun remove(engineId: String): Boolean

Remove an engine and return whether it was removed.

Link copied to clipboard

Get an engine or throw with a clear error message.

Link copied to clipboard
abstract fun verify(engineId: String, expectedHash: String): Boolean

Verify an engine matches the expected implementation hash. Used to detect tampering.

Link copied to clipboard
fun EvaluationEngines.verifyOrThrow(engineId: String, expectedHash: String)

Verify engine integrity or throw SecurityException.