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, ToDocumentFieldValueConverter<V,? extends F> delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description F
convert(V value, ToDocumentFieldValueConvertContext context)
F
convertUnknown(Object value, ToDocumentFieldValueConvertContext context)
Convert an input value of unknown type that may not have the required typeV
.boolean
isCompatibleWith(DslConverter<?,?> other)
String
toString()
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, ToDocumentFieldValueConverter<V,? extends F> delegate)
-
-
Method Detail
-
convert
public F convert(V value, ToDocumentFieldValueConvertContext context)
- Parameters:
value
- The source value to convert.context
- A context that can beextended
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.
-
convertUnknown
public F convertUnknown(Object value, ToDocumentFieldValueConvertContext 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 beextended
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
- AnotherDslConverter
, nevernull
.- Returns:
true
if the given object behaves exactly the same as this object, i.e. itsconvert(Object, ToDocumentFieldValueConvertContext)
andconvertUnknown(Object, ToDocumentFieldValueConvertContext)
methods are guaranteed to always return the same value as this object's when given the same input.false
otherwise, or when in doubt.
-
-