scoop:scoop.core:0.1.0
src/sequence_inspection.scoop
Selected production source · src/sequence_inspection.scoop
1
internal fun <T> inspectSequence(type: TypeRef, values: List<T>, element: ValueInspector<T>): ValueView =2
ValueObservation(type, Some(values), {3
ValueShape.Sequence(SequenceView(values.size, { index -> element.inspect(values[index]) }))4
})6
internal class ArrayInspector<T>(private val element: ValueInspector<T>) : ValueInspector<Array<T>> {7
public override fun inspect(value: Array<T>): ValueView =8
inspectSequence(typeInfo<Array<T>>().type, value, element)9
}11
internal class MutableArrayInspector<T>(private val element: ValueInspector<T>) : ValueInspector<MutableArray<T>> {12
public override fun inspect(value: MutableArray<T>): ValueView =13
inspectSequence(typeInfo<MutableArray<T>>().type, value, element)14
}16
internal class ArrayListInspector<T>(private val element: ValueInspector<T>) : ValueInspector<ArrayList<T>> {17
public override fun inspect(value: ArrayList<T>): ValueView =18
inspectSequence(typeInfo<ArrayList<T>>().type, value, element)19
}21
/**22
* Observes list elements lazily using an explicit element inspector.23
*/24
public class ListInspector<T> public constructor(private val element: ValueInspector<T>) : ValueInspector<List<T>> {25
/**26
* Creates an indexed sequence view of the supplied list.27
*/28
public override fun inspect(value: List<T>): ValueView =29
inspectSequence(typeInfo<List<T>>().type, value, element)30
}32
/**33
* Observes a mutable list through an explicit element inspector; it does not freeze or copy the34
* list.35
*/36
public class MutableListInspector<T> public constructor(private val element: ValueInspector<T>)37
: ValueInspector<MutableList<T>> {38
/**39
* Creates a lazy sequence view; later element reads can observe mutations.40
*/41
public override fun inspect(value: MutableList<T>): ValueView =42
inspectSequence(typeInfo<MutableList<T>>().type, value, element)43
}