Java Code Examples for org.yaml.snakeyaml.TypeDescription#putMapPropertyType()

The following examples show how to use org.yaml.snakeyaml.TypeDescription#putMapPropertyType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ArrayInGenericCollectionTest.java    From snake-yaml with Apache License 2.0 6 votes vote down vote up
public void testArrayAsMapValueWithTypeDespriptor() {
    Yaml yaml2dump = new Yaml();
    yaml2dump.setBeanAccess(BeanAccess.FIELD);
    A data = createA();
    String dump = yaml2dump.dump(data);
    // 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);

    assertEquals(data.meta.size(), loaded.meta.size());
    Set<Entry<String, String[]>> loadedMeta = loaded.meta.entrySet();
    for (Entry<String, String[]> entry : loadedMeta) {
        assertTrue(data.meta.containsKey(entry.getKey()));
        Assert.assertArrayEquals(data.meta.get(entry.getKey()), entry.getValue());
    }
}
 
Example 2
Source File: TypeSafeCollectionsTest.java    From snake-yaml with Apache License 2.0 6 votes vote down vote up
public void testTypeSafeMap() {
    Constructor constructor = new Constructor(MyCar.class);
    TypeDescription carDescription = new TypeDescription(MyCar.class);
    carDescription.putMapPropertyType("wheels", MyWheel.class, Object.class);
    constructor.addTypeDescription(carDescription);
    Yaml yaml = new Yaml(constructor);
    MyCar car = (MyCar) yaml.load(Util
            .getLocalResource("constructor/car-no-root-class-map.yaml"));
    assertEquals("00-FF-Q2", car.getPlate());
    Map<MyWheel, Date> wheels = car.getWheels();
    assertNotNull(wheels);
    assertEquals(5, wheels.size());
    for (MyWheel wheel : wheels.keySet()) {
        assertTrue(wheel.getId() > 0);
        Date date = wheels.get(wheel);
        long time = date.getTime();
        assertTrue("It must be midnight.", time % 10000 == 0);
    }
}
 
Example 3
Source File: ChronixSparkLoader.java    From chronix.spark with Apache License 2.0 6 votes vote down vote up
public ChronixSparkLoader() {
    Representer representer = new Representer();
    representer.getPropertyUtils().setSkipMissingProperties(true);

    Constructor constructor = new Constructor(YamlConfiguration.class);

    TypeDescription typeDescription = new TypeDescription(ChronixYAMLConfiguration.class);
    typeDescription.putMapPropertyType("configurations", Object.class, ChronixYAMLConfiguration.IndividualConfiguration.class);
    constructor.addTypeDescription(typeDescription);

    Yaml yaml = new Yaml(constructor, representer);
    yaml.setBeanAccess(BeanAccess.FIELD);

    InputStream in = this.getClass().getClassLoader().getResourceAsStream("test_config.yml");
    chronixYAMLConfiguration = yaml.loadAs(in, ChronixYAMLConfiguration.class);
}
 
Example 4
Source File: HumanGenericsTest.java    From snake-yaml with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public void testChildrenSetAsRoot() throws IOException, IntrospectionException {
    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());

    HumanGen firstChild = children2.iterator().next();

    HumanGen father2 = firstChild.getFather();
    assertEquals("Father", father2.getName());
    assertEquals("Mother", firstChild.getMother().getName());
    assertSame(father2, father2.getBankAccountOwner());
    assertSame(father2.getPartner(), firstChild.getMother());
    assertSame(father2, firstChild.getMother().getPartner());

    assertSame(father2.getPartner().getChildren(), children2);

    for (Object child : children2) {
        assertSame(HumanGen.class, child.getClass()); // check if type
        // descriptor was correct
    }
}
 
Example 5
Source File: HumanGenericsTest.java    From snake-yaml with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public void testChildrenMapAsRoot() throws IOException, IntrospectionException {
    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());

    Entry<HumanGen2, String> firstEntry = children2.entrySet().iterator().next();
    HumanGen2 firstChild = firstEntry.getKey();

    HumanGen2 father2 = firstChild.getFather();
    assertEquals("Father", father2.getName());
    assertEquals("Mother", firstChild.getMother().getName());
    assertSame(father2, father2.getBankAccountOwner());
    assertSame(father2.getPartner(), firstChild.getMother());
    assertSame(father2, firstChild.getMother().getPartner());

    assertSame(father2.getPartner().getChildren(), children2);
}
 
