Search in sources :

Example 1 with RuntimeType

use of org.opendaylight.mdsal.binding.runtime.api.RuntimeType 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());
}
Also used : RpcOutputGenerator(org.opendaylight.mdsal.binding.generator.impl.reactor.RpcOutputGenerator) ModuleGenerator(org.opendaylight.mdsal.binding.generator.impl.reactor.ModuleGenerator) Stopwatch(com.google.common.base.Stopwatch) Mutable(org.opendaylight.yangtools.concepts.Mutable) TypeBuilderFactory(org.opendaylight.mdsal.binding.generator.impl.reactor.TypeBuilderFactory) BindingRuntimeTypes(org.opendaylight.mdsal.binding.runtime.api.BindingRuntimeTypes) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) GeneratorReactor(org.opendaylight.mdsal.binding.generator.impl.reactor.GeneratorReactor) QNameModule(org.opendaylight.yangtools.yang.common.QNameModule) Verify.verify(com.google.common.base.Verify.verify) Map(java.util.Map) IdentityGenerator(org.opendaylight.mdsal.binding.generator.impl.reactor.IdentityGenerator) OutputRuntimeType(org.opendaylight.mdsal.binding.runtime.api.OutputRuntimeType) Generator(org.opendaylight.mdsal.binding.generator.impl.reactor.Generator) DefaultBindingRuntimeTypes(org.opendaylight.mdsal.binding.generator.impl.rt.DefaultBindingRuntimeTypes) IdentityRuntimeType(org.opendaylight.mdsal.binding.runtime.api.IdentityRuntimeType) RuntimeType(org.opendaylight.mdsal.binding.runtime.api.RuntimeType) Logger(org.slf4j.Logger) RpcInputGenerator(org.opendaylight.mdsal.binding.generator.impl.reactor.RpcInputGenerator) ModuleRuntimeType(org.opendaylight.mdsal.binding.runtime.api.ModuleRuntimeType) RpcGenerator(org.opendaylight.mdsal.binding.generator.impl.reactor.RpcGenerator) AbstractExplicitGenerator(org.opendaylight.mdsal.binding.generator.impl.reactor.AbstractExplicitGenerator) EffectiveModelContext(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext) QName(org.opendaylight.yangtools.yang.common.QName) InputRuntimeType(org.opendaylight.mdsal.binding.runtime.api.InputRuntimeType) JavaTypeName(org.opendaylight.mdsal.binding.model.api.JavaTypeName) NonNull(org.eclipse.jdt.annotation.NonNull) GeneratedType(org.opendaylight.mdsal.binding.model.api.GeneratedType) RpcOutputGenerator(org.opendaylight.mdsal.binding.generator.impl.reactor.RpcOutputGenerator) RpcGenerator(org.opendaylight.mdsal.binding.generator.impl.reactor.RpcGenerator) QName(org.opendaylight.yangtools.yang.common.QName) IdentityGenerator(org.opendaylight.mdsal.binding.generator.impl.reactor.IdentityGenerator) RpcInputGenerator(org.opendaylight.mdsal.binding.generator.impl.reactor.RpcInputGenerator)

Aggregations

Stopwatch (com.google.common.base.Stopwatch)1 Verify.verify (com.google.common.base.Verify.verify)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 NonNull (org.eclipse.jdt.annotation.NonNull)1 AbstractExplicitGenerator (org.opendaylight.mdsal.binding.generator.impl.reactor.AbstractExplicitGenerator)1 Generator (org.opendaylight.mdsal.binding.generator.impl.reactor.Generator)1 GeneratorReactor (org.opendaylight.mdsal.binding.generator.impl.reactor.GeneratorReactor)1 IdentityGenerator (org.opendaylight.mdsal.binding.generator.impl.reactor.IdentityGenerator)1 ModuleGenerator (org.opendaylight.mdsal.binding.generator.impl.reactor.ModuleGenerator)1 RpcGenerator (org.opendaylight.mdsal.binding.generator.impl.reactor.RpcGenerator)1 RpcInputGenerator (org.opendaylight.mdsal.binding.generator.impl.reactor.RpcInputGenerator)1 RpcOutputGenerator (org.opendaylight.mdsal.binding.generator.impl.reactor.RpcOutputGenerator)1 TypeBuilderFactory (org.opendaylight.mdsal.binding.generator.impl.reactor.TypeBuilderFactory)1 DefaultBindingRuntimeTypes (org.opendaylight.mdsal.binding.generator.impl.rt.DefaultBindingRuntimeTypes)1 GeneratedType (org.opendaylight.mdsal.binding.model.api.GeneratedType)1 JavaTypeName (org.opendaylight.mdsal.binding.model.api.JavaTypeName)1 BindingRuntimeTypes (org.opendaylight.mdsal.binding.runtime.api.BindingRuntimeTypes)1 IdentityRuntimeType (org.opendaylight.mdsal.binding.runtime.api.IdentityRuntimeType)1 InputRuntimeType (org.opendaylight.mdsal.binding.runtime.api.InputRuntimeType)1