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

org.openmetadata.service.util.jdbi.BindFQN Maven / Gradle / Ivy

There is a newer version: 1.5.11
Show newest version
package org.openmetadata.service.util.jdbi;

import java.lang.annotation.Annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
import java.lang.reflect.Type;
import org.jdbi.v3.sqlobject.customizer.SqlStatementCustomizerFactory;
import org.jdbi.v3.sqlobject.customizer.SqlStatementCustomizingAnnotation;
import org.jdbi.v3.sqlobject.customizer.SqlStatementParameterCustomizer;
import org.openmetadata.service.util.FullyQualifiedName;

/** Convert fqn string to fqnHash */
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.PARAMETER})
@SqlStatementCustomizingAnnotation(BindFQN.Factory.class)
public @interface BindFQN {
  String value();

  class Factory implements SqlStatementCustomizerFactory {
    @Override
    public SqlStatementParameterCustomizer createForParameter(
        Annotation annotation,
        Class sqlObjectType,
        Method method,
        Parameter param,
        int index,
        Type type) {
      BindFQN bind = (BindFQN) annotation;
      return (stmt, arg) -> {
        String fqn = (String) arg;
        stmt.bind(bind.value(), FullyQualifiedName.buildHash(fqn));
      };
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy