class ImportView implements Transform<Import, String> {

    @Override
    public Optional<String> transform(Generator gen, Import model) {
        requireNonNulls(gen, model);
        final String name = stripGenerics(model.getType().getTypeName())
            .replace('$', '.');

        if (!model.getModifiers().isEmpty()
        ||   shouldImport(gen, model.getType())) {
            return Optional.of(
                "import "
                + gen.onEach(model.getModifiers()).collect(joinIfNotEmpty(" ", "", " "))
                + name
                + model.getStaticMember().map(str -> "." + str).orElse("")
                + ";"
            ).filter(x -> {
                gen.getDependencyMgr().load(name);
                return true;
            });
        } else {
            return Optional.empty();
        }
    }

    /**
     * Returns <code>true</code> if the specified type requires an explicit
     * import. If the type has already been imported or is part of a package
     * that does not need to be imported, <code>false</code> is returned.
     *
     * @param gen the generator
     * @param type the type to import
     * @return      <code>true</code> if it should be imported explicitly
     */
    private boolean shouldImport(Generator gen, Type type) {<FILL_FUNCTION_BODY>}
}

        final DependencyManager mgr = gen.getDependencyMgr();
        final String typeName = stripGenerics(type.getTypeName());
        
        if (mgr.isIgnored(typeName)) {
            return false;
        }

        if (mgr.isLoaded(typeName)) {
            return false;
        }

        final Optional<String> current = mgr.getCurrentPackage();
        final Optional<String> suggested = packageName(typeName);

        // TODO: Inner classes might still be imported explicitly.
            
        return !(current.isPresent()
            && suggested.isPresent()
            && current.get().equals(suggested.get()));
    
<no_super_class>