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

io.github.kbachilo.jooq.converter.BooleanConverter Maven / Gradle / Ivy

package io.github.kbachilo.jooq.converter;

import org.jooq.Converter;

import java.util.Objects;

public class BooleanConverter implements Converter {

    public Boolean from(Byte databaseObject) {
        return Objects.isNull(databaseObject) ? null : databaseObject == 1;
    }

    public Byte to(Boolean userObject) {
        if (userObject == null) {
            return null;
        }
        return userObject ? (byte) 1 : 0;
    }

    public Class fromType() {
        return Byte.class;
    }

    public Class toType() {
        return Boolean.class;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy