Class 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.
    • Method Detail

      • passThrough

        public static <F> DslConverter<F,​F> passThrough​(Class<F> fieldAndValueType)
      • 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.