Class ConverterUtil

    • Constructor Summary

      Constructors 
      Constructor Description
      ConverterUtil()
      Deprecated.
       
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static boolean canConverterHandle​(Converter<?,​?> converter, Class<?> presentationType, Class<?> modelType)
      Deprecated.
      Checks if the given converter can handle conversion between the given presentation and model type.
      static boolean canConverterPossiblyHandle​(Converter<?,​?> converter, Class<?> presentationType, Class<?> modelType)
      Deprecated.
      Checks if it possible that the given converter can handle conversion between the given presentation and model type somehow.
      static <PRESENTATIONTYPE,​MODELTYPE>
      PRESENTATIONTYPE
      convertFromModel​(MODELTYPE modelValue, Class<? extends PRESENTATIONTYPE> presentationType, Converter<PRESENTATIONTYPE,​MODELTYPE> converter, Locale locale)
      Deprecated.
      Convert the given value from the data source type to the UI type.
      static <MODELTYPE,​PRESENTATIONTYPE>
      MODELTYPE
      convertToModel​(PRESENTATIONTYPE presentationValue, Class<MODELTYPE> modelType, Converter<PRESENTATIONTYPE,​MODELTYPE> converter, Locale locale)
      Deprecated.
      Convert the given value from the presentation (UI) type to model (data source) type.
      static <PRESENTATIONTYPE,​MODELTYPE>
      Converter<PRESENTATIONTYPE,​MODELTYPE>
      getConverter​(Class<PRESENTATIONTYPE> presentationType, Class<MODELTYPE> modelType, VaadinSession session)
      Deprecated.
      Finds a converter that can convert from the given presentation type to the given model type and back.
    • Constructor Detail

      • ConverterUtil

        public ConverterUtil()
        Deprecated.
    • Method Detail

      • getConverter

        public static <PRESENTATIONTYPE,​MODELTYPE> Converter<PRESENTATIONTYPE,​MODELTYPE> getConverter​(Class<PRESENTATIONTYPE> presentationType,
                                                                                                                  Class<MODELTYPE> modelType,
                                                                                                                  VaadinSession session)
        Deprecated.
        Finds a converter that can convert from the given presentation type to the given model type and back. Uses the given application to find a ConverterFactory or, if application is null, uses the VaadinSession.getCurrent().
        Type Parameters:
        PRESENTATIONTYPE - the presentation type
        MODELTYPE - the model type
        Parameters:
        presentationType - the presentation type
        modelType - the model type
        session - the session to use to find a ConverterFactory or null to use the current session
        Returns:
        a Converter capable of converting between the given types or null if no converter was found
      • convertFromModel

        public static <PRESENTATIONTYPE,​MODELTYPE> PRESENTATIONTYPE convertFromModel​(MODELTYPE modelValue,
                                                                                           Class<? extends PRESENTATIONTYPE> presentationType,
                                                                                           Converter<PRESENTATIONTYPE,​MODELTYPE> converter,
                                                                                           Locale locale)
                                                                                    throws Converter.ConversionException
        Deprecated.
        Convert the given value from the data source type to the UI type.
        Type Parameters:
        PRESENTATIONTYPE - the presentation type
        MODELTYPE - the model type
        Parameters:
        modelValue - the model value to convert
        presentationType - the type of the presentation value
        converter - the converter to use
        locale - the locale to use for conversion
        Returns:
        the converted value, compatible with the presentation type, or the original value if its type is compatible and no converter is set.
        Throws:
        Converter.ConversionException - if there was a problem converting the value
      • convertToModel

        public static <MODELTYPE,​PRESENTATIONTYPE> MODELTYPE convertToModel​(PRESENTATIONTYPE presentationValue,
                                                                                  Class<MODELTYPE> modelType,
                                                                                  Converter<PRESENTATIONTYPE,​MODELTYPE> converter,
                                                                                  Locale locale)
                                                                           throws Converter.ConversionException
        Deprecated.
        Convert the given value from the presentation (UI) type to model (data source) type.
        Type Parameters:
        PRESENTATIONTYPE - the presentation type
        MODELTYPE - the model type
        Parameters:
        presentationValue - the presentation value to convert
        modelType - the type of the model
        converter - the converter to use
        locale - the locale to use for conversion
        Returns:
        the converted value, compatible with the model type, or the original value if its type is compatible and no converter is set.
        Throws:
        Converter.ConversionException - if there was a problem converting the value
      • canConverterHandle

        public static boolean canConverterHandle​(Converter<?,​?> converter,
                                                 Class<?> presentationType,
                                                 Class<?> modelType)
        Deprecated.
        Checks if the given converter can handle conversion between the given presentation and model type. Does strict type checking and only returns true if the converter claims it can handle exactly the given types.
        Parameters:
        converter - The converter to check. If this is null the result is always false.
        presentationType - The presentation type
        modelType - The model type
        Returns:
        true if the converter supports conversion between the given presentation and model type, false otherwise
        See Also:
        canConverterPossiblyHandle(Converter, Class, Class)
      • canConverterPossiblyHandle

        public static boolean canConverterPossiblyHandle​(Converter<?,​?> converter,
                                                         Class<?> presentationType,
                                                         Class<?> modelType)
        Deprecated.
        Checks if it possible that the given converter can handle conversion between the given presentation and model type somehow.
        Parameters:
        converter - The converter to check. If this is null the result is always false.
        presentationType - The presentation type
        modelType - The model type
        Returns:
        true if the converter possibly support conversion between the given presentation and model type, false otherwise