java.lang.Object
org.hibernate.search.engine.backend.types.converter.spi.DslConverter<V,F>
Type Parameters:
V - The type of values passed to the DSL.
F - The type of converted values passed to the backend.

public final class DslConverter<V,F> extends Object
A converter for values passed to the DSL.
  • Constructor Details

  • Method Details

    • passThrough

      public static <F> DslConverter<F,F> passThrough(Class<F> fieldAndValueType)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • valueType

      public Class<V> valueType()
    • toDocumentValue

      public F toDocumentValue(V value, ToDocumentValueConvertContext context)
      Parameters:
      value - The source value to convert.
      context - A context that can be extended to a more useful type, giving access to such things as a Hibernate ORM SessionFactory (if using the Hibernate ORM mapper).
      Returns:
      The converted index field value.
    • unknownTypeToDocumentValue

      public F unknownTypeToDocumentValue(Object value, ToDocumentValueConvertContext context)
      Convert an input value of unknown type that may not have the required type V.

      Called when passing values to the predicate DSL in particular.

      Parameters:
      value - The value to convert.
      context - A context that can be extended to a more useful type, giving access to such things as a Hibernate ORM SessionFactory (if using the Hibernate ORM mapper).
      Returns:
      The converted index field value.
      Throws:
      RuntimeException - If the value does not match the expected type.
    • withInputType

      public <T> DslConverter<? super T,F> withInputType(Class<T> inputTypeCandidate, EventContextProvider eventContextProvider)
      Check whether DSL arguments values can have the given type, and returns the DSL converter with an appropriate type.
      Type Parameters:
      T - A candidate type for input values.
      Parameters:
      inputTypeCandidate - A candidate type for input values.
      eventContextProvider - A provider for the event context to pass to produced exceptions.
      Returns:
      The DSL converter, guaranteed to accept values to the given type.
      Throws:
      SearchException - If the DSL converter cannot accept values to the given type.
    • isCompatibleWith

      public boolean isCompatibleWith(DslConverter<?,?> other)
      Parameters:
      other - Another DslConverter, never null.
      Returns:
      true if the given object behaves exactly the same as this object, i.e. its toDocumentValue(Object, ToDocumentValueConvertContext) and unknownTypeToDocumentValue(Object, ToDocumentValueConvertContext) methods are guaranteed to always return the same value as this object's when given the same input. false otherwise, or when in doubt.