Package org.yaml.snakeyaml

Examples of org.yaml.snakeyaml.TypeDescription


        Constructor constructor = new Constructor();
        Representer representer = new Representer();
        Tag generalAccountTag = new Tag("!GA");
        constructor
                .addTypeDescription(new TypeDescription(GeneralAccount.class, generalAccountTag));
        representer.addClassTag(GeneralAccount.class, generalAccountTag);

        Yaml yaml = new Yaml(constructor, representer);
        String dump = yaml.dump(customerAB);
        // System.out.println(dump);
View Full Code Here


        Constructor constructor = new Constructor();
        Representer representer = new Representer();

        Tag generalAccountTag = new Tag("!GA");
        constructor
                .addTypeDescription(new TypeDescription(GeneralAccount.class, generalAccountTag));
        representer.addClassTag(GeneralAccount.class, generalAccountTag);

        Yaml yaml = new Yaml(constructor, representer);
        String dump = yaml.dump(customerAB_property);
        // System.out.println(dump);
View Full Code Here

        father.setChildren(children);
        mother.setChildren(children);
        //

        Constructor constructor = new Constructor();
        TypeDescription humanDescription = new TypeDescription(HumanGen.class);
        humanDescription.putMapPropertyType("children", HumanGen.class, Object.class);
        constructor.addTypeDescription(humanDescription);

        Yaml yaml = new Yaml(constructor);
        String output = yaml.dump(son);
        // System.out.println(output);
View Full Code Here

        String output = yaml.dump(son);
        // System.out.println(output);
        String etalon = Util.getLocalResource("recursive/generics/with-children-2.yaml");
        assertEquals(etalon, output);
        // load
        TypeDescription humanDescription = new TypeDescription(HumanGen2.class);
        humanDescription.putMapPropertyType("children", HumanGen2.class, String.class);
        Yaml beanLoader = new Yaml(new Constructor(humanDescription));
        //
        HumanGen2 son2 = beanLoader.loadAs(output, HumanGen2.class);
        assertNotNull(son2);
        assertEquals("Son", son.getName());
View Full Code Here

        father.setChildren(children);
        mother.setChildren(children);
        //

        Constructor constructor = new Constructor();
        TypeDescription Human3Description = new TypeDescription(HumanGen3.class);
        Human3Description.putListPropertyType("children", HumanGen3.class);
        constructor.addTypeDescription(Human3Description);

        Yaml yaml = new Yaml(constructor);
        String output = yaml.dump(son);
        // System.out.println(output);
View Full Code Here

            return;
        }
        String etalon = Util.getLocalResource("recursive/generics/with-children-as-set.yaml");

        Constructor constructor = new Constructor();
        TypeDescription humanDescription = new TypeDescription(HumanGen.class);
        humanDescription.putMapPropertyType("children", HumanGen.class, Object.class);
        constructor.addTypeDescription(humanDescription);

        Yaml yaml = new Yaml(constructor);
        Set<HumanGen> children2 = (Set<HumanGen>) yaml.load(etalon);
        assertNotNull(children2);
View Full Code Here

            return;
        }
        String etalon = Util.getLocalResource("recursive/generics/with-children-as-map.yaml");

        Constructor constructor = new Constructor();
        TypeDescription Human2Description = new TypeDescription(HumanGen2.class);
        Human2Description.putMapPropertyType("children", HumanGen2.class, String.class);
        constructor.addTypeDescription(Human2Description);

        Yaml yaml = new Yaml(constructor);
        Map<HumanGen2, String> children2 = (Map<HumanGen2, String>) yaml.load(etalon);
        assertNotNull(children2);
View Full Code Here

        father.setChildren(children);
        mother.setChildren(children);
        //

        Constructor constructor = new Constructor();
        TypeDescription Human3Description = new TypeDescription(HumanGen3.class);
        Human3Description.putListPropertyType("children", HumanGen3.class);
        constructor.addTypeDescription(Human3Description);

        Yaml yaml = new Yaml(constructor);
        String output = yaml.dump(father.getChildren());
        // System.out.println(output);
View Full Code Here

        String output = yaml.dump(new Wrapper(bean));
        // System.out.println(output);
        assertEquals("!mybean {age: -47, color: Violet, name: Bahrack, type: Type3}\n", output);
        // parse back to instance
        Constructor constr = new Constructor();
        TypeDescription description = new TypeDescription(Wrapper.class, new Tag("!mybean"));
        constr.addTypeDescription(description);
        yaml = new Yaml(constr);
        Wrapper wrapper = (Wrapper) yaml.load(output);
        JavaBeanWithStaticState bean2 = wrapper.createBean();
        assertEquals(-47, bean2.getAge());
View Full Code Here

     * be an interface)
     */
    public void testLoadList2() {
        String output = Util.getLocalResource("examples/list-bean-3.yaml");
        // System.out.println(output);
        TypeDescription descr = new TypeDescription(ListBean.class);
        descr.putListPropertyType("developers", Developer.class);
        Yaml beanLoader = new Yaml(new Constructor(descr));
        ListBean parsed = beanLoader.loadAs(output, ListBean.class);
        assertNotNull(parsed);
        List<Human> developers = parsed.getDevelopers();
        assertEquals(2, developers.size());
View Full Code Here

TOP

Related Classes of org.yaml.snakeyaml.TypeDescription

Copyright © 2018 www.massapicom. 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.