gpt4 book ai didi

alien4cloud.utils.YamlParserUtil.parse()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-15 00:09:31 25 4
gpt4 key购买 nike

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

YamlParserUtil.parse介绍

[英]Parses a string to build an instance of T
[中]

代码示例

代码示例来源:origin: alien4cloud/alien4cloud

private DefaultDeclarativeWorkflows loadDefaultDeclarativeWorkflow(String configName) throws IOException {
  return YamlParserUtil.parse(DefaultDeclarativeWorkflows.class.getClassLoader().getResourceAsStream(configName), DefaultDeclarativeWorkflows.class);
}

代码示例来源:origin: alien4cloud/alien4cloud

/**
 * Load the file from the given path and parse it's content into an instance of T.
 * 
 * @param filePath The path of the file to load an parse.
 * @param clazz The return instance class
 * @return An instance of T.
 * @throws IOException In case jackson fails to read the json input stream to create an instance of T.
 */
public static <T> T parseFromUTF8File(Path filePath, Class<T> clazz) throws IOException {
  InputStream input = Files.newInputStream(filePath);
  try {
    return parse(input, clazz);
  } finally {
    Closeables.close(input, true);
  }
}

代码示例来源:origin: alien4cloud/alien4cloud

@Override
public Date parse(String text) throws InvalidPropertyValueException {
  try {
    return YamlParserUtil.parse(text, Date.class);
  } catch (Exception e) {
    throw new InvalidPropertyValueException("Could not parse timestamp from value " + text, e);
  }
}

代码示例来源:origin: alien4cloud/alien4cloud

/**
 * This method load the defaults suggestions to ES.
 * 
 * @throws IOException
 */
@PostConstruct
public void loadDefaultSuggestions() throws IOException {
  try (InputStream input = Thread.currentThread().getContextClassLoader().getResourceAsStream("suggestion-configuration.yml")) {
    SuggestionEntry[] suggestions = YamlParserUtil.parse(input, SuggestionEntry[].class);
    for (SuggestionEntry suggestionEntry : suggestions) {
      if (!isSuggestionExist(suggestionEntry)) {
        alienDAO.save(suggestionEntry);
        try {
          setSuggestionIdOnPropertyDefinition(suggestionEntry);
        } catch (Exception e) {
          log.warn(e.getClass().getName() + " : " + e.getMessage());
        }
      }
    }
  }
}

代码示例来源:origin: alien4cloud/alien4cloud

@SneakyThrows
public <T extends AbstractDeploymentConfig> T findById(Class<T> clazz, String id) {
  Path path = localGitRepositoryPathResolver.resolve(clazz, id);
  T config = null;
  if (Files.exists(path)) {
    byte[] bytes = Files.readAllBytes(path);
    if (ArrayUtils.isNotEmpty(bytes)) {
      config = YamlParserUtil.parse(new String(bytes, StandardCharsets.UTF_8), clazz);
    }
  } else {
    // Any data to migrate?
    config = alienDao.findById(clazz, id);
    if (config != null) {
      // migrating data from ES to Git
      save(config);
      alienDao.delete(clazz, id);
    }
  }
  return config;
}

代码示例来源:origin: alien4cloud/alien4cloud

@Test
  public void default_declarative_workflow_could_be_parsed_from_configuration() throws IOException {
    DefaultDeclarativeWorkflows defaultDeclarativeWorkflows = YamlParserUtil.parse(
        DefaultDeclarativeWorkflows.class.getClassLoader().getResourceAsStream("declarative-workflows-2.0.0.yml"), DefaultDeclarativeWorkflows.class);

    Assert.assertNotNull(defaultDeclarativeWorkflows.getNodeWorkflows());
    Assert.assertNotNull(defaultDeclarativeWorkflows.getRelationshipWorkflows());
    Assert.assertNotNull(defaultDeclarativeWorkflows.getRelationshipsWeaving());

    Assert.assertTrue(defaultDeclarativeWorkflows.getNodeWorkflows().containsKey(NormativeWorkflowNameConstants.INSTALL));
    Assert.assertTrue(defaultDeclarativeWorkflows.getRelationshipWorkflows().containsKey(NormativeWorkflowNameConstants.INSTALL));
    Assert.assertTrue(defaultDeclarativeWorkflows.getRelationshipsWeaving().containsKey(NormativeTypesConstant.ROOT_RELATIONSHIP_TYPE));
  }
}

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