V
- The type of values on the POJO side of the bridge.F
- The type of raw index field values, on the index side of the bridge.public interface ValueBridge<V,F> extends AutoCloseable
V
and an index field of type F
.
The ValueBridge
interface is a simpler version of PropertyBridge
,
in which no property metadata is available
and a given input value can only be mapped to a single field, in particular.
Modifier and Type | Method and Description |
---|---|
default StandardIndexFieldTypeContext<?,F> |
bind(ValueBridgeBindingContext<V> context)
Bind this bridge instance to the given index field model and the given POJO model element.
|
V |
cast(Object value)
Cast an input value to the expected type
V . |
default void |
close()
Close any resource before the bridge is discarded.
|
default boolean |
isCompatibleWith(ValueBridge<?,?> other) |
F |
toIndexedValue(V value,
ValueBridgeToIndexedValueContext context)
Transform the given POJO-extracted value to the value of the indexed field.
|
default StandardIndexFieldTypeContext<?,F> bind(ValueBridgeBindingContext<V> context)
This method is called exactly once for each bridge instance, before any other method. It allows the bridge to:
ValueBridgeBindingContext.getTypeFactory()
.
ValueBridgeBindingContext.getBridgedElement()
.
ValueBridgeBindingContext.getTypeFactory()
.
context
- An entry point allowing to perform the operations listed above.context.getTypeFactory()
and setting the expectations regarding the index field type
(for instance return context.getTypeFactory().asString()
).
null
to let Hibernate Search derive the expectations
from the ValueBridge
's generic type parameters.F toIndexedValue(V value, ValueBridgeToIndexedValueContext context)
value
- The POJO-extracted value to be transformed.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).V cast(Object value)
V
.
Called for values passed to the predicate DSL in particular.
value
- The value to convert.RuntimeException
- If the value does not match the expected type.default boolean isCompatibleWith(ValueBridge<?,?> other)
other
- Another ValueBridge
, never null
.true
if the given object is also a ValueBridge
that behaves exactly the same as this object, i.e. its cast(Object)
and toIndexedValue(Object, ValueBridgeToIndexedValueContext)
methods are guaranteed to always return the same value as this object's
when given the same input. false
otherwise, or when in doubt.default void close()
close
in interface AutoCloseable
Copyright © 2006-2019 Red Hat, Inc. and others. Licensed under the GNU Lesser General Public License (LGPL), version 2.1 or later.