net.morimekta.providence.jdbi.v3.EnumValueArgument Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of providence-jdbi-v3 Show documentation
Show all versions of providence-jdbi-v3 Show documentation
Utilities for handling providence messages using jdbi v3.
package net.morimekta.providence.jdbi.v3;
import net.morimekta.providence.PEnumValue;
import org.jdbi.v3.core.argument.Argument;
import org.jdbi.v3.core.statement.StatementContext;
import javax.annotation.Nonnull;
import java.sql.PreparedStatement;
import java.sql.SQLException;
class EnumValueArgument implements Argument {
private final PEnumValue value;
public EnumValueArgument(@Nonnull PEnumValue value) {this.value = value;}
@Override
public String toString() {
return value.asInteger() + " (" + value.asString() + ")";
}
@Override
public void apply(int position, PreparedStatement statement, StatementContext ctx)
throws SQLException {
statement.setInt(position, value.asInteger());
}
}