/* * Copyright 2000-2022 Vaadin Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package com.vaadin.data; import java.io.Serializable; import java.util.function.Function; import com.vaadin.data.Binder.BindingBuilder; import com.vaadin.server.SerializableFunction; /** * Interface that implements conversion between a model and a presentation type. *
* Converters must not have any side effects (never update UI from inside a
* converter).
*
* @param
* A converter can optionally use locale to do the conversion.
*
* @param value
* The value to convert. Can be null
* @param context
* The value context for the conversion.
* @return The converted value compatible with the source type
*/
public Result
* A converter can optionally use locale to do the conversion.
*
* @param value
* The value to convert. Can be null
* @param context
* The value context for the conversion.
* @return The converted value compatible with the source type
*/
public PRESENTATION convertToPresentation(MODEL value,
ValueContext context);
/**
* Returns a converter that returns its input as-is in both directions.
*
* @param
* the presentation type
* @param Converter from(
SerializableFunction toModel,
SerializableFunction
* the presentation type
* @param Converter from(
SerializableFunction > toModel,
SerializableFunction () {
@Override
public Result
* The chained converters will form a new converter capable of converting
* from the presentation type of this converter to the model type of the
* other converter.
*
* In most typical cases you should not need this method but instead only
* need to define one converter for a binding using
* {@link BindingBuilder#withConverter(Converter)}.
*
* @param