import org.opendaylight.mdsal.binding.model.ri.BindingTypes;
import org.opendaylight.mdsal.binding.runtime.api.CompositeRuntimeType;
import org.opendaylight.mdsal.binding.runtime.api.RuntimeType;
+import org.opendaylight.yangtools.rfc8040.model.api.YangDataEffectiveStatement;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.AddedByUsesAware;
import org.opendaylight.yangtools.yang.model.api.CopyableNode;
import org.opendaylight.yangtools.yang.model.api.stmt.CaseEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.ChoiceEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.ContainerEffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.FeatureEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.GroupingEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.IdentityEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.InputEffectiveStatement;
// Final step, return child
return ret;
}
- if (ret instanceof AbstractCompositeGenerator) {
+ if (ret instanceof AbstractCompositeGenerator<?, ?> composite) {
// We know how to descend down
- return ((AbstractCompositeGenerator<?, ?>) ret).findGenerator(childStrategy, stmtPath, next);
+ return composite.findGenerator(childStrategy, stmtPath, next);
}
// Yeah, don't know how to continue here
return null;
// Attempt to make progress on child linkage
final var it = unlinkedChildren.iterator();
while (it.hasNext()) {
- final var child = it.next();
- if (child instanceof AbstractExplicitGenerator) {
- if (((AbstractExplicitGenerator<?, ?>) child).linkOriginalGenerator()) {
- progress = LinkageProgress.SOME;
- it.remove();
-
- // If this is a composite generator we need to process is further
- if (child instanceof AbstractCompositeGenerator<?, ?> composite) {
- if (unlinkedComposites.isEmpty()) {
- unlinkedComposites = new ArrayList<>();
- }
- unlinkedComposites.add(composite);
+ if (it.next() instanceof AbstractExplicitGenerator<?, ?> explicit && explicit.linkOriginalGenerator()) {
+ progress = LinkageProgress.SOME;
+ it.remove();
+
+ // If this is a composite generator we need to process is further
+ if (explicit instanceof AbstractCompositeGenerator<?, ?> composite) {
+ if (unlinkedComposites.isEmpty()) {
+ unlinkedComposites = new ArrayList<>();
}
+ unlinkedComposites.add(composite);
}
}
}
if (isOriginalDeclaration(container)) {
tmp.add(new ContainerGenerator(container, this));
}
+ } else if (stmt instanceof FeatureEffectiveStatement feature && this instanceof ModuleGenerator parent) {
+ tmp.add(new FeatureGenerator(feature, parent));
} else if (stmt instanceof GroupingEffectiveStatement grouping) {
tmp.add(new GroupingGenerator(grouping, this));
} else if (stmt instanceof IdentityEffectiveStatement identity) {
tmp.add(new IdentityGenerator(identity, this));
} else if (stmt instanceof InputEffectiveStatement input) {
- tmp.add(this instanceof RpcGenerator ? new RpcInputGenerator(input, this)
- : new InputGenerator(input, this));
+ tmp.add(new InputGenerator(input, this));
} else if (stmt instanceof LeafEffectiveStatement leaf) {
if (!isAugmenting(leaf)) {
tmp.add(new LeafGenerator(leaf, this));
tmp.add(new NotificationGenerator(notification, this));
}
} else if (stmt instanceof OutputEffectiveStatement output) {
- tmp.add(this instanceof RpcGenerator ? new RpcOutputGenerator(output, this)
- : new OutputGenerator(output, this));
+ tmp.add(new OutputGenerator(output, this));
} else if (stmt instanceof RpcEffectiveStatement rpc) {
- tmp.add(new RpcGenerator(rpc, this));
+ if (this instanceof ModuleGenerator module) {
+ tmp.add(new RpcGenerator(rpc, module));
+ }
} else if (stmt instanceof TypedefEffectiveStatement typedef) {
tmp.add(new TypedefGenerator(typedef, this));
} else if (stmt instanceof AugmentEffectiveStatement augment) {
// So here is where we should decide how to handle this augment, and make sure we
// retain information about this being an alias. That will serve as the base for keys
// in the augment -> original map we provide to BindingRuntimeTypes.
- if (this instanceof ModuleGenerator) {
- tmpAug.add(new ModuleAugmentGenerator(augment, this));
+ if (this instanceof ModuleGenerator module) {
+ tmpAug.add(new ModuleAugmentGenerator(augment, module));
}
} else if (stmt instanceof UsesEffectiveStatement uses) {
for (var usesSub : uses.effectiveSubstatements()) {
tmpAug.add(new UsesAugmentGenerator(usesAug, uses, this));
}
}
+ } else if (stmt instanceof YangDataEffectiveStatement yangData) {
+ if (this instanceof ModuleGenerator moduleGen) {
+ tmp.add(YangDataGenerator.of(yangData, moduleGen));
+ }
} else {
LOG.trace("Ignoring statement {}", stmt);
}
// Utility equivalent of (!isAddedByUses(stmt) && !isAugmenting(stmt)). Takes advantage of relationship between
// CopyableNode and AddedByUsesAware
private static boolean isOriginalDeclaration(final EffectiveStatement<?, ?> stmt) {
- if (stmt instanceof AddedByUsesAware aware) {
- if (aware.isAddedByUses()
- || stmt instanceof CopyableNode copyable && copyable.isAugmenting()) {
- return false;
- }
+ if (stmt instanceof AddedByUsesAware aware
+ && (aware.isAddedByUses() || stmt instanceof CopyableNode copyable && copyable.isAugmenting())) {
+ return false;
}
return true;
}