File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
metamodel-runtime/src/commonMain/kotlin/org/modelix/metamodel Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -11,16 +11,18 @@ abstract class ChildAccessor<ChildT : ITypedNode>(
11
11
protected val parent : INode ,
12
12
protected val role : IChildLink ,
13
13
protected val childConcept : IConcept ,
14
- protected val childType : KClass <ChildT >,
14
+ val childType : KClass <ChildT >,
15
15
): Iterable<ChildT> {
16
16
fun isEmpty (): Boolean = ! iterator().hasNext()
17
17
18
18
fun getSize (): Int {
19
19
return this .count()
20
20
}
21
21
22
+ fun untypedNodes () : Iterable <INode > = parent.getChildren(role)
23
+
22
24
override fun iterator (): Iterator <ChildT > {
23
- return parent.getChildren(role ).map {
25
+ return untypedNodes( ).map {
24
26
when (childConcept) {
25
27
is GeneratedConcept <* , * > -> it.typed(childType)
26
28
else -> throw RuntimeException (" Unsupported concept type: ${childConcept::class } (${childConcept.getLongName()} )" )
@@ -44,3 +46,7 @@ abstract class ChildAccessor<ChildT : ITypedNode>(
44
46
removeUnwrapped(child.unwrap())
45
47
}
46
48
}
49
+
50
+ fun <ChildT : ITypedNode > ChildAccessor<ChildT>.filterLoaded (): List <ChildT > {
51
+ return untypedNodes().asSequence().filter { it.isValid }.map { it.typed(childType) }.toList()
52
+ }
You can’t perform that action at this time.
0 commit comments