Examples of loadAs()


Examples of org.yaml.snakeyaml.Yaml.loadAs()

    Config config;
    if (Files.exists(configFile)) {
      try (InputStream is = Files.newInputStream(configFile)) {
        Yaml yaml = new Yaml();
        config = yaml.loadAs(is, Config.class);
      }
    } else {
      config = new Config();
    }
View Full Code Here

Examples of org.yaml.snakeyaml.Yaml.loadAs()

      if (Files.exists(configFile)) {
        try (InputStream is = Files.newInputStream(configFile)) {
          Yaml yaml = new Yaml();
          @SuppressWarnings("unused")
          Config config = yaml.loadAs(is, Config.class);

          // loading checks for syntax errors like existing tab
          // characters.
          // todo
          // Add some more checks like printing a warning if there is
View Full Code Here

Examples of org.yaml.snakeyaml.Yaml.loadAs()

        final TypeDescription graphiteReporterDescription = new TypeDescription(GraphiteReporterMetrics.class);
        constructor.addTypeDescription(graphiteReporterDescription);

        final Yaml yaml = new Yaml(constructor);
        return yaml.loadAs(stream, Settings.class);
    }

    public static class ProcessorSettings {
        public String className;
        public Map<String, Object> config;
View Full Code Here

Examples of org.yaml.snakeyaml.Yaml.loadAs()

            throw new ParseException("Dataset not found in classpath");
        }

        Yaml yaml = new Yaml();
        try {
            ParsedKeyspace keyspace = yaml.loadAs(inputDataSetLocation, ParsedKeyspace.class);
            return keyspace;
        } catch (YAMLException e) {
            throw new ParseException(e);
        }
    }
View Full Code Here

Examples of org.yaml.snakeyaml.Yaml.loadAs()

  @SuppressWarnings("unchecked")
  public void load() {
    Yaml yaml = new Yaml();
    try {
      bindings = new ArrayList<KeyBinding>();
      ArrayList<Object> kbsave = yaml.loadAs(new FileReader(getBindingsFile()), ArrayList.class);
      if (kbsave == null) {
        kbsave = new ArrayList<Object>();
      }
      for (Object obj:kbsave) {
        HashMap<String, Object> item = (HashMap<String, Object>) obj;
View Full Code Here

Examples of org.yaml.snakeyaml.Yaml.loadAs()

      e.printStackTrace();
      bindings = new ArrayList<KeyBinding>();
    }
    try {
      shortcuts.clear();
      ArrayList<Object> shsave = yaml.loadAs(new FileReader(getShortcutsFile()), ArrayList.class);
      if (shsave == null) {
        shsave = new ArrayList<Object>();
      }
      for (Object obj:shsave) {
        HashMap<String, Object> item = (HashMap<String, Object>) obj;
View Full Code Here

Examples of org.yaml.snakeyaml.Yaml.loadAs()

        String etalon = Util.getLocalResource("template/etalon2-template.yaml").trim();
        assertEquals(etalon.length(), output.length());
        assertEquals(etalon, output);
        // parse the YAML document
        Yaml loader = new Yaml();
        MyBean parsedBean = loader.loadAs(output, MyBean.class);
        assertEquals(bean, parsedBean);
    }

    private MyBean createBean() {
        MyBean bean = new MyBean();
View Full Code Here

Examples of org.yaml.snakeyaml.Yaml.loadAs()

        Yaml yaml = new Yaml();
        String output = yaml.dumpAsMap(bean);
        // System.out.println(output);
        assertEquals(Util.getLocalResource("issues/issue74-array1.txt"), output);
        Yaml beanLoader = new Yaml();
        ArrayBean parsed = beanLoader.loadAs(output, ArrayBean.class);
        // System.out.println(parsed);
        assertEquals(3, parsed.getMembers().length);
        assertEquals(2, parsed.openMembers.length);
        assertEquals(2, parsed.getList().size());
        assertEquals("ID123", parsed.getId());
View Full Code Here

Examples of org.yaml.snakeyaml.Yaml.loadAs()

        String output = yaml.dumpAsMap(bean);
        // System.out.println(output);
        assertEquals("name: lunch\n", output);
        //
        Yaml loader = new Yaml();
        IncompleteBean parsed = loader.loadAs(output, IncompleteBean.class);
        assertEquals(bean.getName(), parsed.getName());
    }

    public void testBean2() {
        IncompleteBean bean = new IncompleteBean();
View Full Code Here

Examples of org.yaml.snakeyaml.Yaml.loadAs()

        // System.out.println(output);
        assertEquals("id: 10\nname: lunch\n", output);
        //
        Yaml loader = new Yaml();
        try {
            loader.loadAs(output, IncompleteBean.class);
            fail("Setter is missing.");
        } catch (YAMLException e) {
            String message = e.getMessage();
            assertTrue(
                    message,
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.