class FormDefinitionSerializerImpl implements FormDefinitionSerializer {

    @Override
    public FormDefinition deserialize(String serializedForm) {
        GsonBuilder builder = new GsonBuilder();
        builder.registerTypeAdapter(FormModel.class,
                                    formModelSerializer);
        builder.registerTypeAdapter(FieldDefinition.class,
                                    fieldSerializer);

        builder.registerTypeAdapter(ModelProperty.class,
                                    (JsonDeserializer<ModelProperty>) (json, typeOfT, context) -> context.deserialize(json,
                                                                                                                      ModelPropertyImpl.class));
        builder.registerTypeAdapter(TypeInfo.class,
                                    (JsonDeserializer<TypeInfo>) (json, typeOfT, context) -> context.deserialize(json,
                                                                                                                 TypeInfoImpl.class));

        builder.registerTypeAdapter(ModelMetaData.class,
                                    (JsonDeserializer<ModelMetaData>) (json, typeOfT, context) -> context.deserialize(json,
                                                                                                                      ModelMetaDataImpl.class));

        builder.registerTypeAdapter(MetaDataEntry.class,
                                    (JsonDeserializer<MetaDataEntry>) (json, typeOfT, context) -> {
                                        JsonObject jsonField = json.getAsJsonObject();
                                        JsonElement jsonName = jsonField.get("name");
                                        return context.deserialize(json,
                                                                   metaDataEntryManager.getMetaDataEntryClass(jsonName.getAsString()));
                                    });

        Gson gson = builder.create();

        return gson.fromJson(serializedForm,
                             FormDefinition.class);
    }

    @Inject public  FormDefinitionSerializerImpl(FieldSerializer fieldSerializer,
                                        FormModelSerializer formModelSerializer,
                                        MetaDataEntryManager metaDataEntryManager);

}