Example 6
Source File: HumanTest.java    From snake-yaml with Apache License 2.0 5 votes vote down vote up
@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);
    assertEquals(2, children2.size());

    Human firstChild = children2.iterator().next();

    Human father2 = firstChild.getFather();
    assertEquals("Father", father2.getName());
    assertEquals("Mother", firstChild.getMother().getName());
    assertSame(father2, father2.getBankAccountOwner());
    assertSame(father2.getPartner(), firstChild.getMother());
    assertSame(father2, firstChild.getMother().getPartner());

    assertSame(father2.getPartner().getChildren(), children2);

    for (Object child : children2) {
        // check if type descriptor was correct
        assertSame(Human.class, child.getClass());
    }

    validateSet(children2);
}
 
Example 7
Source File: HumanTest.java    From snake-yaml with Apache License 2.0 5 votes vote down vote up
@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);
    assertEquals(2, children2.size());

    Entry<Human2, String> firstEntry = children2.entrySet().iterator().next();
    Human2 firstChild = firstEntry.getKey();

    Human2 father2 = firstChild.getFather();
    assertEquals("Father", father2.getName());
    assertEquals("Mother", firstChild.getMother().getName());
    assertSame(father2, father2.getBankAccountOwner());
    assertSame(father2.getPartner(), firstChild.getMother());
    assertSame(father2, firstChild.getMother().getPartner());

    assertSame(father2.getPartner().getChildren(), children2);

    validateMapKeys(children2);
}
 
Example 8
Source File: HumanGenericsTest.java    From snake-yaml with Apache License 2.0 4 votes vote down vote up
public void testChildren() throws IOException, IntrospectionException {
    if (!GenericsBugDetector.isProperIntrospection()) {
        return;
    }
    HumanGen father = new HumanGen();
    father.setName("Father");
    father.setBirthday(new Date(1000000000));
    father.setBirthPlace("Leningrad");
    father.setBankAccountOwner(father);
    //
    HumanGen mother = new HumanGen();
    mother.setName("Mother");
    mother.setBirthday(new Date(100000000000L));
    mother.setBirthPlace("Saint-Petersburg");
    father.setPartner(mother);
    mother.setPartner(father);
    mother.setBankAccountOwner(father);
    //
    HumanGen son = new HumanGen();
    son.setName("Son");
    son.setBirthday(new Date(310000000000L));
    son.setBirthPlace("Munich");
    son.setBankAccountOwner(father);
    son.setFather(father);
    son.setMother(mother);
    //
    HumanGen daughter = new HumanGen();
    daughter.setName("Daughter");
    daughter.setBirthday(new Date(420000000000L));
    daughter.setBirthPlace("New York");
    daughter.setBankAccountOwner(father);
    daughter.setFather(father);
    daughter.setMother(mother);
    //
    Set<HumanGen> children = new LinkedHashSet<HumanGen>(2);
    children.add(son);
    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");
    assertEquals(etalon, output);
    //
    HumanGen son2 = (HumanGen) yaml.load(output);
    assertNotNull(son2);
    assertEquals("Son", son.getName());

    HumanGen father2 = son2.getFather();
    assertEquals("Father", father2.getName());
    assertEquals("Mother", son2.getMother().getName());
    assertSame(father2, father2.getBankAccountOwner());
    assertSame(father2.getPartner(), son2.getMother());
    assertSame(father2, son2.getMother().getPartner());

    Set<HumanGen> children2 = father2.getChildren();
    assertEquals(2, children2.size());
    assertSame(father2.getPartner().getChildren(), children2);

    for (Object child : children2) {
        assertSame(HumanGen.class, child.getClass()); // check if type
        // descriptor was correct
    }
}
 
