-
-
Save jkbbwr/3f6fdca5d74f7c584fa7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@BindingAnnotation(BindBytes.BytesBinderFactory.class) | |
@Retention(RetentionPolicy.RUNTIME) | |
@Target({ElementType.PARAMETER}) | |
public @interface BindBytes { | |
String value(); | |
class BytesBinderFactory implements BinderFactory { | |
public Binder build(final Annotation annotation) { | |
return new Binder<BindBytes, byte[]>() { | |
public void bind(SQLStatement q, BindBytes bind, byte[] arg) { | |
String name = ((BindBytes) annotation).value(); | |
q.bind(name, UtilKt.hexify(arg)); | |
} | |
}; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@BindingAnnotation(BindBytes.BytesBinderFactory::class) | |
@Retention(RetentionPolicy.RUNTIME) | |
@Target(AnnotationTarget.VALUE_PARAMETER) | |
annotation class BindBytes(val value: String) | |
class BytesBinderFactory : BinderFactory { | |
override fun build(annotation: Annotation): Binder<BindBytes, ByteArray> { | |
return Binder { q, bind, arg -> | |
val name = (annotation as BindBytes).value | |
q.bind(name, arg.hexify()) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment