Search in sources :

Example 21 with ModuleEffectiveStatement

use of org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement in project yangtools by opendaylight.

the class SchemaInferenceStack method pushFirstSchema.

@NonNull
private SchemaTreeEffectiveStatement<?> pushFirstSchema(@NonNull final QName nodeIdentifier) {
    final ModuleEffectiveStatement module = getModule(nodeIdentifier);
    final SchemaTreeEffectiveStatement<?> ret = pushSchema(module, nodeIdentifier);
    currentModule = module;
    return ret;
}
Also used : ModuleEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement) NonNull(org.eclipse.jdt.annotation.NonNull) Objects.requireNonNull(java.util.Objects.requireNonNull)

Example 22 with ModuleEffectiveStatement

use of org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement in project yangtools by opendaylight.

the class SchemaInferenceStack method pushFirstData.

@NonNull
private DataTreeEffectiveStatement<?> pushFirstData(@NonNull final QName nodeIdentifier) {
    final ModuleEffectiveStatement module = getModule(nodeIdentifier);
    final DataTreeEffectiveStatement<?> ret = pushData(module, nodeIdentifier);
    currentModule = module;
    return ret;
}
Also used : ModuleEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement) NonNull(org.eclipse.jdt.annotation.NonNull) Objects.requireNonNull(java.util.Objects.requireNonNull)

Example 23 with ModuleEffectiveStatement

use of org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement in project yangtools by opendaylight.

the class SchemaInferenceStack method resolveDataTreeSteps.

private void resolveDataTreeSteps(@NonNull final QName nodeIdentifier) {
    final EffectiveStatement<?, ?> parent = deque.peekFirst();
    if (parent != null) {
        verify(parent instanceof SchemaTreeAwareEffectiveStatement, "Unexpected parent %s", parent);
        resolveDataTreeSteps((SchemaTreeAwareEffectiveStatement<?, ?>) parent, nodeIdentifier);
        return;
    }
    final ModuleEffectiveStatement module = getModule(nodeIdentifier);
    resolveDataTreeSteps(module, nodeIdentifier);
    currentModule = module;
}
Also used : SchemaTreeAwareEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.SchemaTreeAwareEffectiveStatement) ModuleEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement)

Example 24 with ModuleEffectiveStatement

use of org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement in project yangtools by opendaylight.

the class SchemaInferenceStack method pushFirstGrouping.

@NonNull
private GroupingEffectiveStatement pushFirstGrouping(@NonNull final QName nodeIdentifier) {
    final ModuleEffectiveStatement module = getModule(nodeIdentifier);
    final GroupingEffectiveStatement ret = pushGrouping(module, nodeIdentifier);
    currentModule = module;
    return ret;
}
Also used : GroupingEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.GroupingEffectiveStatement) ModuleEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement) NonNull(org.eclipse.jdt.annotation.NonNull) Objects.requireNonNull(java.util.Objects.requireNonNull)

Example 25 with ModuleEffectiveStatement

use of org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement in project yangtools by opendaylight.

the class SchemaInferenceStack method enterYangData.

/**
 * Lookup a {@code rc:yang-data} by the module namespace where it is defined and its template name.
 *
 * @param namespace Module namespace in which to lookup the template
 * @param name Template name
 * @return Resolved yang-data
 * @throws NullPointerException if any argument is null
 * @throws IllegalArgumentException if the corresponding yang-data cannot be found
 * @throws IllegalStateException if this stack is not empty
 */
@NonNull
public YangDataEffectiveStatement enterYangData(final QNameModule namespace, final String name) {
    final EffectiveStatement<?, ?> parent = deque.peekFirst();
    checkState(parent == null, "Cannot lookup yang-data in a non-empty stack");
    final String templateName = requireNonNull(name);
    final ModuleEffectiveStatement module = effectiveModel.getModuleStatements().get(requireNonNull(namespace));
    checkArgument(module != null, "Module for %s not found", namespace);
    final YangDataEffectiveStatement ret = module.streamEffectiveSubstatements(YangDataEffectiveStatement.class).filter(stmt -> templateName.equals(stmt.argument())).findFirst().orElseThrow(() -> new IllegalArgumentException("yang-data " + templateName + " not present in " + namespace));
    deque.push(ret);
    currentModule = module;
    return ret;
}
Also used : YangDataEffectiveStatement(org.opendaylight.yangtools.rfc8040.model.api.YangDataEffectiveStatement) ModuleEffectiveStatement(org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement) NonNull(org.eclipse.jdt.annotation.NonNull) Objects.requireNonNull(java.util.Objects.requireNonNull)

Aggregations

ModuleEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement)45 Test (org.junit.Test)28 GroupingEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.GroupingEffectiveStatement)20 ContainerEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.ContainerEffectiveStatement)12 NonNull (org.eclipse.jdt.annotation.NonNull)9 Objects.requireNonNull (java.util.Objects.requireNonNull)8 NotificationEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.NotificationEffectiveStatement)8 QNameModule (org.opendaylight.yangtools.yang.common.QNameModule)5 QName (org.opendaylight.yangtools.yang.common.QName)4 LeafEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.LeafEffectiveStatement)4 LeafListEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.LeafListEffectiveStatement)4 SubmoduleEffectiveStatement (org.opendaylight.yangtools.yang.model.api.stmt.SubmoduleEffectiveStatement)4 ModuleStatement (org.opendaylight.yangtools.yang.model.api.stmt.ModuleStatement)3 ImmutableList (com.google.common.collect.ImmutableList)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Entry (java.util.Map.Entry)2 Revision (org.opendaylight.yangtools.yang.common.Revision)2 EffectiveModelContext (org.opendaylight.yangtools.yang.model.api.EffectiveModelContext)2 Module (org.opendaylight.yangtools.yang.model.api.Module)2