gpt4 book ai didi

org.opendaylight.yangtools.yang.binding.YangModuleInfo.getImportedModules()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-14 19:12:49 35 4
gpt4 key购买 nike

本文整理了Java中org.opendaylight.yangtools.yang.binding.YangModuleInfo.getImportedModules()方法的一些代码示例,展示了YangModuleInfo.getImportedModules()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YangModuleInfo.getImportedModules()方法的具体详情如下:
包路径:org.opendaylight.yangtools.yang.binding.YangModuleInfo
类名称:YangModuleInfo
方法名:getImportedModules

YangModuleInfo.getImportedModules介绍

[英]Return YangModuleInfo objects for all modules which are imported by this module. Default implementation returns an empty list.
[中]返回此模块导入的所有模块的YangModuleInfo对象。默认实现返回一个空列表。

代码示例

代码示例来源:origin: org.opendaylight.yangtools/yang-binding

private static void collectYangModuleInfo(final YangModuleInfo moduleInfo,
    final Builder<YangModuleInfo> moduleInfoSet) {
  moduleInfoSet.add(moduleInfo);
  for (YangModuleInfo dependency : moduleInfo.getImportedModules()) {
    collectYangModuleInfo(dependency, moduleInfoSet);
  }
}

代码示例来源:origin: io.lighty.core/lighty-common

private static void addDependencies(final Map<ModuleId, YangModuleInfo> resolvedModules, final Collection<YangModuleInfo> importedModules) {
  for (YangModuleInfo yangModuleInfo : importedModules) {
    resolvedModules.put(ModuleId.from(yangModuleInfo), yangModuleInfo);
    LOG.info("Adding [{}] module into known modules", yangModuleInfo);
    addDependencies(resolvedModules, yangModuleInfo.getImportedModules());
  }
}

代码示例来源:origin: org.opendaylight.yangtools/binding-generator-impl

private boolean resolveModuleInfo(final YangModuleInfo moduleInfo) {
  SourceIdentifier identifier = sourceIdentifierFrom(moduleInfo);
  YangModuleInfo previous = sourceIdentifierToModuleInfo.putIfAbsent(identifier, moduleInfo);
  ClassLoader moduleClassLoader = moduleInfo.getClass().getClassLoader();
  if (previous == null) {
    String modulePackageName = moduleInfo.getClass().getPackage().getName();
    packageNameToClassLoader.putIfAbsent(modulePackageName, new WeakReference<ClassLoader>(moduleClassLoader));
    for (YangModuleInfo importedInfo : moduleInfo.getImportedModules()) {
      resolveModuleInfo(importedInfo);
    }
  } else {
    return false;
  }
  return true;
}

代码示例来源:origin: io.lighty.core/lighty-common

/**
 * Filter unique models from given entry set.
 * This filter scans recursively dependencies and returns minimal set of models that are unique.
 * @param models
 *   Unfiltered entry set of models.
 * @return
 *   Filtered set of unique models only.
 */
public static Set<YangModuleInfo> filterUniqueModels(final Collection<YangModuleInfo> models) {
  Map<ModuleId, YangModuleInfo> result = new HashMap<>();
  for (YangModuleInfo yangModuleInfo: models) {
    result.put(ModuleId.from(yangModuleInfo), yangModuleInfo);
    for (YangModuleInfo yangModuleInfoDep : filterUniqueModels(yangModuleInfo.getImportedModules())) {
      result.put(ModuleId.from(yangModuleInfoDep), yangModuleInfoDep);
    }
  }
  return new HashSet<>(result.values());
}

代码示例来源:origin: io.lighty.core/lighty-common

/**
 * Get all Yang modules from classpath filtered by collection of top-level modules.
 * @param filter
 *   The collection of top-level modules represented by name and revision.
 * @return
 *   Collection top-level modules and all of imported yang module dependencies recursively.
 *   Empty collection is returned if no suitable modules are found.
 */
