org.xblackcat.sjpu.storage.converter.ToBooleanConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sjpu-dbah Show documentation
Show all versions of sjpu-dbah Show documentation
Service for generating DB access logic in simple way via interfaces and annotations
package org.xblackcat.sjpu.storage.converter;
import java.sql.ResultSet;
import java.sql.SQLException;
/**
* The class to convert a single-column result to Boolean object.
*
* Valid values are threaded as true
: boolean true, non-zero number value.
* All other values are threaded as false
. NULL threaded as null.
*/
public class ToBooleanConverter implements IToObjectConverter {
public Boolean convert(ResultSet rs) throws SQLException {
Object value = rs.getObject(1);
if (value instanceof Boolean) {
return (Boolean) value;
}
return value instanceof Number && ((Number) value).intValue() != 0;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy