use of org.opendaylight.mdsal.binding.generator.impl.reactor.ModuleGenerator in project mdsal by opendaylight.
the class BindingRuntimeTypesFactory method indexModules.
private void indexModules(final Map<QNameModule, ModuleGenerator> moduleGens) {
for (var entry : moduleGens.entrySet()) {
final var modGen = entry.getValue();
// index the module's runtime type
safePut(modules, "modules", entry.getKey(), modGen.runtimeType().orElseThrow());
// index module's identities and RPC input/outputs
for (var gen : modGen) {
if (gen instanceof IdentityGenerator) {
((IdentityGenerator) gen).runtimeType().ifPresent(identity -> {
safePut(identities, "identities", identity.statement().argument(), identity);
});
}
// FIXME: do not collect these once we they generate a proper RuntimeType
if (gen instanceof RpcGenerator) {
final QName rpcName = ((RpcGenerator) gen).statement().argument();
for (var subgen : gen) {
if (subgen instanceof RpcInputGenerator) {
((RpcInputGenerator) subgen).runtimeType().ifPresent(input -> rpcInputs.put(rpcName, input));
} else if (subgen instanceof RpcOutputGenerator) {
((RpcOutputGenerator) subgen).runtimeType().ifPresent(output -> rpcOutputs.put(rpcName, output));
}
}
}
}
}
indexRuntimeTypes(moduleGens.values());
}
use of org.opendaylight.mdsal.binding.generator.impl.reactor.ModuleGenerator in project mdsal by opendaylight.
the class DefaultBindingGenerator method generateFor.
/**
* Resolves generated types from {@code context} schema nodes only for modules specified in {@code modules}.
* Generated types are created for modules, groupings, types, containers, lists, choices, augments, rpcs,
* notification, identities and actions.
*
* @param context schema context which contains data about all schema nodes saved in modules
* @param modules set of modules for which schema nodes should be generated types
* @return list of types (usually a {@link GeneratedType} or an {@link GeneratedTransferObject}), which:
* <ul>
* <li>are generated from {@code context} schema nodes and</li>
* <li>are also part of some of the module in {@code modules} set.</li>
* </ul>
* @throws NullPointerException if any argument is {@code null}, or if {@code modules} contains a {@code null}
* element
*/
@VisibleForTesting
@NonNull
static List<GeneratedType> generateFor(final EffectiveModelContext context, final Collection<? extends Module> modules) {
final Set<ModuleEffectiveStatement> filter = modules.stream().map(Module::asEffectiveStatement).collect(Collectors.toUnmodifiableSet());
final List<GeneratedType> result = new ArrayList<>();
for (ModuleGenerator gen : new GeneratorReactor(context).execute(TypeBuilderFactory.codegen()).values()) {
if (filter.contains(gen.statement())) {
addTypes(result, gen);
}
}
return result;
}
Aggregations