org.sql2o.converters.UUIDConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sql2o Show documentation
Show all versions of sql2o Show documentation
Easy database query library
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);
}
}