com.ea.orbit.actors.core.shaded.org.yaml.snakeyaml.Yaml类的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(1.7k)|赞(0)|评价(0)|浏览(227)

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

Yaml介绍

暂无

代码示例

代码示例来源:origin: com.ea.orbit/orbit-hk2

private static Map<String, Object> readProperties(final Set<String> activeProfiles, final InputStream in) throws IOException
{
  String inputStreamString = IOUtils.toString(new InputStreamReader(in, "UTF-8"));
  Yaml yaml = new Yaml();
  final Iterable<Object> iter = yaml.loadAll(substituteVariables(inputStreamString));
  final Map<String, Object> newProperties = new LinkedHashMap<>();
  iter.forEach(item -> {
    final Map<String, Object> section = (Map<String, Object>) item;
    final Object sectionProfile = section.get("orbit.profile");
    if (sectionProfile == null || activeProfiles.contains(sectionProfile))
    {
      // if no profile or if the profile is in the current list of profiles.
      newProperties.putAll(section);
    }
  });
  return newProperties;
}

代码示例来源:origin: com.ea.orbit/orbit-core

private void loadClassInfo(final ClassPath.ResourceInfo r)
{
  final URL url = r.url();
  try
  {
    final LinkedHashMap map = new Yaml().loadAs(url.openStream(), LinkedHashMap.class);
    final Object classId = map.get("classId");
    if (classId instanceof Number)
    {
      final String resourceName = r.getResourceName();
      final Integer classIdKey = ((Number) classId).intValue();
      final String className = resourceName.substring(META_INF_SERVICES_ORBIT_CLASSES.length(),
          resourceName.length() - SUFFIX.length());
      idToName.putIfAbsent(classIdKey, className);
      nameToId.putIfAbsent(className, classIdKey);
    }
    else
    {
      logger.warn("classId not found at: " + url);
    }
  }
  catch (Exception ex)
  {
    logger.error("Error loading class info " + url, ex);
  }
}

相关文章

Yaml类方法