@@ -44,6 +44,8 @@ interface INode {
44
44
*/
45
45
val concept: IConcept ?
46
46
47
+ fun tryGetConcept (): IConcept ? = getConceptReference()?.tryResolve()
48
+
47
49
/* *
48
50
* Role of this node in its parent node if it exists,or null otherwise.
49
51
*/
@@ -329,11 +331,7 @@ fun INode.resolveProperty(role: String): IProperty {
329
331
* or null, if this concept has no child link or an exception was thrown during concept resolution
330
332
*/
331
333
fun INode.tryResolveChildLink (role : String ): IChildLink ? {
332
- val c = try {
333
- this .concept ? : return null
334
- } catch (e: RuntimeException ) {
335
- return null
336
- }
334
+ val c = this .tryGetConcept() ? : return null
337
335
val allLinks = c.getAllChildLinks()
338
336
return allLinks.find { it.key(this ) == role }
339
337
? : allLinks.find { it.getSimpleName() == role }
@@ -350,11 +348,7 @@ fun INode.resolveChildLinkOrFallback(role: String?): IChildLink {
350
348
* or null, if this node has no reference link or an exception was thrown during concept resolution
351
349
*/
352
350
fun INode.tryResolveReferenceLink (role : String ): IReferenceLink ? {
353
- val c = try {
354
- this .concept ? : return null
355
- } catch (e: RuntimeException ) {
356
- return null
357
- }
351
+ val c = this .tryGetConcept() ? : return null
358
352
val allLinks = c.getAllReferenceLinks()
359
353
return allLinks.find { it.key(this ) == role }
360
354
? : allLinks.find { it.getSimpleName() == role }
@@ -370,11 +364,7 @@ fun INode.resolveReferenceLinkOrFallback(role: String): IReferenceLink {
370
364
* or null, if this node has no concept or an exception was thrown during concept resolution
371
365
*/
372
366
fun INode.tryResolveProperty (role : String ): IProperty ? {
373
- val c = try {
374
- this .concept ? : return null
375
- } catch (e: RuntimeException ) {
376
- return null
377
- }
367
+ val c = this .tryGetConcept() ? : return null
378
368
val allLinks = c.getAllProperties()
379
369
return allLinks.find { it.key(this ) == role }
380
370
? : allLinks.find { it.getSimpleName() == role }
@@ -417,4 +407,3 @@ fun INode.getContainmentLink() = if (this is INodeEx) {
417
407
fun INode.getRoot (): INode = parent?.getRoot() ? : this
418
408
fun INode.isInstanceOf (superConcept : IConcept ? ): Boolean = concept.let { it != null && it.isSubConceptOf(superConcept) }
419
409
fun INode.isInstanceOfSafe (superConcept : IConcept ): Boolean = tryGetConcept()?.isSubConceptOf(superConcept) ? : false
420
- fun INode.tryGetConcept (): IConcept ? = getConceptReference()?.tryResolve()
0 commit comments