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

net.morimekta.providence.jdbi.v2.EnumValueArgument Maven / Gradle / Ivy

There is a newer version: 2.7.0
Show newest version
package net.morimekta.providence.jdbi.v2;

import net.morimekta.providence.PEnumValue;
import org.skife.jdbi.v2.StatementContext;
import org.skife.jdbi.v2.tweak.Argument;

import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Types;

public class EnumValueArgument implements Argument {
    private final PEnumValue value;

    public EnumValueArgument(PEnumValue value) {
        this.value = value;
    }

    @Override
    public void apply(int position, PreparedStatement statement, StatementContext ctx) throws SQLException {
        if (value == null) {
            statement.setNull(position, Types.INTEGER);
        } else {
            statement.setInt(position, value.asInteger());
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy