Package org.yaml.snakeyaml.constructor

Examples of org.yaml.snakeyaml.constructor.Constructor$ConstructSequence


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


        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

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

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

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

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

     * is not required
     */
    public void testMergeBeanProperty() {
        String input = Util.getLocalResource("issues/issue100-3.yaml");
        // System.out.println(input);
        Yaml yaml = new Yaml(new Constructor(DataBean.class));
        DataBean bean = (DataBean) yaml.load(input);
        assertEquals("id001", bean.getId());
        assertEquals("id002", bean.getData().getId());
        assertEquals(17, bean.getData().getAge());
        assertEquals(17, bean.getMore().getAge());
View Full Code Here

     */
    @SuppressWarnings("unchecked")
    public void testMergeMapToJavaBean() {
        String input = "- &id001 { age: 11, id: id123 }\n- !!org.yaml.snakeyaml.issues.issue100.Data\n  <<: *id001\n  id: id456";
        // System.out.println(input);
        Yaml yaml = new Yaml(new Constructor());
        List<Object> objects = (List<Object>) yaml.load(input);
        assertEquals(2, objects.size());
        // Check first type
        Object first = objects.get(0);
        Map<Object, Object> firstMap = (Map<Object, Object>) first;
View Full Code Here

        // System.out.println(dump);

        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

        // System.out.println(dump);

        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

TOP

Related Classes of org.yaml.snakeyaml.constructor.Constructor$ConstructSequence

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.