Class DslConverter<V,F>
- 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 Summary
Constructors Constructor Description DslConverter(Class<V> valueType, ToDocumentValueConverter<V,? extends F> delegate)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanisCompatibleWith(DslConverter<?,?> other)static <F> DslConverter<F,F>passThrough(Class<F> fieldAndValueType)FtoDocumentValue(V value, ToDocumentValueConvertContext context)StringtoString()FunknownTypeToDocumentValue(Object value, ToDocumentValueConvertContext context)Convert an input value of unknown type that may not have the required typeV.Class<V>valueType()<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.
-
-
-
Constructor Detail
-
DslConverter
public DslConverter(Class<V> valueType, ToDocumentValueConverter<V,? extends F> delegate)
-
-
Method Detail
-
passThrough
public static <F> DslConverter<F,F> passThrough(Class<F> fieldAndValueType)
-
toDocumentValue
public F toDocumentValue(V value, ToDocumentValueConvertContext context)
- Parameters:
value- The source value to convert.context- A context that can beextendedto 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 typeV.Called when passing values to the predicate DSL in particular.
- Parameters:
value- The value to convert.context- A context that can beextendedto 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- AnotherDslConverter, nevernull.- Returns:
trueif the given object behaves exactly the same as this object, i.e. itstoDocumentValue(Object, ToDocumentValueConvertContext)andunknownTypeToDocumentValue(Object, ToDocumentValueConvertContext)methods are guaranteed to always return the same value as this object's when given the same input.falseotherwise, or when in doubt.
-
-