Search in sources :

Example 1 with CaseEffectiveStatement

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);
}
Also used : ContainerEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.ContainerEffectiveStatement) CaseEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.CaseEffectiveStatement) GroupingEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.GroupingEffectiveStatement) ChoiceEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.ChoiceEffectiveStatement) NotificationEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.NotificationEffectiveStatement) ModuleEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement) Test(org.junit.Test)

Example 2 with CaseEffectiveStatement

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);
}
Also used : VerifyException(com.google.common.base.VerifyException) CaseEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.CaseEffectiveStatement) ChoiceEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.ChoiceEffectiveStatement)

Aggregations

CaseEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.CaseEffectiveStatement)2 ChoiceEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.ChoiceEffectiveStatement)2 VerifyException (com.google.common.base.VerifyException)1 Test (org.junit.Test)1 ContainerEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.ContainerEffectiveStatement)1 GroupingEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.GroupingEffectiveStatement)1 ModuleEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement)1 NotificationEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.NotificationEffectiveStatement)1