import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.util.Set;
import java.util.stream.Collectors;
import org.eclipse.jdt.annotation.NonNull;
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
groupings = List.copyOf(tmp);
}
+ // Iterate over a some generators recursively, linking them to the GroupingGenerators they use. GroupingGenerators
+ // are skipped and added to unprocessedGroupings for later processing.
+ final void linkUsedGroupings(final Set<GroupingGenerator> skippedChildren) {
+ // Link to used groupings IFF we have a corresponding generated Java class
+ switch (classPlacement()) {
+ case NONE:
+ case PHANTOM:
+ break;
+ default:
+ for (var grouping : groupings()) {
+ grouping.addUser(this);
+ }
+ }
+
+ for (var child : childGenerators) {
+ if (child instanceof GroupingGenerator grouping) {
+ skippedChildren.add(grouping);
+ } else if (child instanceof AbstractCompositeGenerator<?, ?> composite) {
+ composite.linkUsedGroupings(skippedChildren);
+ }
+ }
+ }
+
final void startUsesAugmentLinkage(final List<AugmentRequirement> requirements) {
for (var child : childGenerators) {
if (child instanceof UsesAugmentGenerator uses) {
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);
}
// CopyableNode and AddedByUsesAware
private static boolean isOriginalDeclaration(final EffectiveStatement<?, ?> stmt) {
if (stmt instanceof AddedByUsesAware aware
- && (aware.isAddedByUses() || stmt instanceof CopyableNode copyable && copyable.isAugmenting())) {
+ && (aware.isAddedByUses() || aware instanceof CopyableNode copyable && copyable.isAugmenting())) {
return false;
}
return true;