Class LinkkiConverterRegistry

  • All Implemented Interfaces:
    Serializable

    public class LinkkiConverterRegistry
    extends Object
    implements Serializable
    A converter registry that holds a set of standard converters. The registry could be instantiated with additional converters which would be set before the default converters. That means if the registry is initiated with a custom converter which has the same types as an existing one, the custom converter is used with higher priority.
    See Also:
    Serialized Form
    • Constructor Detail

      • LinkkiConverterRegistry

        @SafeVarargs
        public LinkkiConverterRegistry​(com.vaadin.flow.data.converter.Converter<?,​?>... customConverters)
        Creates a new LinkkiConverterRegistry with all default converters.
        Parameters:
        customConverters - custom converters that are registered within this LinkkiConverterRegistry
      • LinkkiConverterRegistry

        public LinkkiConverterRegistry​(Collection<com.vaadin.flow.data.converter.Converter<?,​?>> customConverters)
        Creates a new LinkkiConverterRegistry with additional converters which are registered with higher priority before the default converters.
        Parameters:
        customConverters - custom converters that are registered within this LinkkiConverterRegistry
      • LinkkiConverterRegistry

        public LinkkiConverterRegistry​(org.linkki.util.Sequence<com.vaadin.flow.data.converter.Converter<?,​?>> customConverters)
    • Method Detail

      • findConverter

        public <P,​M> com.vaadin.flow.data.converter.Converter<P,​M> findConverter​(Type presentationType,
                                                                                             Type modelType)
        Finds a converter that does match the two types for the presentation an the model type.

        If the types are classes they have to match exactly the type of a converter. We do not check assignable types because the covariance and contravariance depends on the direction of conversion.

        If both types are equal or we cannot determine the correct type for any reason, the identity converter is returned.

        If the correct type could be determined but there is no matching converter, an IllegalArgumentException is thrown.

        Parameters:
        presentationType - The type of the presentation, that means the value type of the UI component
        modelType - The type of the model, that means the value type of the model property
        Returns:
        the converter that best match the two types
        Throws:
        IllegalArgumentException - if the types could be considered to be correct but no matching converter could be found.
      • getAllConverters

        protected org.linkki.util.Sequence<com.vaadin.flow.data.converter.Converter<?,​?>> getAllConverters()