class YamlSafeConstructor extends Constructor {
    private Set<String> supportedTypes;

    public YamlSafeConstructor(Set<Class<?>> supportedClasses) {
        supportedTypes = supportedClasses.stream().map(Class::getName).collect(Collectors.collectingAndThen(Collectors.toSet(), Collections::unmodifiableSet));
    }

    @Override
    protected Class<?> getClassForName(String name) throws ClassNotFoundException {<FILL_FUNCTION_BODY>}
}

        Assert.state(supportedTypes.contains(name), "Unsupported '" + name + "' type encountered in YAML document");

        return super.getClassForName(name);
    
<no_super_class>