Package org.yaml.snakeyaml

Examples of org.yaml.snakeyaml.TypeDescription


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


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

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

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

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

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

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

    @SuppressWarnings("unchecked")
    public void testChildrenSetAsRoot() {
        String etalon = Util.getLocalResource("recursive/with-children-as-set.yaml");

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

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

    @SuppressWarnings("unchecked")
    public void testChildrenMapAsRoot() {
        String etalon = Util.getLocalResource("recursive/with-children-as-map.yaml");

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

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

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

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

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

        Yaml beanDumper = new Yaml();
        String output = beanDumper.dumpAsMap(son);
        // System.out.println(output);
        String etalon = Util.getLocalResource("recursive/with-children-no-root-tag.yaml");
        assertEquals(etalon, output);
        TypeDescription humanDescription = new TypeDescription(Human.class);
        humanDescription.putMapPropertyType("children", Human.class, Object.class);
        Yaml beanLoader = new Yaml(new Constructor(humanDescription));
        //
        Human son2 = beanLoader.loadAs(output, Human.class);
        assertNotNull(son2);
        assertEquals("Son", son.getName());
View Full Code Here

        Yaml beanDumper = new Yaml();
        String yaml = beanDumper.dumpAsMap(house);
        String etalon = Util.getLocalResource("javabeans/house-dump3.yaml");
        assertEquals(etalon, yaml);
        // load
        TypeDescription description = new TypeDescription(House.class);
        description.putListPropertyType("rooms", Room.class);
        Yaml beanLoader = new Yaml(new Constructor(description));
        House loadedHouse = (House) beanLoader.load(yaml);
        House loadedHouse2 = (House) beanLoader.loadAs(yaml, House.class);
        assertNotNull(loadedHouse);
        assertFalse(loadedHouse == loadedHouse2);
View Full Code Here

        }
    }

    public void testChildrenArray() {
        Constructor constructor = new Constructor(Human_WithArrayOfChildren.class);
        TypeDescription HumanWithChildrenArrayDescription = new TypeDescription(
                Human_WithArrayOfChildren.class);
        HumanWithChildrenArrayDescription.putListPropertyType("children",
                Human_WithArrayOfChildren.class);
        constructor.addTypeDescription(HumanWithChildrenArrayDescription);
        Human_WithArrayOfChildren son = createSon();
        Yaml yaml = new Yaml(constructor);
        String output = yaml.dump(son);
View Full Code Here

        assertEquals(etalon, output);
    }

    public void testParseChildrenArrayWithoutRootTag() {
        Constructor constructor = new Constructor(Human_WithArrayOfChildren.class);
        TypeDescription HumanWithChildrenArrayDescription = new TypeDescription(
                Human_WithArrayOfChildren.class);
        HumanWithChildrenArrayDescription.putListPropertyType("children",
                Human_WithArrayOfChildren.class);
        constructor.addTypeDescription(HumanWithChildrenArrayDescription);
        Yaml yaml = new Yaml(constructor);
        String doc = Util.getLocalResource("recursive/with-childrenArray-no-root-tag.yaml");
        Human_WithArrayOfChildren son2 = (Human_WithArrayOfChildren) yaml.load(doc);
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.