Example 9
Source File: HumanGenericsTest.java    From snake-yaml with Apache License 2.0 4 votes vote down vote up
public void testChildren2() throws IOException, IntrospectionException {
    if (!GenericsBugDetector.isProperIntrospection()) {
        return;
    }
    HumanGen2 father = new HumanGen2();
    father.setName("Father");
    father.setBirthday(new Date(1000000000));
    father.setBirthPlace("Leningrad");
    father.setBankAccountOwner(father);
    //
    HumanGen2 mother = new HumanGen2();
    mother.setName("Mother");
    mother.setBirthday(new Date(100000000000L));
    mother.setBirthPlace("Saint-Petersburg");
    father.setPartner(mother);
    mother.setPartner(father);
    mother.setBankAccountOwner(father);
    //
    HumanGen2 son = new HumanGen2();
    son.setName("Son");
    son.setBirthday(new Date(310000000000L));
    son.setBirthPlace("Munich");
    son.setBankAccountOwner(father);
    son.setFather(father);
    son.setMother(mother);
    //
    HumanGen2 daughter = new HumanGen2();
    daughter.setName("Daughter");
    daughter.setBirthday(new Date(420000000000L));
    daughter.setBirthPlace("New York");
    daughter.setBankAccountOwner(father);
    daughter.setFather(father);
    daughter.setMother(mother);
    //
    HashMap<HumanGen2, String> children = new LinkedHashMap<HumanGen2, String>(2);
    children.put(son, "son");
    children.put(daughter, "daughter");
    father.setChildren(children);
    mother.setChildren(children);
    //
    Representer representer = new Representer();
    representer.addClassTag(HumanGen2.class, Tag.MAP);
    Yaml yaml = new Yaml(representer);
    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());

    HumanGen2 father2 = son2.getFather();
    assertEquals("Father", father2.getName());
    assertEquals("Mother", son2.getMother().getName());
    assertSame(father2, father2.getBankAccountOwner());
    assertSame(father2.getPartner(), son2.getMother());
    assertSame(father2, son2.getMother().getPartner());

    Map<HumanGen2, String> children2 = father2.getChildren();
    assertEquals(2, children2.size());
    assertSame(father2.getPartner().getChildren(), children2);

}
 
Example 10
Source File: HumanTest.java    From snake-yaml with Apache License 2.0 4 votes vote down vote up
public void testChildren() {
    Human father = new Human();
    father.setName("Father");
    father.setBirthday(new Date(1000000000));
    father.setBirthPlace("Leningrad");
    father.setBankAccountOwner(father);
    //
    Human mother = new Human();
    mother.setName("Mother");
    mother.setBirthday(new Date(100000000000L));
    mother.setBirthPlace("Saint-Petersburg");
    father.setPartner(mother);
    mother.setPartner(father);
    mother.setBankAccountOwner(father);
    //
    Human son = new Human();
    son.setName("Son");
    son.setBirthday(new Date(310000000000L));
    son.setBirthPlace("Munich");
    son.setBankAccountOwner(father);
    son.setFather(father);
    son.setMother(mother);
    //
    Human daughter = new Human();
    daughter.setName("Daughter");
    daughter.setBirthday(new Date(420000000000L));
    daughter.setBirthPlace("New York");
    daughter.setBankAccountOwner(father);
    daughter.setFather(father);
    daughter.setMother(mother);
    //
    Set<Human> children = new LinkedHashSet<Human>(2);
    children.add(son);
    children.add(daughter);
    father.setChildren(children);
    mother.setChildren(children);
    //
    Yaml beanDumper = new Yaml();
    String output = beanDumper.dumpAsMap(son);
    // System.out.println(output);
    String etalon = Util.getLocalResource("recursive/with-children.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());

    Human father2 = son2.getFather();
    assertEquals("Father", father2.getName());
    assertEquals("Mother", son2.getMother().getName());
    assertSame(father2, father2.getBankAccountOwner());
    assertSame(father2.getPartner(), son2.getMother());
    assertSame(father2, son2.getMother().getPartner());

    Set<Human> children2 = father2.getChildren();
    assertEquals(2, children2.size());
    assertSame(father2.getPartner().getChildren(), children2);

    for (Object child : children2) {
        // check if type descriptor was correct
        assertSame(Human.class, child.getClass());
    }

    // check if hashCode is correct
    validateSet(children2);
}
 
Example 11
Source File: HumanTest.java    From snake-yaml with Apache License 2.0 4 votes vote down vote up
public void testChildrenPretty() {
    Human father = new Human();
    father.setName("Father");
    father.setBirthday(new Date(1000000000));
    father.setBirthPlace("Leningrad");
    father.setBankAccountOwner(father);
    //
    Human mother = new Human();
    mother.setName("Mother");
    mother.setBirthday(new Date(100000000000L));
    mother.setBirthPlace("Saint-Petersburg");
    father.setPartner(mother);
    mother.setPartner(father);
    mother.setBankAccountOwner(father);
    //
    Human son = new Human();
    son.setName("Son");
    son.setBirthday(new Date(310000000000L));
    son.setBirthPlace("Munich");
    son.setBankAccountOwner(father);
    son.setFather(father);
    son.setMother(mother);
    //
    Human daughter = new Human();
    daughter.setName("Daughter");
    daughter.setBirthday(new Date(420000000000L));
    daughter.setBirthPlace("New York");
    daughter.setBankAccountOwner(father);
    daughter.setFather(father);
    daughter.setMother(mother);
    //
    Set<Human> children = new LinkedHashSet<Human>(2);
    children.add(son);
    children.add(daughter);
    father.setChildren(children);
    mother.setChildren(children);
    //
    DumperOptions options = new DumperOptions();
    options.setDefaultFlowStyle(FlowStyle.FLOW);
    options.setPrettyFlow(true);
    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());

    Human father2 = son2.getFather();
    assertEquals("Father", father2.getName());
    assertEquals("Mother", son2.getMother().getName());
    assertSame(father2, father2.getBankAccountOwner());
    assertSame(father2.getPartner(), son2.getMother());
    assertSame(father2, son2.getMother().getPartner());

    Set<Human> children2 = father2.getChildren();
    assertEquals(2, children2.size());
    assertSame(father2.getPartner().getChildren(), children2);

    for (Object child : children2) {
        // check if type descriptor was correct
        assertSame(Human.class, child.getClass());
    }

    // check if hashCode is correct
    validateSet(children2);
}
 
