All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.vaadin.ui.declarative.converters.DesignObjectConverter Maven / Gradle / Ivy

There is a newer version: 8.27.3
Show newest version
/*
 * Copyright (C) 2000-2024 Vaadin Ltd
 *
 * This program is available under Vaadin Commercial License and Service Terms.
 *
 * See  for the full
 * license.
 */
package com.vaadin.ui.declarative.converters;

import com.vaadin.data.Converter;
import com.vaadin.data.Result;
import com.vaadin.data.ValueContext;
import com.vaadin.ui.declarative.DesignAttributeHandler;

/**
 * An converter for Object to/from String for {@link DesignAttributeHandler} to
 * use internally.
 *
 * @since 7.4
 * @author Vaadin Ltd
 */
public class DesignObjectConverter implements Converter {

    @Override
    public Result convertToModel(String value, ValueContext context) {
        return Result.ok(value);
    }

    @Override
    public String convertToPresentation(Object value, ValueContext context) {
        if (value == null) {
            return null;
        }

        return value.toString();
    }

}