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

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

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

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

  private static ModuleImport getModuleImport(final Module targetModule, final String prefix) {
    return targetModule.getImports().stream()
      .filter(imp -> prefix.equals(imp.getPrefix())).findFirst().orElse(null);
  }
}
origin: org.opendaylight.controller/yang-jmx-generator

private static ModuleImport findModuleImport(final Module module, final String prefix) {
  for (ModuleImport moduleImport : module.getImports()) {
    if (moduleImport.getPrefix().equals(prefix)) {
      return moduleImport;
    }
  }
  throw new IllegalStateException(format("Import not found with prefix %s in %s", prefix, module));
}
origin: opendaylight/yangtools

  private static ModuleImport getModuleImport(final Module targetModule, final String prefix) {
    return targetModule.getImports().stream()
      .filter(imp -> prefix.equals(imp.getPrefix())).findFirst().orElse(null);
  }
}
origin: org.opendaylight.controller/yang-jmx-generator

private static String getConfigModulePrefixFromImport(final Module currentModule) {
  for (ModuleImport currentImport : currentModule.getImports()) {
    if (currentImport.getModuleName().equals(ConfigConstants.CONFIG_MODULE)) {
      return currentImport.getPrefix();
    }
  }
  throw new IllegalArgumentException("Cannot find import " + ConfigConstants.CONFIG_MODULE + " in "
      + currentModule);
}
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: 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: opendaylight/yangtools

private static Map<String, URI> prefixToNamespace(final SchemaContext ctx, final Module module) {
  final BiMap<String, URI> prefixMap = HashBiMap.create(module.getImports().size() + 1);
  prefixMap.put(module.getPrefix(), module.getNamespace());
  for (final ModuleImport imp : module.getImports()) {
    final String prefix = imp.getPrefix();
    final URI namespace = getModuleNamespace(ctx, imp.getModuleName());
    prefixMap.put(prefix, namespace);
  }
  return prefixMap;
}
origin: org.opendaylight.yangtools/yang-model-export

private static Map<String, URI> prefixToNamespace(final SchemaContext ctx, final Module module) {
  final BiMap<String, URI> prefixMap = HashBiMap.create(module.getImports().size() + 1);
  prefixMap.put(module.getPrefix(), module.getNamespace());
  for (final ModuleImport imp : module.getImports()) {
    final String prefix = imp.getPrefix();
    final URI namespace = getModuleNamespace(ctx, imp.getModuleName());
    prefixMap.put(prefix, namespace);
  }
  return prefixMap;
}
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: opendaylight/yangtools

private static IdentitySchemaNode getIdentitySchemaNodeFromString(final String identity,
    final SchemaContext schemaContext, final TypedDataSchemaNode correspondingSchemaNode) {
  final List<String> identityPrefixAndName = COLON_SPLITTER.splitToList(identity);
  final Module module = schemaContext.findModule(correspondingSchemaNode.getQName().getModule()).get();
  if (identityPrefixAndName.size() == 2) {
    // prefix of local module
    if (identityPrefixAndName.get(0).equals(module.getPrefix())) {
      return findIdentitySchemaNodeInModule(module, QName.create(module.getQNameModule(),
          identityPrefixAndName.get(1)));
    }
    // prefix of imported module
    for (final ModuleImport moduleImport : module.getImports()) {
      if (identityPrefixAndName.get(0).equals(moduleImport.getPrefix())) {
        final Module importedModule = schemaContext.findModule(moduleImport.getModuleName(),
          moduleImport.getRevision()).get();
        return findIdentitySchemaNodeInModule(importedModule, QName.create(
          importedModule.getQNameModule(), identityPrefixAndName.get(1)));
      }
    }
    throw new IllegalArgumentException(String.format("Cannot resolve prefix '%s' from identity '%s'.",
        identityPrefixAndName.get(0), identity));
  }
  if (identityPrefixAndName.size() == 1) {
    // without prefix
    return findIdentitySchemaNodeInModule(module, QName.create(module.getQNameModule(),
        identityPrefixAndName.get(0)));
  }
  throw new IllegalArgumentException(String.format("Malformed identity argument: %s.", identity));
}
origin: org.opendaylight.yangtools/yang-model-util

if (prefix.equals(mi.getPrefix())) {
  return context.findModule(mi.getModuleName(), mi.getRevision()).orElse(null);
origin: opendaylight/yangtools

if (prefix.equals(mi.getPrefix())) {
  return context.findModule(mi.getModuleName(), mi.getRevision()).orElse(null);
origin: org.opendaylight.yangtools/yang-data-jaxen

private static IdentitySchemaNode getIdentitySchemaNodeFromString(final String identity,
    final SchemaContext schemaContext, final TypedDataSchemaNode correspondingSchemaNode) {
  final List<String> identityPrefixAndName = COLON_SPLITTER.splitToList(identity);
  final Module module = schemaContext.findModule(correspondingSchemaNode.getQName().getModule()).get();
  if (identityPrefixAndName.size() == 2) {
    // prefix of local module
    if (identityPrefixAndName.get(0).equals(module.getPrefix())) {
      return findIdentitySchemaNodeInModule(module, QName.create(module.getQNameModule(),
          identityPrefixAndName.get(1)));
    }
    // prefix of imported module
    for (final ModuleImport moduleImport : module.getImports()) {
      if (identityPrefixAndName.get(0).equals(moduleImport.getPrefix())) {
        final Module importedModule = schemaContext.findModule(moduleImport.getModuleName(),
          moduleImport.getRevision()).get();
        return findIdentitySchemaNodeInModule(importedModule, QName.create(
          importedModule.getQNameModule(), identityPrefixAndName.get(1)));
      }
    }
    throw new IllegalArgumentException(String.format("Cannot resolve prefix '%s' from identity '%s'.",
        identityPrefixAndName.get(0), identity));
  }
  if (identityPrefixAndName.size() == 1) {
    // without prefix
    return findIdentitySchemaNodeInModule(module, QName.create(module.getQNameModule(),
        identityPrefixAndName.get(0)));
  }
  throw new IllegalArgumentException(String.format("Malformed identity argument: %s.", identity));
}
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.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: 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.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());
  }
}
origin: opendaylight/yangtools

  /**
   * 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());
  }
}
origin: org.opendaylight.yangtools/binding-generator-impl

_builder.append(_moduleName_1, "");
_builder.append(" { prefix \"");
String _prefix = moduleImport.getPrefix();
_builder.append(_prefix, "");
_builder.append("\"; }");
org.opendaylight.yangtools.yang.model.apiModuleImportgetPrefix

Javadoc

Returns the prefix associated with the imported module.

Popular methods of ModuleImport

  • getModuleName
    Returns the name of the module to import.
  • getRevision
    Returns the module revision to import. May be null.
  • getSemanticVersion
    Returns the semantic version to import.

Popular in Java

  • Reading from database using SQL prepared statement
  • compareTo (BigDecimal)
  • onRequestPermissionsResult (Fragment)
  • setScale (BigDecimal)
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • JFileChooser (javax.swing)
  • XPath (javax.xml.xpath)
    XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
  • 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