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

net.morimekta.providence.jdbi.v2.EnumValueArgumentFactory 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 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);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy