Tabnine Logo
ModuleImport.getRevision
Code IndexAdd Tabnine to your IDE (free)

How to use
getRevision
method
in
org.opendaylight.yangtools.yang.model.api.ModuleImport

Best Java code snippets using org.opendaylight.yangtools.yang.model.api.ModuleImport.getRevision (Showing top 20 results out of 315)

origin: org.opendaylight.yangtools/yang-parser-impl

@Override
protected boolean isKnown(final Collection<SourceIdentifier> haystack, final ModuleImport mi) {
  final SourceIdentifier msi = RevisionSourceIdentifier.create(mi.getModuleName(), mi.getRevision());
  // Quick lookup
  if (haystack.contains(msi)) {
    return true;
  }
  // Slow revision-less walk
  return !mi.getRevision().isPresent() && findWildcard(haystack, mi.getModuleName()) != null;
}
origin: opendaylight/yangtools

@Override
protected boolean isKnown(final Collection<SourceIdentifier> haystack, final ModuleImport mi) {
  final SourceIdentifier msi = RevisionSourceIdentifier.create(mi.getModuleName(), mi.getRevision());
  // Quick lookup
  if (haystack.contains(msi)) {
    return true;
  }
  // Slow revision-less walk
  return !mi.getRevision().isPresent() && findWildcard(haystack, mi.getModuleName()) != null;
}
origin: org.opendaylight.yangtools/yang-data-impl

private Optional<QNameModule> getQNameModuleForImportPrefix(final Module targetModule, final String prefix) {
  final ModuleImport moduleImport = getModuleImport(targetModule, prefix);
  if (moduleImport == null) {
    return Optional.empty();
  }
  final String moduleName = moduleImport.getModuleName();
  final Optional<Revision> revision = moduleImport.getRevision();
  return schemaContext.findModule(moduleName, revision).map(Module::getQNameModule);
}
origin: org.opendaylight.mdsal/mdsal-binding-generator-impl

private Module findModuleFromImports(final Set<ModuleImport> imports, final String prefix) {
  for (final ModuleImport imp : imports) {
    if (imp.getPrefix().equals(prefix)) {
      return schemaContext.findModule(imp.getModuleName(), imp.getRevision()).orElse(null);
    }
  }
  return null;
}
origin: opendaylight/yangtools

private Optional<QNameModule> getQNameModuleForImportPrefix(final Module targetModule, final String prefix) {
  final ModuleImport moduleImport = getModuleImport(targetModule, prefix);
  if (moduleImport == null) {
    return Optional.empty();
  }
  final String moduleName = moduleImport.getModuleName();
  final Optional<Revision> revision = moduleImport.getRevision();
  return schemaContext.findModule(moduleName, revision).map(Module::getQNameModule);
}
origin: org.opendaylight.yangtools/binding-generator-impl

private Module findModuleFromImports(final Set<ModuleImport> imports, final String prefix) {
  for (final ModuleImport imp : imports) {
    if (imp.getPrefix().equals(prefix)) {
      return schemaContext.findModuleByName(imp.getModuleName(), imp.getRevision());
    }
  }
  return null;
}
origin: org.opendaylight.yangtools/yang-parser-impl

@Override
protected boolean isKnown(final Collection<SourceIdentifier> haystack, final ModuleImport mi) {
  final SemVerSourceIdentifier msi = SemVerSourceIdentifier.create(mi.getModuleName(), mi.getRevision(),
    mi.getSemanticVersion().orElse(null));
  // Quick lookup
  if (haystack.contains(msi)) {
    return true;
  }
  // Slow revision-less walk
  return findCompatibleVersion(haystack, mi) != null;
}
origin: org.opendaylight.controller/yang-jmx-generator