public static Set<YangModuleInfo> getModelsFromClasspath(final Set<ModuleId> filter) {
  Map<ModuleId, YangModuleInfo> resolvedModules = new HashMap<>();
  ServiceLoader<YangModelBindingProvider> yangProviderLoader = ServiceLoader.load(YangModelBindingProvider.class);
  for (ModuleId moduleId: filter) {
    Set<YangModuleInfo> filteredSet = filterYangModelBindingProviders(moduleId, yangProviderLoader);
    for (YangModuleInfo yangModuleInfo : filteredSet) {
      resolvedModules.put(ModuleId.from(yangModuleInfo), yangModuleInfo);
      LOG.info("Adding [{}] module into known modules", yangModuleInfo);
      addDependencies(resolvedModules, yangModuleInfo.getImportedModules());
    }
  }
  return Collections.unmodifiableSet(resolvedModules.values().stream().collect(Collectors.toSet()));
}

代码示例来源:origin: org.opendaylight.mdsal/mdsal-binding-generator-impl

@SuppressWarnings("checkstyle:illegalCatch")
@SuppressFBWarnings("REC_CATCH_EXCEPTION")
private boolean resolveModuleInfo(final YangModuleInfo moduleInfo) {
  final SourceIdentifier identifier = sourceIdentifierFrom(moduleInfo);
  final YangModuleInfo previous = sourceIdentifierToModuleInfo.putIfAbsent(identifier, moduleInfo);
  if (previous != null) {
    return false;
  }
  ClassLoader moduleClassLoader = moduleInfo.getClass().getClassLoader();
  try {
    String modulePackageName = moduleInfo.getClass().getPackage().getName();
    packageNameToClassLoader.putIfAbsent(modulePackageName, new WeakReference<>(moduleClassLoader));
    ctxResolver.registerSource(toYangTextSource(identifier, moduleInfo));
    for (YangModuleInfo importedInfo : moduleInfo.getImportedModules()) {
      resolveModuleInfo(importedInfo);
    }
  } catch (Exception e) {
    LOG.error("Not including {} in YANG sources because of error.", moduleInfo, e);
  }
  return true;
}

代码示例来源:origin: io.lighty.core/lighty-common

private static void printDependencies(final Collection<YangModuleInfo> yangModuleInfos, final int prefixLength) {
  for (final YangModuleInfo yangModuleInfo : yangModuleInfos) {
    final QName qname = yangModuleInfo.getName();
    LOG.info("{}{} {} {}", Strings.repeat(" ", prefixLength), qname.getNamespace(), qname.getLocalName(), qname.getRevision());
    printDependencies(yangModuleInfo.getImportedModules(), prefixLength + PREFIX);
  }
}

代码示例来源:origin: io.lighty.core/lighty-common

private static boolean hasDependency(final YangModuleInfo superiorModel, final YangModuleInfo dependency) {
  for (YangModuleInfo moduleInfo:  superiorModel.getImportedModules()) {
    if (moduleInfo.getName().equals(dependency.getName())) {
      return true;
    }
    hasDependency(moduleInfo, dependency);
  }
  return false;
}

代码示例来源:origin: io.lighty.core/lighty-common

public static void printModelInfo(final Set<YangModuleInfo> allModelsFromClasspath) {
  final int prefixLength = 0;
  final Set<YangModuleInfo> topLevelModels = YangModuleUtils.filterTopLevelModels(allModelsFromClasspath);
  LOG.info("# top-level models tree: {}", topLevelModels.size());
  for (final YangModuleInfo yangModuleInfo : topLevelModels) {
    final QName qname = yangModuleInfo.getName();
    LOG.info("{}", qname.getNamespace(), qname.getLocalName(), qname.getRevision());
    printDependencies(yangModuleInfo.getImportedModules(), prefixLength + PREFIX);
  }
  LOG.info("# top-level models list: {}", topLevelModels.size());
  for (final YangModuleInfo yangModuleInfo : topLevelModels) {
    final QName qname = yangModuleInfo.getName();
    LOG.info("{} {} {}", qname.getNamespace(), qname.getLocalName(), qname.getRevision());
  }
  final Set<YangModuleInfo> uniqueModels = YangModuleUtils.filterUniqueModels(allModelsFromClasspath);
  LOG.info("# unique models list   : {}", uniqueModels.size());
  for (final YangModuleInfo yangModuleInfo : uniqueModels) {
    final QName qname = yangModuleInfo.getName();
    LOG.info("{} {} {}", qname.getNamespace(), qname.getLocalName(), qname.getRevision());
  }
}

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com