class DynamicFormModelGenerator {

    public StaticModelFormRenderingContext getContextForModel(Object model, FormElementFilter... filters) {
        PortablePreconditions.checkNotNull("model",
                                           model);

        Optional<FormElementFilter[]> optional = Optional.ofNullable(filters);
        Stream<FormElementFilter> streamFilter = optional.map(value -> Stream.of(value)).orElseGet(Stream::empty);

        List<FormElementFilter> rootFormElemenFilters = new ArrayList<>();
        List<FormElementFilter> nestedFormFilters = new ArrayList<>();

        streamFilter.forEach(filter -> {
            if(!filter.getElementName().contains(".")) {
                rootFormElemenFilters.add(filter);
            } else {
                nestedFormFilters.add(filter);
            }
        });

        FormDefinition formDefinition = formBuildingService.generateFormForModel(model, rootFormElemenFilters.stream().toArray(FormElementFilter[]::new));

        if (formDefinition == null) {
            return null;
        }

        StaticModelFormRenderingContext context = new StaticModelFormRenderingContext(String.valueOf(System.currentTimeMillis()));

        context.setModel(model);
        context.setRootForm(formDefinition);

        if (context.getModel() != null) {
            initNestedFormSettings(formDefinition, context.getModel(), context, nestedFormFilters);
        } else {
            initNestedFormSettings(formDefinition,null, context, nestedFormFilters);
        }

        return context;
    }

    @Inject public  DynamicFormModelGenerator(FormBuildingService formBuildingService,
                                     PropertyValueExtractor propertyValueExtractor);

}