private static ServiceInterfaceEntry findSIE(final String prefixAndIdentityLocalName, final Module currentModule,
    final Map<QName, ServiceInterfaceEntry> qNamesToSIEs, final SchemaContext schemaContext) {
  Matcher m = PREFIX_COLON_LOCAL_NAME.matcher(prefixAndIdentityLocalName);
  Module foundModule;
  String localSIName;
  if (m.matches()) {
    // if there is a prefix, look for ModuleImport with this prefix. Get
    // Module from SchemaContext
    String prefix = m.group(1);
    ModuleImport moduleImport = findModuleImport(currentModule, prefix);
    foundModule = schemaContext.findModuleByName(moduleImport.getModuleName(), moduleImport.getRevision());
    checkNotNull(foundModule, format("Module not found in SchemaContext by %s", moduleImport));
    localSIName = m.group(2);
  } else {
    foundModule = currentModule; // no prefix => SIE is in currentModule
    localSIName = prefixAndIdentityLocalName;
  }
  QName siQName = QName.create(foundModule.getNamespace(), foundModule.getRevision(), localSIName);
  ServiceInterfaceEntry sie = qNamesToSIEs.get(siQName);
  checkState(sie != null, "Cannot find referenced Service Interface by " + prefixAndIdentityLocalName);
  return sie;
}
origin: opendaylight/yangtools

@Override
protected boolean isKnown(final Collection<SourceIdentifier> haystack, final ModuleImport mi) {
  final SemVerSourceIdentifier msi = SemVerSourceIdentifier.create(mi.getModuleName(), mi.getRevision(),
    mi.getSemanticVersion().orElse(null));
  // Quick lookup
  if (haystack.contains(msi)) {
    return true;
  }
  // Slow revision-less walk
  return findCompatibleVersion(haystack, mi) != null;
}
origin: org.opendaylight.yangtools/yang-data-jaxen

private QName createQName(final String prefix, final String localName) {
  final Module module = schemaContext.findModule(schemaNode.getQName().getModule()).get();
  if (prefix.isEmpty() || module.getPrefix().equals(prefix)) {
    return QName.create(module.getQNameModule(), localName);
  }
  for (final ModuleImport moduleImport : module.getImports()) {
    if (prefix.equals(moduleImport.getPrefix())) {
      final Module importedModule = schemaContext.findModule(moduleImport.getModuleName(),
          moduleImport.getRevision()).get();
      return QName.create(importedModule.getQNameModule(),localName);
    }
  }
  throw new IllegalArgumentException(String.format("Failed to lookup a module for prefix %s", prefix));
}
origin: opendaylight/yangtools

private QName createQName(final String prefix, final String localName) {
  final Module module = schemaContext.findModule(schemaNode.getQName().getModule()).get();
  if (prefix.isEmpty() || module.getPrefix().equals(prefix)) {
    return QName.create(module.getQNameModule(), localName);
  }
  for (final ModuleImport moduleImport : module.getImports()) {
    if (prefix.equals(moduleImport.getPrefix())) {
      final Module importedModule = schemaContext.findModule(moduleImport.getModuleName(),
          moduleImport.getRevision()).get();
      return QName.create(importedModule.getQNameModule(),localName);
    }
  }
  throw new IllegalArgumentException(String.format("Failed to lookup a module for prefix %s", prefix));
}
origin: org.opendaylight.yangtools/yang-model-util

