Package com.vaadin.data.converter
Class StringToUuidConverter
- java.lang.Object
-
- com.vaadin.data.converter.StringToUuidConverter
-
- All Implemented Interfaces:
Converter<java.lang.String,java.util.UUID>,java.io.Serializable
public class StringToUuidConverter extends java.lang.Object implements Converter<java.lang.String,java.util.UUID>
A converter that converts fromStringtoUUIDand back.Leading and trailing white spaces are ignored when converting from a String.
The String representation uses the canonical format of 32-characters with a hyphen to separate each of five groups of hexadecimal digits as defined in: RFC 4122: A Universally Unique IDentifier (UUID) URN Namespace http://www.ietf.org/rfc/rfc4122.txt
- Since:
- 8.8
- Author:
- Vaadin Ltd
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description StringToUuidConverter(ErrorMessageProvider errorMessageProvider)Constructs a new converter instance with the given error message provider.StringToUuidConverter(java.lang.String errorMessage)Constructs a converter for String to UUID and back.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Result<java.util.UUID>convertToModel(java.lang.String value, ValueContext context)Converts the given value from model type to presentation type.java.lang.StringconvertToPresentation(java.util.UUID value, ValueContext context)Converts the given value from presentation type to model type.
-
-
-
Constructor Detail
-
StringToUuidConverter
public StringToUuidConverter(java.lang.String errorMessage)
Constructs a converter for String to UUID and back.- Parameters:
errorMessage- the error message to use if conversion fails
-
StringToUuidConverter
public StringToUuidConverter(ErrorMessageProvider errorMessageProvider)
Constructs a new converter instance with the given error message provider. Empty strings are converted tonull.- Parameters:
errorMessageProvider- the error message provider to use if conversion fails
-
-
Method Detail
-
convertToModel
public Result<java.util.UUID> convertToModel(java.lang.String value, ValueContext context)
Description copied from interface:ConverterConverts the given value from model type to presentation type.A converter can optionally use locale to do the conversion.
- Specified by:
convertToModelin interfaceConverter<java.lang.String,java.util.UUID>- Parameters:
value- The value to convert. Can be nullcontext- The value context for the conversion.- Returns:
- The converted value compatible with the source type
-
convertToPresentation
public java.lang.String convertToPresentation(java.util.UUID value, ValueContext context)Description copied from interface:ConverterConverts the given value from presentation type to model type.A converter can optionally use locale to do the conversion.
- Specified by:
convertToPresentationin interfaceConverter<java.lang.String,java.util.UUID>- Parameters:
value- The value to convert. Can be nullcontext- The value context for the conversion.- Returns:
- The converted value compatible with the source type
-
-