use of org.opendaylight.yangtools.yang.model.api.stmt.BaseEffectiveStatement in project mdsal by opendaylight.
the class AbstractTypeObjectGenerator method bindTypeDefinition.
void bindTypeDefinition(final GeneratorContext context) {
if (baseGen != null) {
// We have registered with baseGen, it will push the type to us
return;
}
final QName arg = type.argument();
if (TypeDefinitions.IDENTITYREF.equals(arg)) {
refType = TypeReference.identityRef(type.streamEffectiveSubstatements(BaseEffectiveStatement.class).map(BaseEffectiveStatement::argument).map(context::resolveIdentity).collect(Collectors.toUnmodifiableList()));
} else if (TypeDefinitions.LEAFREF.equals(arg)) {
final AbstractTypeObjectGenerator<?, ?> targetGenerator = context.resolveLeafref(type.findFirstEffectiveSubstatementArgument(PathEffectiveStatement.class).orElseThrow());
checkArgument(targetGenerator != this, "Effective model contains self-referencing leaf %s", statement().argument());
refType = TypeReference.leafRef(targetGenerator);
} else if (TypeDefinitions.UNION.equals(arg)) {
unionDependencies = new UnionDependencies(type, context);
LOG.trace("Resolved union {} to dependencies {}", type, unionDependencies);
}
LOG.trace("Resolved base {} to generator {}", type, refType);
bindDerivedGenerators(refType);
}
use of org.opendaylight.yangtools.yang.model.api.stmt.BaseEffectiveStatement in project yangtools by opendaylight.
the class IdentityRefSpecificationSupport method createEffective.
@Override
protected EffectiveStatement<QName, IdentityRefSpecification> createEffective(final Current<QName, IdentityRefSpecification> stmt, final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
if (substatements.isEmpty()) {
throw noBase(stmt);
}
final IdentityrefTypeBuilder builder = BaseTypes.identityrefTypeBuilder(stmt.argumentAsTypeQName());
for (final EffectiveStatement<?, ?> subStmt : substatements) {
if (subStmt instanceof BaseEffectiveStatement) {
final QName identityQName = ((BaseEffectiveStatement) subStmt).argument();
final IdentityEffectiveStatement baseIdentity = verifyNotNull(stmt.getFromNamespace(IdentityNamespace.class, identityQName)).buildEffective();
verify(baseIdentity instanceof IdentitySchemaNode, "Statement %s is not an IdentitySchemaNode", baseIdentity);
builder.addIdentity((IdentitySchemaNode) baseIdentity);
}
}
return new TypeEffectiveStatementImpl<>(stmt.declared(), substatements, builder);
}
use of org.opendaylight.yangtools.yang.model.api.stmt.BaseEffectiveStatement in project yangtools by opendaylight.
the class IdentityStatementSupport method createEffective.
@Override
protected IdentityEffectiveStatement createEffective(final Current<QName, IdentityStatement> stmt, final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
if (substatements.isEmpty()) {
return EffectiveStatements.createIdentity(stmt.declared());
}
final List<IdentitySchemaNode> identities = new ArrayList<>();
for (EffectiveStatement<?, ?> substatement : substatements) {
if (substatement instanceof BaseEffectiveStatement) {
final QName qname = ((BaseEffectiveStatement) substatement).argument();
final IdentityEffectiveStatement identity = verifyNotNull(stmt.getFromNamespace(IdentityNamespace.class, qname), "Failed to find identity %s", qname).buildEffective();
verify(identity instanceof IdentitySchemaNode, "%s is not a IdentitySchemaNode", identity);
identities.add((IdentitySchemaNode) identity);
}
}
return EffectiveStatements.createIdentity(stmt.declared(), new FlagsBuilder().setStatus(findFirstArgument(substatements, StatusEffectiveStatement.class, Status.CURRENT)).toFlags(), substatements, ImmutableSet.copyOf(identities));
}
Aggregations