use of org.opendaylight.yangtools.yang.model.api.stmt.CaseEffectiveStatement in project yangtools by opendaylight.
the class YT1208Test method testCaseStatementReuse.
@Test
public void testCaseStatementReuse() throws Exception {
final ModuleEffectiveStatement module = StmtTestUtils.parseYangSource("/bugs/YT1208/case.yang").getModuleStatement(QNameModule.create(XMLNamespace.of("foo")));
final NotificationEffectiveStatement notif = module.findFirstEffectiveSubstatement(NotificationEffectiveStatement.class).orElseThrow();
final CaseEffectiveStatement grpBar = notif.findFirstEffectiveSubstatement(GroupingEffectiveStatement.class).orElseThrow().findFirstEffectiveSubstatement(ChoiceEffectiveStatement.class).orElseThrow().findFirstEffectiveSubstatement(CaseEffectiveStatement.class).orElseThrow();
final CaseEffectiveStatement contBar = notif.findFirstEffectiveSubstatement(ContainerEffectiveStatement.class).orElseThrow().findFirstEffectiveSubstatement(ChoiceEffectiveStatement.class).orElseThrow().findFirstEffectiveSubstatement(CaseEffectiveStatement.class).orElseThrow();
assertSame(contBar, grpBar);
}
use of org.opendaylight.yangtools.yang.model.api.stmt.CaseEffectiveStatement in project yangtools by opendaylight.
the class SchemaInferenceStack method resolveChoiceSteps.
private void resolveChoiceSteps(@NonNull final ChoiceEffectiveStatement parent, @NonNull final QName nodeIdentifier) {
for (EffectiveStatement<?, ?> stmt : parent.effectiveSubstatements()) {
if (stmt instanceof CaseEffectiveStatement) {
final CaseEffectiveStatement caze = (CaseEffectiveStatement) stmt;
final SchemaTreeEffectiveStatement<?> found = caze.findSchemaTreeNode(nodeIdentifier).orElse(null);
if (found instanceof ChoiceEffectiveStatement) {
deque.push(caze);
deque.push(found);
return;
}
}
}
throw new VerifyException("Failed to resolve " + nodeIdentifier + " in " + parent);
}
Aggregations