ByteStringArgumentFactory.java
package net.morimekta.proto.jdbi.v3.util;
import com.google.protobuf.ByteString;
import org.jdbi.v3.core.argument.Argument;
import org.jdbi.v3.core.argument.ArgumentFactory;
import org.jdbi.v3.core.config.ConfigRegistry;
import java.lang.reflect.Type;
import java.util.Optional;
import static net.morimekta.proto.jdbi.MorimektaJdbiOptions.SqlType.VARBINARY;
public class ByteStringArgumentFactory implements ArgumentFactory {
public static final ByteStringArgumentFactory INSTANCE = new ByteStringArgumentFactory();
@Override
public Optional<Argument> build(Type type, Object value, ConfigRegistry config) {
if (!type.equals(ByteString.class)) {
return Optional.empty();
}
return Optional.of(new ByteStringArgument((ByteString) value, VARBINARY));
}
}