I filed a feature request ticket with Vaadin to bundle such a class with Vaadin.
Source code…
import com.vaadin.data.util.converter.Converter;
import java.util.Locale;
import java.util.UUID;
/**
* Modified by Basil Bourque to ensure output of hex string is in lowercase as required by the UUID spec. 2014-08.
*
* @author petter@vaadin.com
*/
public class UUIDToStringConverter implements Converter<String , UUID>
{
private static final String NULL_STRING = "(none)";
@Override
public UUID convertToModel ( String value , Class<? extends UUID> targetType , Locale locale ) throws ConversionException
{
try {
return value == null || value.isEmpty() || value.equals( NULL_STRING ) ? null : UUID.fromString( value );
} catch ( IllegalArgumentException ex ) {
throw new ConversionException( ex );
}
}
@Override
public String convertToPresentation ( UUID value , Class<? extends String> targetType , Locale locale ) throws ConversionException
{
return value == null ? NULL_STRING : value.toString().toLowerCase(); // The UUID spec *requires* hex-string output to be lowercase. Must tolerate uppercase for input.
}
@Override
public Class<UUID> getModelType ()
{
return UUID.class;
}
@Override
public Class<String> getPresentationType ()
{
return String.class;
}
}
xx
I filed a feature request ticket with Vaadin to bundle such a class with Vaadin.
ReplyDeleteDownload Free Crack Software Full Version