Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include Converter for the UUID data type. #5579

Closed
vaadin-bot opened this issue Aug 22, 2014 · 3 comments
Closed

Include Converter for the UUID data type. #5579

vaadin-bot opened this issue Aug 22, 2014 · 3 comments
Labels
Stale Stale bot label

Comments

@vaadin-bot
Copy link
Collaborator

Originally by basil.bourque


Add a com.vaadin.data.util.converter.Converter implementation to handle the UUID data type.

-Motivation*

Java includes a UUID class. UUID is becoming increasingly popular, used in internet protocols, enterprise work, and as primary key values in database such as Postgres. Vaadin’s data model, Table/Grid, and such really should be supporting UUID out-of-the box.

-Example Code*

The following is some source code I found written by "petter" of Vaadin. I modified that code by adding a call to toLowercase as the UUID spec requires that a hex-string representation of the UUID’s 128-bit value be presented in lowercase, though uppercase must be tolerated as input for parsing.

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.
 - 
 - @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;
    }
}


Imported from https://dev.vaadin.com/ issue #14493

@vaadin-bot
Copy link
Collaborator Author

Originally by basil.bourque


The reason I added the call to toLowercase is because the JavaDoc for the UUID.class’ implementation of toString incorrectly documents lowercase or uppercase as being allowed for generation of the hex-string representing a UUID. Some implementations of Java may therefore output uppercase hex. But in fact that JavaDoc is incorrect, as the spec for UUID clearly requires the hex-string be lowercase: "The hexadecimal values "a" through "f" are output as lower case characters and are case insensitive on input."

@stale
Copy link

stale bot commented Mar 21, 2018

Hello there!

It looks like this issue hasn't progressed lately. There are so many issues that we just can't deal them all within a reasonable timeframe.

There are a couple of things you could help to get things rolling on this issue (this is an automated message, so expect that some of these are already in use):

  • Check if the issue is still valid for the latest version. There are dozens of duplicates in our issue tracker, so it is possible that the issue is already tackled. If it appears to be fixed, close the issue, otherwise report to the issue that it is still valid.
  • Provide more details how to reproduce the issue.
  • Explain why it is important to get this issue fixed and politely draw others attention to it e.g. via the forum or social media.
  • Add a reduced test case about the issue, so it is easier for somebody to start working on a solution.
  • Try fixing the issue yourself and create a pull request that contains the test case and/or a fix for it. Handling the pull requests is the top priority for the core team.
  • If the issue is clearly a bug, use the Warranty in your Vaadin subscription to raise its priority.

Thanks again for your contributions! Even though we haven't been able to get this issue fixed, we hope you to report your findings and enhancement ideas in the future too!

@stale stale bot added the Stale Stale bot label label Mar 21, 2018
@stale
Copy link

stale bot commented Sep 6, 2020

The issue was automatically closed due to inactivity. If you found some new details to it or started working on it, comment on the issue so that maintainers can re-open it.

@stale stale bot closed this as completed Sep 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Stale Stale bot label
Projects
None yet
Development

No branches or pull requests

1 participant