for (final ModuleImport mi : imports) {
  if (prefix.equals(mi.getPrefix())) {
    return context.findModule(mi.getModuleName(), mi.getRevision()).orElse(null);
origin: org.opendaylight.yangtools/yang-model-util

private static Collection<Module> getImportedModules(final Map<ModuleId, Module> allModules,
    final Set<Module> baseModules, final TreeMultimap<String, Module> nameToModulesAll) {
  List<Module> relatedModules = Lists.newLinkedList();
  for (Module module : baseModules) {
    for (ModuleImport moduleImport : module.getImports()) {
      Optional<Revision> revisionDate = moduleImport.getRevision();
      if (!revisionDate.isPresent()) {
        revisionDate = nameToModulesAll.get(moduleImport.getModuleName()).first().getRevision();
      }
      ModuleId key = new ModuleId(moduleImport.getModuleName(), revisionDate);
      Module importedModule = allModules.get(key);
      Preconditions.checkArgument(importedModule != null,
          "Invalid schema, cannot find imported module: %s from module: %s, %s, modules:%s", key,
          module.getQNameModule(), module.getName(), allModules);
      relatedModules.add(importedModule);
      //calling imports recursive
      relatedModules.addAll(getImportedModules(allModules, Collections.singleton(importedModule),
            nameToModulesAll));
    }
  }
  return relatedModules;
}
origin: opendaylight/yangtools

private boolean checkModuleDependency(final Module module, final Collection<ModuleId> rootModules) {
  for (ModuleId rootModule : rootModules) {
    if (rootModule.equals(new ModuleId(module.getName(), module.getRevision()))) {
      return true;
    }
    //handling/checking imports regarding root modules
    for (ModuleImport moduleImport : module.getImports()) {
      if (moduleImport.getModuleName().equals(rootModule.getName())) {
        return !moduleImport.getRevision().isPresent()
            || moduleImport.getRevision().equals(rootModule.getRev());
      }
    }
    //submodules handling
    for (Module moduleSub : module.getSubmodules()) {
      return checkModuleDependency(moduleSub, rootModules);
    }
  }
  return false;
}
origin: org.opendaylight.yangtools/yang-model-util

private boolean checkModuleDependency(final Module module, final Collection<ModuleId> rootModules) {
  for (ModuleId rootModule : rootModules) {
    if (rootModule.equals(new ModuleId(module.getName(), module.getRevision()))) {
      return true;
    }
    //handling/checking imports regarding root modules
    for (ModuleImport moduleImport : module.getImports()) {
      if (moduleImport.getModuleName().equals(rootModule.getName())) {
        return !moduleImport.getRevision().isPresent()
            || moduleImport.getRevision().equals(rootModule.getRev());
      }
    }
    //submodules handling
    for (Module moduleSub : module.getSubmodules()) {
      return checkModuleDependency(moduleSub, rootModules);
    }
  }
  return false;
}
origin: org.opendaylight.mdsal/mdsal-binding2-dom-codec

private static Object qnameDomValueFromString(final Codec<Object, Object> codec, final DataSchemaNode schema,
    final String defaultValue, final SchemaContext schemaContext) {
  final int prefixEndIndex = defaultValue.indexOf(':');
  if (prefixEndIndex != -1) {
    final String defaultValuePrefix = defaultValue.substring(0, prefixEndIndex);
    final Module module = schemaContext.findModule(schema.getQName().getModule()).get();
    if (module.getPrefix().equals(defaultValuePrefix)) {
      return codec.deserialize(QName.create(module.getQNameModule(),
        defaultValue.substring(prefixEndIndex + 1)));
    }
    final Set<ModuleImport> imports = module.getImports();
    for (final ModuleImport moduleImport : imports) {
      if (moduleImport.getPrefix().equals(defaultValuePrefix)) {
        final Module importedModule = schemaContext.findModule(moduleImport.getModuleName(),
          moduleImport.getRevision()).get();
        return codec.deserialize(QName.create(importedModule.getQNameModule(),
          defaultValue.substring(prefixEndIndex + 1)));
      }
    }
    return null;
  }
  return codec.deserialize(QName.create(schema.getQName(), defaultValue));
}
origin: opendaylight/yangtools

private static Collection<Module> getImportedModules(final Map<ModuleId, Module> allModules,
    final Set<Module> baseModules, final TreeMultimap<String, Module> nameToModulesAll) {
  List<Module> relatedModules = Lists.newLinkedList();
  for (Module module : baseModules) {
    for (ModuleImport moduleImport : module.getImports()) {
      Optional<Revision> revisionDate = moduleImport.getRevision();
      if (!revisionDate.isPresent()) {
        revisionDate = nameToModulesAll.get(moduleImport.getModuleName()).first().getRevision();
      }
      ModuleId key = new ModuleId(moduleImport.getModuleName(), revisionDate);
      Module importedModule = allModules.get(key);
      Preconditions.checkArgument(importedModule != null,
          "Invalid schema, cannot find imported module: %s from module: %s, %s, modules:%s", key,
          module.getQNameModule(), module.getName(), allModules);
      relatedModules.add(importedModule);
      //calling imports recursive
      relatedModules.addAll(getImportedModules(allModules, Collections.singleton(importedModule),
            nameToModulesAll));
    }
  }
  return relatedModules;
}
origin: org.opendaylight.yangtools/yang-model-export

private void emitImport(final ModuleImport importNode) {
  super.writer.startImportNode(importNode.getModuleName());
  emitDocumentedNode(importNode);
  emitPrefixNode(importNode.getPrefix());
  importNode.getRevision().ifPresent(this::emitRevisionDateNode);
  super.writer.endNode();
}
origin: org.opendaylight.mdsal/mdsal-binding-dom-codec

private static Object qnameDomValueFromString(final Codec<Object, Object> codec, final DataSchemaNode schema,
                       final String defaultValue, final SchemaContext schemaContext) {
  int prefixEndIndex = defaultValue.indexOf(':');
  QName qname;
  if (prefixEndIndex != -1) {
    String defaultValuePrefix = defaultValue.substring(0, prefixEndIndex);
    Module module = schemaContext.findModule(schema.getQName().getModule()).get();
    if (module.getPrefix().equals(defaultValuePrefix)) {
      qname = QName.create(module.getQNameModule(), defaultValue.substring(prefixEndIndex + 1));
      return codec.deserialize(qname);
    }
    Set<ModuleImport> imports = module.getImports();
    for (ModuleImport moduleImport : imports) {
      if (moduleImport.getPrefix().equals(defaultValuePrefix)) {
        Module importedModule = schemaContext.findModule(moduleImport.getModuleName(),
          moduleImport.getRevision()).get();
        qname = QName.create(importedModule.getQNameModule(), defaultValue.substring(prefixEndIndex + 1));
        return codec.deserialize(qname);
      }
    }
    return null;
  }
  qname = QName.create(schema.getQName(), defaultValue);
  return codec.deserialize(qname);
}
origin: org.opendaylight.yangtools/yang-data-api

  /**
   * Create a prefix {@link Converter} for {@link XPathExpressionException} defined in a particular YANG
   * {@link Module} .Instantiation requires establishing how a module's imports are mapped to actual modules
   * and their namespaces. This information is cached and used for improved lookups.
   *
   * @param ctx A SchemaContext
   * @param module Module in which the XPath is defined
   * @return A new Converter
   */
  public static @Nonnull Converter<String, QNameModule> create(final SchemaContext ctx, final Module module) {
    // Always check for null ctx
    requireNonNull(ctx, "Schema context may not be null");

    // Use immutable map builder for detection of duplicates (which should never occur)
    final Builder<String, QNameModule> b = ImmutableBiMap.builder();
    b.put(module.getPrefix(), module.getQNameModule());

    for (ModuleImport i : module.getImports()) {
      final Optional<Module> mod = ctx.findModule(i.getModuleName(), i.getRevision());
      checkArgument(mod.isPresent(), "Unsatisfied import of %s by module %s", i, module);

      b.put(i.getPrefix(), mod.get().getQNameModule());
    }

    return Maps.asConverter(b.build());
  }
}
org.opendaylight.yangtools.yang.model.apiModuleImportgetRevision

Javadoc

Returns the module revision to import. May be null.

Popular methods of ModuleImport

  • getModuleName
    Returns the name of the module to import.
  • getPrefix
    Returns the prefix associated with the imported module.
  • getSemanticVersion
    Returns the semantic version to import.

Popular in Java

  • Reactive rest calls using spring rest template
  • scheduleAtFixedRate (Timer)
  • getApplicationContext (Context)
  • startActivity (Activity)
  • ServerSocket (java.net)
    This class represents a server-side socket that waits for incoming client connections. A ServerSocke
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • Collectors (java.util.stream)
  • Annotation (javassist.bytecode.annotation)
    The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
  • Cipher (javax.crypto)
    This class provides access to implementations of cryptographic ciphers for encryption and decryption
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now