Search in sources :

Example 1 with TypeAware

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

the class SchemaInferenceStack method resolveLeafref.

@Override
public TypeDefinition<?> resolveLeafref(final LeafrefTypeDefinition type) {
    final SchemaInferenceStack tmp = copy();
    LeafrefTypeDefinition current = type;
    while (true) {
        final EffectiveStatement<?, ?> resolved = tmp.resolvePathExpression(current.getPathStatement());
        checkState(resolved instanceof TypeAware, "Unexpected result %s resultion of %s", resolved, type);
        final TypeDefinition<?> result = ((TypedDataSchemaNode) resolved).getType();
        if (result instanceof LeafrefTypeDefinition) {
            checkArgument(result != type, "Resolution of %s loops back onto itself via %s", type, current);
            current = (LeafrefTypeDefinition) result;
        } else {
            return result;
        }
    }
}
Also used : TypedDataSchemaNode(org.opendaylight.yangtools.yang.model.api.TypedDataSchemaNode) LeafrefTypeDefinition(org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition) TypeAware(org.opendaylight.yangtools.yang.model.api.TypeAware)

Aggregations

TypeAware (org.opendaylight.yangtools.yang.model.api.TypeAware)1 TypedDataSchemaNode (org.opendaylight.yangtools.yang.model.api.TypedDataSchemaNode)1 LeafrefTypeDefinition (org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition)1