net.morimekta.providence.jdbi.v2.EnumValueArgumentFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of providence-jdbi-v2 Show documentation
Show all versions of providence-jdbi-v2 Show documentation
Utilities for handling providence messages using jdbi v2.
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 org.skife.jdbi.v2.tweak.ArgumentFactory;
public class EnumValueArgumentFactory implements ArgumentFactory {
private final Class> klass;
@SuppressWarnings("unused")
public EnumValueArgumentFactory() {
this(PEnumValue.class);
}
public EnumValueArgumentFactory(Class> klass) {
this.klass = klass;
}
@Override
public boolean accepts(Class> expectedType, Object value, StatementContext ctx) {
return klass.isAssignableFrom(expectedType);
}
@Override
public Argument build(Class> expectedType, PEnumValue value, StatementContext ctx) {
return new EnumValueArgument(value);
}
}