Example 12
Source File: HumanTest.java    From snake-yaml with Apache License 2.0 4 votes vote down vote up
public void testChildren2() {
    Human2 father = new Human2();
    father.setName("Father");
    father.setBirthday(new Date(1000000000));
    father.setBirthPlace("Leningrad");
    father.setBankAccountOwner(father);
    //
    Human2 mother = new Human2();
    mother.setName("Mother");
    mother.setBirthday(new Date(100000000000L));
    mother.setBirthPlace("Saint-Petersburg");
    father.setPartner(mother);
    mother.setPartner(father);
    mother.setBankAccountOwner(father);
    //
    Human2 son = new Human2();
    son.setName("Son");
    son.setBirthday(new Date(310000000000L));
    son.setBirthPlace("Munich");
    son.setBankAccountOwner(father);
    son.setFather(father);
    son.setMother(mother);
    //
    Human2 daughter = new Human2();
    daughter.setName("Daughter");
    daughter.setBirthday(new Date(420000000000L));
    daughter.setBirthPlace("New York");
    daughter.setBankAccountOwner(father);
    daughter.setFather(father);
    daughter.setMother(mother);
    //
    HashMap<Human2, String> children = new LinkedHashMap<Human2, String>(2);
    children.put(son, "son");
    children.put(daughter, "daughter");
    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);
    String etalon = Util.getLocalResource("recursive/with-children-2.yaml");
    assertEquals(etalon, output);
    //
    Human2 son2 = (Human2) yaml.load(output);
    assertNotNull(son2);
    assertEquals("Son", son.getName());

    Human2 father2 = son2.getFather();
    assertEquals("Father", father2.getName());
    assertEquals("Mother", son2.getMother().getName());
    assertSame(father2, father2.getBankAccountOwner());
    assertSame(father2.getPartner(), son2.getMother());
    assertSame(father2, son2.getMother().getPartner());

    Map<Human2, String> children2 = father2.getChildren();
    assertEquals(2, children2.size());
    assertSame(father2.getPartner().getChildren(), children2);

    validateMapKeys(children2);
}
 
