All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sql2o.converters.UUIDConverter Maven / Gradle / Ivy

There is a newer version: 1.9.0-RC1
Show newest version
package org.sql2o.converters;

import java.util.UUID;

/**
 * Used by sql2o to convert a value from the database into a {@link UUID}.
 */
public class UUIDConverter extends ConverterBase {
    public UUID convert(Object val) throws ConverterException {
        if (val == null){
            return null;
        }

        if (val instanceof UUID){
            return (UUID)val;
        }

        if(val instanceof String){
            return UUID.fromString((String) val);
        }

        throw new ConverterException("Cannot convert type " + val.getClass() + " " + UUID.class);
    }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy