Examples of addTypeDescription()


Examples of org.yaml.snakeyaml.constructor.Constructor.addTypeDescription()

        //

        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);
        String etalon = Util.getLocalResource("recursive/generics/with-children-as-list.yaml");
View Full Code Here

Examples of org.yaml.snakeyaml.constructor.Constructor.addTypeDescription()

        TypeDescription aTypeDescr = new TypeDescription(A.class);
        aTypeDescr.putMapPropertyType("meta", String.class, String[].class);

        Constructor c = new Constructor();
        c.addTypeDescription(aTypeDescr);
        Yaml yaml2load = new Yaml(c);
        yaml2load.setBeanAccess(BeanAccess.FIELD);

        A loaded = (A) yaml2load.load(dump);
View Full Code Here

Examples of org.yaml.snakeyaml.constructor.Constructor.addTypeDescription()

        TypeDescription aTypeDescr = new TypeDescription(B.class);
        aTypeDescr.putListPropertyType("meta", String[].class);

        Constructor c = new Constructor();
        c.addTypeDescription(aTypeDescr);
        Yaml yaml2load = new Yaml(c);
        yaml2load.setBeanAccess(BeanAccess.FIELD);

        B loaded = (B) yaml2load.load(dump);
View Full Code Here

Examples of org.yaml.snakeyaml.constructor.Constructor.addTypeDescription()

    public void testMain() {
        Map<String, String> config = new HashMap<String, String>();
        config.put("user.home", "HOME");
        Constructor constructor = new ConfigurationConstructor(config);
        constructor.addTypeDescription(new TypeDescription(TestBean.class, "!testbean"));
        Yaml yaml = new Yaml(constructor);
        yaml.addImplicitResolver(CFG, Pattern.compile("\\$\\([a-zA-Z\\d\\u002E\\u005F]+\\)"), "$");
        TestBean bean = (TestBean) yaml.load("!testbean {myval: !cfg $(user.home)}");
        // System.out.println(bean.toString());
        assertEquals("Explicit tag must be respected", "HOME", bean.getMyval());
View Full Code Here

Examples of org.yaml.snakeyaml.constructor.Constructor.addTypeDescription()

        //

        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);
        String etalon = Util.getLocalResource("recursive/with-children-2.yaml");
View Full Code Here

Examples of org.yaml.snakeyaml.constructor.Constructor.addTypeDescription()

        //

        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);
        String etalon = Util.getLocalResource("recursive/with-children-3.yaml");
View Full Code Here

Examples of org.yaml.snakeyaml.constructor.Constructor.addTypeDescription()

        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);
        assertEquals(2, children2.size());
View Full Code Here

Examples of org.yaml.snakeyaml.constructor.Constructor.addTypeDescription()

        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);
        assertEquals(2, children2.size());
View Full Code Here

Examples of org.yaml.snakeyaml.constructor.Constructor.addTypeDescription()

        //

        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);
        String etalon = Util.getLocalResource("recursive/with-children-as-list.yaml");
View Full Code Here

Examples of org.yaml.snakeyaml.constructor.Constructor.addTypeDescription()

        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);
        // System.out.println(output);
        String etalon = Util.getLocalResource("recursive/with-childrenArray.yaml");
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.