Example 13
Source File: HumanTest.java    From snake-yaml with Apache License 2.0 4 votes vote down vote up
public void testChildrenWithoutRootTag() {
    Human father = new Human();
    father.setName("Father");
    father.setBirthday(new Date(1000000000));
    father.setBirthPlace("Leningrad");
    father.setBankAccountOwner(father);
    //
    Human mother = new Human();
    mother.setName("Mother");
    mother.setBirthday(new Date(100000000000L));
    mother.setBirthPlace("Saint-Petersburg");
    father.setPartner(mother);
    mother.setPartner(father);
    mother.setBankAccountOwner(father);
    //
    Human son = new Human();
    son.setName("Son");
    son.setBirthday(new Date(310000000000L));
    son.setBirthPlace("Munich");
    son.setBankAccountOwner(father);
    son.setFather(father);
    son.setMother(mother);
    //
    Human daughter = new Human();
    daughter.setName("Daughter");
    daughter.setBirthday(new Date(420000000000L));
    daughter.setBirthPlace("New York");
    daughter.setBankAccountOwner(father);
    daughter.setFather(father);
    daughter.setMother(mother);
    //
    Set<Human> children = new LinkedHashSet<Human>(2);
    children.add(son);
    children.add(daughter);
    father.setChildren(children);
    mother.setChildren(children);
    //
    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());

    Human father2 = son2.getFather();
    assertEquals("Father", father2.getName());
    assertEquals("Mother", son2.getMother().getName());
    assertSame(father2, father2.getBankAccountOwner());
    assertSame(father2.getPartner(), son2.getMother());
    assertSame(father2, son2.getMother().getPartner());

    Set<Human> children2 = father2.getChildren();
    assertEquals(2, children2.size());
    assertSame(father2.getPartner().getChildren(), children2);

    for (Object child : children2) {
        // check if type descriptor was correct
        assertSame(Human.class, child.getClass());
    }

    // check if hashCode is correct
    validateSet(children2);
}
 
Example 14
Source File: Settings.java    From tinkerpop with Apache License 2.0 4 votes vote down vote up
/**
 * Read configuration from a file into a new {@link Settings} object.
 *
 * @param stream an input stream containing a Gremlin Server YAML configuration
 * @return a new {@link Optional} object wrapping the created {@link Settings}
 */
public static Settings read(final InputStream stream) {
    Objects.requireNonNull(stream);

    final Constructor constructor = new Constructor(Settings.class);
    final TypeDescription settingsDescription = new TypeDescription(Settings.class);
    settingsDescription.putMapPropertyType("graphs", String.class, String.class);
    settingsDescription.putMapPropertyType("scriptEngines", String.class, ScriptEngineSettings.class);
    settingsDescription.putListPropertyType("serializers", SerializerSettings.class);
    settingsDescription.putListPropertyType("plugins", String.class);
    settingsDescription.putListPropertyType("processors", ProcessorSettings.class);
    constructor.addTypeDescription(settingsDescription);

    final TypeDescription serializerSettingsDescription = new TypeDescription(SerializerSettings.class);
    serializerSettingsDescription.putMapPropertyType("config", String.class, Object.class);
    constructor.addTypeDescription(serializerSettingsDescription);

    final TypeDescription scriptEngineSettingsDescription = new TypeDescription(ScriptEngineSettings.class);
    scriptEngineSettingsDescription.putListPropertyType("imports", String.class);
    scriptEngineSettingsDescription.putListPropertyType("staticImports", String.class);
    scriptEngineSettingsDescription.putListPropertyType("scripts", String.class);
    scriptEngineSettingsDescription.putMapPropertyType("config", String.class, Object.class);
    scriptEngineSettingsDescription.putMapPropertyType("plugins", String.class, Object.class);
    constructor.addTypeDescription(scriptEngineSettingsDescription);

    final TypeDescription sslSettings = new TypeDescription(SslSettings.class);
    constructor.addTypeDescription(sslSettings);

    final TypeDescription authenticationSettings = new TypeDescription(AuthenticationSettings.class);
    constructor.addTypeDescription(authenticationSettings);

    final TypeDescription serverMetricsDescription = new TypeDescription(ServerMetrics.class);
    constructor.addTypeDescription(serverMetricsDescription);

    final TypeDescription consoleReporterDescription = new TypeDescription(ConsoleReporterMetrics.class);
    constructor.addTypeDescription(consoleReporterDescription);

    final TypeDescription csvReporterDescription = new TypeDescription(CsvReporterMetrics.class);
    constructor.addTypeDescription(csvReporterDescription);

    final TypeDescription jmxReporterDescription = new TypeDescription(JmxReporterMetrics.class);
    constructor.addTypeDescription(jmxReporterDescription);

    final TypeDescription slf4jReporterDescription = new TypeDescription(Slf4jReporterMetrics.class);
    constructor.addTypeDescription(slf4jReporterDescription);

    final TypeDescription gangliaReporterDescription = new TypeDescription(GangliaReporterMetrics.class);
    constructor.addTypeDescription(gangliaReporterDescription);

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

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