import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.mdsal.binding.model.api.Enumeration;
import org.opendaylight.mdsal.binding.model.api.GeneratedTransferObject;
-import org.opendaylight.mdsal.binding.model.api.GeneratedType;
import org.opendaylight.mdsal.binding.model.api.Type;
import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedTypeBuilder;
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;
@Override
final R createExternalRuntimeType(final Type type) {
- verify(type instanceof GeneratedType, "Unexpected type %s", type);
- return createBuilder(statement()).populate(new AugmentResolver(), this).build((GeneratedType) type);
+ return createBuilder(statement()).populate(new AugmentResolver(), this).build(verifyGeneratedType(type));
}
abstract @NonNull CompositeRuntimeTypeBuilder<S, R> createBuilder(S statement);
@Override
final R createInternalRuntimeType(final AugmentResolver resolver, final S statement, final Type type) {
- verify(type instanceof GeneratedType, "Unexpected type %s", type);
- return createBuilder(statement).populate(resolver, this).build((GeneratedType) type);
+ return createBuilder(statement).populate(resolver, this).build(verifyGeneratedType(type));
}
@Override
// 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);
}
}
}
} 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) {
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);
}
// substatements to establish this order.
tmpAug.sort(AbstractAugmentGenerator.COMPARATOR);
tmp.addAll(tmpAug);
-
- // Compatibility FooService and FooListener interfaces, only generated for modules.
- if (this instanceof ModuleGenerator moduleGen) {
- final List<NotificationGenerator> notifs = tmp.stream()
- .filter(NotificationGenerator.class::isInstance)
- .map(NotificationGenerator.class::cast)
- .collect(Collectors.toUnmodifiableList());
- if (!notifs.isEmpty()) {
- tmp.add(new NotificationServiceGenerator(moduleGen, notifs));
- }
-
- final List<RpcGenerator> rpcs = tmp.stream()
- .filter(RpcGenerator.class::isInstance)
- .map(RpcGenerator.class::cast)
- .collect(Collectors.toUnmodifiableList());
- if (!rpcs.isEmpty()) {
- tmp.add(new RpcServiceGenerator(moduleGen, rpcs));
- }
- }
-
return List.copyOf(tmp);
}
// 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() || aware instanceof CopyableNode copyable && copyable.isAugmenting())) {
+ return false;
}
return true;
}